#nobody_unexpected
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1371705357805551666
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- nobody_unexpected, 5 days ago, 30 messages
- nobody_api, 6 days ago, 22 messages
Hi sam, continuing this thread from before
The issue was that i would like to conditionally render an address element if the country selected is india, but the onchange event doesn't tell me any information
Hi! As per my last reply, it looks like the billing details in the value parameters will only be populated for saved payment method. So if it's a new customer you cannot get the billing details.
The only other alternatives we can think of are:
- Call stripe.createPaymentMethod (https://docs.stripe.com/js/payment_methods/create_payment_method_elements) within the on("change') listener so that you can get the billing_details.
- Or inspect the payment method since you're using confirmation token and then based on the country show either your own UI to collect a postal code or use Address Element
Yikess, this is not ideal
Because they require a backend call to determine whether a frontend element should be rendered. I wouldn't even be able to detect when this should happen during the frontend flow.
The first option is a frontend method.
I see
But it would have be called on every onchange
When someone is typing out their credit card it would be called 30+ times
Unless i am missing something
You can look at the complete parameter (https://docs.stripe.com/js/element/events/on_change?type=paymentElement#element_on_change-handler-complete). Only create the payment method when complete is true.
Unfortunately it appears you can only create the payment method after the customer presses submit
In that case, for your specific scenario, option 2 is the only way.
Confimation token is also created after the customer submits payment. The address element is supposed to be filled out before submission. I can't have a failed payment submission be a prerequisite for a successful one.
The only way left is to either use Address element or provide your own UI just for the postal code from the beginning.
Unfortunately this is an untenable situation as a developer. I would disable indian cards entirely but that is not an option either. I have no choice but to leave indian cards broken in production. I'm confident this situation is an oversight based on the docs. If there is a place to submit a bug report i would do so.
This is not a bug. We specifically do not collect the postal code for India. I will provide a feedback internally however, currently the only way around this are the options we dicussed.
Address element: it shouldn't have to render address element for 50+ countries just because only india does not display zip field
Custom zip field: this is complicated because many countries don't have zip. Since there's no way to detect which country is currently selected: if i have my own zip field, it will always be rendered, even though many times it should not be asked in the first place.
So i can't see how this isn't a bug, honestly. I appreciate the internal feedback.
So i can't see how this isn't a bug, honestly.
Payment Element only collects postal code when necessary for address verification checks, i.e. US, UK and Canada: https://docs.stripe.com/disputes/prevention/verification#avs-check
You require the postal code for tax calculation purposes which is not supported by Payment Element
Custom zip field: this is complicated because many countries don't have zip. Since there's no way to detect which country is currently selected: if i have my own zip field, it will always be rendered, even though many times it should not be asked in the first place.
The only alternative is to inspect the payment method details from the confirmation token.
I appreciate the internal feedback.
I will file a feedback. ๐