#greggles_best-practices
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1260307482945782084
đ Have more to share? Add details, code, screenshots, videos, etc. below.
Additional requirements:
I need the customer address to determine tax liability first and I want to use the address element. This affects the bottom line price. We add tax manually to the invoice and use Anrok as a 3rd party tax provider.
Just to clarify, are you trying to create one-off invoices and then pay them using PaymentElement?
Hi, thank you. At it's basic level, I'm trying to sell a stripe one-off payment product and have the customer use the address element and the payment element.
I've tried several integrations, the latest was the deferred payment method of loading the payment element, but it was limited to cards, cashApp and US bank account which skunks my international clients.
Sorry for the delay here
So, is it preferable to
- create the paymentintent or setupintent prior to rendering the payment and address elements
- render the elements
- confirm the payment
Then what?
After confirming the payment
create the customer,
create the invoice,
attach products to invoice
Apply payment?
I don't think we have a guide that covers this usecase fully. But ideally you could do something like,
- Create a customer
- Use AddressElement to collect customer location data: https://docs.stripe.com/elements/address-element/collect-addresses
- Create a draft invoice for the customer: https://docs.stripe.com/api/invoices/create
- Call your third-party tax provider and get tax details & add it as invoice item to the invoice: https://docs.stripe.com/api/invoiceitems/create
- Finalize the invoice: https://docs.stripe.com/api/invoices/finalize
Finalized invoice generates a PaymentIntent.. Use that to render elements, collect card details and confirm payment: https://docs.stripe.com/api/invoices/object#invoice_object-payment_intent
Thank you for the suggestion. So essentially this would be a 2 page/step process because I'd need to instantiate stripe elements separately, once for the address element, then again for the payment element using the client_secret?
This is how I backed myself into a corner before. I instantiated stripe elements on page load and rendered the address element and payment element from that initial instantiation.
Yeah since third-party tax API + invoices are involved, it'd be better to do it as a step process