#matt_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/1408503096329372010
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Thanks for waiting! Looking into this now
By default, Stripe require address to be collected for automatic tax on the subscription: https://docs.stripe.com/tax/subscriptions
During subscription, the first invoice will be finalised immediately. When the invoice is finalised, the amount can't be updated. This also means that we can't compute the tax and change the amount after the payment method once the first invoice is finalised.
Another alternative will be using deferred intent flow, which you collect the payment method first, the create subscription later: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription
Learn how to integrate Stripe Tax with Stripe Billing to calculate taxes on subscriptions, estimate totals, collect customer information, manage location validation, and handle automatic tax calculations.
Ty please give me a few min to try/check some things
I am doing the deferred intent flow. The difference in my code vs the docs is that in the docs they're separately adding full address to the customer.
But as the docs say: By default, the Payment Element only collects the necessary billing address details.
Which it does, the card portion of the Payment Element collects Country/Zip which is enough for taxes, but with my current code the location for the tax is being checked immediately, even though I'm creating a default_incomplete deferred intent and Stripe will have access to the location data when the frontend runs the confirmPayment referenced here: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=web&type=subscription#confirm-the-subscription
I feel like at some point I had it not validating the tax until the confirmPayment part of the Payment element ran, because otherwise the code doesn't work
Maybe I was re-using an existing Stripe::Customer that had already had address info when I was testing and it was working because of that
But it would be nice to get confirmation because it feels odd that I would have to separately collect address information when the payment element does have that information.
And I've spent a lot of time trying, but there seems to be no way to get the country/zip from the frontend javascript Payment Element which means I would have to either collect that info twice, or create my own country+zip inputs that map cleanly to Stripe which is a big undertaking given every country has their own postal code format
By default, the Payment Element only collects the necessary billing address details.
That's right! Even with the normal flow without deferred intent, billing address will only be collected when necessary.
To always collect the address, I'd recommend disabling address collection in the Payment Element, and use Address Element (or your own form) to collect that
- Disable address collection in Payment Element - set
fields.billingDetails: 'never': https://docs.stripe.com/js/elements_object/create_payment_element#payment_element_create-options-fields-billingDetails
It always collects on card though, so the 'necessary' part doesn't matter really, it always collects the address
Initially I did use an Address Element, but it's super heavy to collect full name and full down to the house address when stripe only needs the postal code that the PaymentElement already always collects
I can even get the address from the Payment method created after the subscription is charged with
pi = Stripe::PaymentIntent.retrieve(stripe_payment_intent_id)
pm = Stripe::PaymentMethod.retrieve(pi.payment_method)
pm.billing_details.address
I guess I feel like one of the following should be possible, but can you confirm neither of these are?
Get the address from the payment element before the Payment intent is confirmed
or defer Subscription/Payment Intent to not care about the address for tax until it's confirmed like how you can on a customer with tax: validate_location: deferred
Hi taking over here. Give me a minute to catch up on context
Yeah so you need to set the location on the customer first before creating the sub
Recommend referring to the flow chart at the top of: https://docs.stripe.com/tax/subscriptions
And there's no way to get that information from the Payment Element that does have that information?
Recommend using the address element, but you could in theory use something like the element change event to set a client side variable for billing address/zip code when it's entered in the payment element: https://docs.stripe.com/js/element/events/on_change?type=paymentElement
And then pass that client side variable's value to your server when creating the customer + subscription
Oh my god, that's exactly what I need. That was just added a month ago so my code didn't have access to that when I was trying to figure this out before. Thank you