#dongwan_best-practices
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/1266465738663923905
π Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi π
That depends on how much detail you want. The Payment Element will only collect as much billing address details as it deems necessary to maxmimize conversion of the payment (i.e. prevent declines).
If you want to always be sure to collect a finer level of detail you should use the Address Element
https://docs.stripe.com/elements/address-element
Thanks for the prompt response. The main reason we use the PaymentElement is to use Apple/Google pay. In this scenario, should i use Address Element when paymentElement's type is "card", right?
Also can you clarify how is gonna work when customers choose Apple/Google pay? since it's not collecting the billing address, the customers can only see the subtotal on the checkout page but they will eventually get charged the price with tax?
Hi there π jumping in as my teammate needs to step away soon. It largely depends on how much address information you're looking to collect.
For instance, when accepting card payments using the Payment Element it collects a value for Country by default, and will also collect a postal/zip code for US-based customers. If that's sufficient enough for your to get an accurate tax estimate, then you can likely work with the Payment Element alone. If you want to collect line1 details for a more precise tax calculation, that would require the use of the Address Element.
Can you tell me more about how you're structuring your flow? Is this a deferred intents flow that you're building?
I got this but my main question was about getting address data from PaymentElement.
Yes. the Payment Element will be mounted with amount and currency first and then once data is collected, we will create a subscription object.
Sorry if I'm missing the mark. Can you help me understand what it is you're looking for instead? Are you looking for guidance on how to actually get the address information provided to the Payment Element?
Yes you are correct
Gotcha, that's done by setting up a listener for change Events emitted by the Payment Element, and inspecting the values contained within those:
https://docs.stripe.com/js/element/events/on_change?type=paymentElement
yeah that's what i assumed. since our FE is react, i added console.log to onChange function but under value, it only shows "{ type: 'card' }"
Hm, yeah, I'm seeing the same. Taking a closer look.
Apologies for the confusion, the change Events there aren't actually expected to surface address details. I think, though am not certain offhand, that the payment_method hash we're seeing in the value hash is only populated if a customer uses a saved payment method.
Taking that into account, I do think using the Address Element, or custom address fields, would be the best approach here.
ok in that case, i assume i need to add the Address Element for "card" payment method.
I'm not sure I understand. You'd add it whenever you want to collect address details.
i meant assuming Google/Apple pay would not need to collect the address from the Address Element, only credit card payment method requires to collect billing address to calculate the tax.
Sorry, I'm still a bit confused. I was under the impression you wanted to update the amount being used by the Payment Element to include the calculated tax amount before submitting the Payment Element. So I thought you'd still want to collect address information regardless of the Payment Method type selected in the Payment Element, so you can update the amount being used there before submission.
You can always test this in testmode though and see if the address and tax information are being populated as you're expecting.
Ah sorry for confusion. I think you are right.
Is there a way to use stripe tax with the billing address thatβs already stored within apple pay/google pay in my scenario?
For Subscriptions, Stripe Tax pulls address information from the Customer record:
https://docs.stripe.com/tax/subscriptions#create-a-customer
if you're able to capture address details from Apple/Google Pay, and reuse the address from the Payment Method's details to update the Customer object, then I believe so. If I'm remembering correctly, the limiting factor there is that you can't force Apple/Google pay to collect address information when using the Payment Element.