#Abishek - payment element billing fields
1 messages ยท Page 1 of 1 (latest)
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
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
Unfortunately we do not have an option for this at the moment https://stripe.com/docs/js/elements_object/create_payment_element#payment_element_create-options-fields-billingDetails
We only have auto and never
so, how does auto work?
I believe there is a feature request for always. I do not know if there is on the roadmap
do they only show when it is necessary?
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
ok
So at the moment the recommendation would be to choose never and create your own form to take billing information
is there a way to pass the custom elements when calling confirmSetup?
Exactly. You would pass the values in to that call
alright cool. thank you
when using confirmSetup does it always navigate to the return_url?
You can set redirect to if_required so that it only redirects when need be https://stripe.com/docs/js/setup_intents/confirm_setup#confirm_setup_intent-options-redirect
but the redirect isn't required for confirmCardSetup right?
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?
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?
Hi ๐ @frozen geode had to step away. I'm getting caught up
there isn't a great way to update the appearance of the card element as well
As @frozen geode pointed out, the 3DS authentication process uses a modal window to avoid redirection.
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')
That is not correct. I was testing 3DS earlier today with elements.create('payment') and it definitely still used a modal window.
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?
is there a way to use stripe.confirmCardSetup with elements.create('payment')
The .confirmCardSetup function does not exist on the object returned when using payment
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?
Sure
https://stripe.com/docs/js/setup_intents/confirm_card_setup#stripe_confirm_card_setup-data-payment_method here the payment_method requires the card element and i am not sure how to get the card element when using elements.create('payment');
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.
in the above code you are passing the return_url. This above code navigates for me
doesn't open a modal
elements.create('payment')Creates a Payment Element, not a Card. The confirm method isconfirmSetupelements.create('card')Creates a Card Element, the confirm method is.confirmCardSetup
So you want another modal after the 3DS?
does the above code redirect to the bank page for 3DS or open a modal?
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
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?
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
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
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
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
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.
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
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
Then I think you should be able to avoid redirects
ok, is there a way to disable afterPay, klarna and stuff. I already have the wallets disabled
If they aren't enabled in your dashboard, they won't be an option.
so, I need to enable these services for it show on the payment form?
For each individual Setup Intent, you can specify which payment methods you accept on your server:
https://stripe.com/docs/api/setup_intents/create#create_setup_intent-payment_method_types
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
ok, so I only have it setup to card
Then you shouldn't see those other methods as options
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
I am fairly certain, but personally I would test with all the test cards to validate the expected behavior: https://stripe.com/docs/testing
Happy to help ๐
do the elements have client side events? like ready loading loaded?
something like that to indicate if the elements are loaded on the page?
Here are the Element events. It is worth noting not all events fire on all elements so make sure you check with element is selected: https://stripe.com/docs/js/element/events
For instance, the paymentElement does not have a a click event
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
It can be pretty easy to get confused. The names of many of the functions are only slightly different