#mike-p_code
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/1349910606198865933
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi, the currency is decided when you are intializing the Payment Elements, either by PaymentIntent on backend or on initialization on frontend. When the PaymentElements is showed, the currency is already fixed
I am setting the "currency" when the payment intent is created to "CAD" on the backend. (I just checked and verified this is the value being set as expected.)
I posted the front-end initialization of the Stripe Element in the initial question sent to StripeBot.
I'm invoking the V1 PaymentIntents Create API on the backend.
Sorry let me clarify, is your question about
entering the Canada test CC number, only US Zip Code is acceptable, not a Canadian postal code
?
The goal is to only allow Canadian payments (with Canadian postal code) or only allow US payments (with US zip code)
Setting the currency to 'CAD' when creating the PaymentIntent does not look like it is causing the Payment Element to only support 'CAD'. With the country: 'never' set on the Element, the country drop down is not visible, but the zip code entry must always be a US Zip Code (even with the PaymentIntent currency as CAD)
So I think the country : never only changes its display or not. IF you drop that never option, does the country display US by default?
It is defaulting to US
Okie, when you create the PaymentElements, can you specify the defaultValues 's country here? https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options-defaultValues-billingDetails-address-country
Something like this
defaultValues: {
billingDetails: {
address: {
country: "CA",
}
}
},
fields: {
billingDetails: {
address: {
country: "never",
}
}
}
trying ...
It does not look to be defaulting to Canada. I am not using country: "never" so i can see the coutry drop down.
(i also put a debugger statement to ensure the code is loading as expected)
... i missed address element. Let me try again.
... with the address element, that now works as i would expect.
I think that got what I am looking for. Thank you! โค๏ธ
It does look like the 4242 4242 4242 4242 test card does accept a Canadian Postal Code (i used V6A 2W5). My expectation was that this would fail, but it did not.
Yes that's a general purpose test card ๐ Happy to hear it works!