#Abishek - payment element billing fields

1 messages ยท Page 1 of 1 (latest)

frozen geode
#

Good question. Checking in to that. What payment method are you taking?

#

That shouldn't matter because you said "always" but I just want to make sure I am testing right

fleet sail
#

I am using elements.create('payment') if that is what you are asking. I only want to use a credit card and that is why I am disabling the wallets on the option. I did not want to use `elements.create('card'). Not a fan of that layout

#

but want to show all the billing fields

frozen geode
#

We only have auto and never

fleet sail
#

so, how does auto work?

frozen geode
#

I believe there is a feature request for always. I do not know if there is on the roadmap

fleet sail
#

do they only show when it is necessary?

frozen geode
#

Auto is the behavior you are seeing now. If the payment method requires the billing options it will show it, if it does not require them it does not

#

Exactly

fleet sail
#

ok

frozen geode
#

So at the moment the recommendation would be to choose never and create your own form to take billing information

fleet sail
#

is there a way to pass the custom elements when calling confirmSetup?

frozen geode
#

Exactly. You would pass the values in to that call

fleet sail
#

alright cool. thank you

fleet sail
#

when using confirmSetup does it always navigate to the return_url?

frozen geode
fleet sail
#

but the redirect isn't required for confirmCardSetup right?

frozen geode
#

I don't believe so. If 3DS is required, that should come up as a modal instead of a redirect.

#

Are you using confirmCardSetup with the Payment Element and it is redirecting?

fleet sail
#

No, I don't want a redirection, but I also don't want to use confirmCardSetup. Not a fan of the layout when creating a card element.

#

Is it possible to configure to use a modal instead of a redirect when it comes to confirmSetup?

obtuse onyx
#

Hi ๐Ÿ‘‹ @frozen geode had to step away. I'm getting caught up

fleet sail
#

there isn't a great way to update the appearance of the card element as well

obtuse onyx
#

As @frozen geode pointed out, the 3DS authentication process uses a modal window to avoid redirection.

fleet sail
#

yes, but that is only for when the payment element is card and not payment. Just wondering if there is a way to configure to use the modal instead of a redirect when it comes to elements.create('payment')

obtuse onyx
#

That is not correct. I was testing 3DS earlier today with elements.create('payment') and it definitely still used a modal window.

fleet sail
#

does'nt elements.create('payment') require you to use stripe.confirmSetup instead of stripe.confirmCardSetup?

#

because confirmSetup only does redirect and not modal

#

am I missing something?

obtuse onyx
fleet sail
#

is there a way to use stripe.confirmCardSetup with elements.create('payment')

obtuse onyx
#

The .confirmCardSetup function does not exist on the object returned when using payment

fleet sail
#

thats great. how do I get the card Element to pass to confirmCardSetup when using elements.create('payment') been trying this for sometime now

#

any chance you have the full js code to what you showed above?

obtuse onyx
#

Sure

fleet sail
obtuse onyx
#
const options = {
        clientSecret : document.getElementById('client-secret').value,
        appearance: {
            theme: 'night',
            labels: 'floating'
        },
    }
    
    const elements = stripe.elements(options);

    const paymentElement = elements.create('payment');
    paymentElement.mount('#payment-element')
    paymentElement.on('change', event => {console.log(event)})
    const form = document.getElementById('setup-form')
    form.addEventListener('submit', async (event) => {
        event.preventDefault();

        const { error }= await stripe.confirmSetup({
            elements,
            confirmParams: {
                return_url: window.location.href
            }
        })
        errMessageHandler(error)
    })
#

Okay hold on sec

#

You are confusing elements and methods.

fleet sail
#

in the above code you are passing the return_url. This above code navigates for me

#

doesn't open a modal

obtuse onyx
#
  • elements.create('payment') Creates a Payment Element, not a Card. The confirm method is confirmSetup
  • elements.create('card') Creates a Card Element, the confirm method is .confirmCardSetup
#

So you want another modal after the 3DS?

fleet sail
#

does the above code redirect to the bank page for 3DS or open a modal?

obtuse onyx
#

The above code returns the request back to my application. It does trigger a browser refresh

#

But I am not navigated away from my application

fleet sail
#

ya, that is my problem, is there a way to not refresh the browser and open a modal instead for 3DS?

#

ok, let me put it this way, if I use elements.create('payment') , can I use stripe.confirmCardSetup to confirm the setupIntent?

#

if yes, how would the above code change?

obtuse onyx
#

No you cannot

#

As I said earlier, confirmCardSetup is only available for Card Elements.

#

When you use elements.create('payment') you are instantiating a Payment Element

fleet sail
#

ok

#

ok, so with elements.create('payment') there will always be a page refresh

obtuse onyx
#

You can avoid it by passing in redirect: 'if_required'

#

The problem here is that you need to take into account that a user could potentially try to confirm the same setupIntent twice, which would cause an error

fleet sail
#

the main reason I am trying to prevent the page refresh is because of oAuth. Its a shopify app and the redirection is going to be a pain because the app loads on shopify's app bridge, so when I navigate, it will go to homepage of the app and not to the current page. And I am not a fan of the card layout. It's just a bit blah. I like the payment element and I cannot use it without redirection

obtuse onyx
#

I just revised my code like so:

const { error }= await stripe.confirmSetup({
            elements,
            confirmParams: {
                return_url: window.location.href
            },
            redirect: 'if_required'
        })

and I don't get a redirect even with 3DS

fleet sail
#

so I am just trying to address a pain point when it comes to UX within a shopify app.

#

so, what does if_required actually mean if it doesn't redirect?

#

just trying to understand if there is an edge case and a customer gets redirected.

obtuse onyx
#

Yeah, payment is definitely an improvement both stylistically and for more features.

#

The redirect is if the user needs to be taken to a new page. Some payment methods like Afterpay require this

fleet sail
#

well, I only want to show card with elements.create('payment') because wallets and afterpay don't support subscriptions

#

so I just want to stick to accepting card with elements.create('payment') and prevent a redirect

obtuse onyx
#

Then I think you should be able to avoid redirects

fleet sail
#

ok, is there a way to disable afterPay, klarna and stuff. I already have the wallets disabled

obtuse onyx
#

If they aren't enabled in your dashboard, they won't be an option.

fleet sail
#

so, I need to enable these services for it show on the payment form?

obtuse onyx
#

In test mode it will show more payment methods than you have activated but you will also see a Console warning stating which ones won't be active in live mode

fleet sail
#

ok, so I only have it setup to card

obtuse onyx
#

Then you shouldn't see those other methods as options

fleet sail
#

and with paymentMethod set to card + elements.create('payment') + confirmSetup with redirect set to if_required I don't have to worry about redirection, correct?

#

no edge cases right?

#

I am not going to have any of the other payment modes

#

only card

obtuse onyx
fleet sail
#

ok, I will make sure I will do that

#

thank you

obtuse onyx
#

Happy to help ๐Ÿ‘

fleet sail
#

do the elements have client side events? like ready loading loaded?

#

something like that to indicate if the elements are loaded on the page?

obtuse onyx
#

For instance, the paymentElement does not have a a click event

fleet sail
#

perfect

#

Thank you for clarifying on the usage of elements.create('payment') I really appreciate it.

#

owe you a beer or more

#

been struggling it for hours

obtuse onyx
#

It can be pretty easy to get confused. The names of many of the functions are only slightly different