#matt_code

1 messages ¡ Page 1 of 1 (latest)

foggy spruceBOT
#

👋 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.

idle creek
#

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.

Build an integration where you can render the Payment Element prior to creating a PaymentIntent or SetupIntent.

quasi lagoon
#

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

Build an integration where you can render the Payment Element prior to creating a PaymentIntent or SetupIntent.

#

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

idle creek
#

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

foggy spruceBOT
quasi lagoon
#

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

unkempt forge
#

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

quasi lagoon
#

And there's no way to get that information from the Payment Element that does have that information?

unkempt forge
#

And then pass that client side variable's value to your server when creating the customer + subscription

quasi lagoon
#

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