#horlaarsco_api
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/1237161624129900585
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there!
Taking a look at the requests you shared
Ah, you'll also want to set auto_advance: true, either when you create the Invoice if you expect to add all invoice items within an hour, or once you've added all necessary items: https://docs.stripe.com/api/invoices/create#create_invoice-auto_advance
I just tried that by setting the auto_advance to true and finalizing the invoice but it seems the status is still open. Here is a screenshot
I see this from the dashboard, but i want to charge the user immediately
If you're working with the same customer, this is expected. This customer has a few saved PaymentMethods but none of these are configured as their default PM for Invoices: https://docs.stripe.com/api/customers/object#customer_object-invoice_settings-default_payment_method
I passed the card still didn't work, here is what i did that worked which is confirming the paymentIntent but feels weird that i have to do all these calls or is that how it works?
So with auto_advance: true you can either finalize the invoice manually or wait ~1 hour after creation for Stripe to automatically finalize the invoice
If you complete the first three steps above (create the invoice, add invoice items, finalize), we should automatically attempt payment, no need to confirm the PI manually
Could you try the first three steps above with that same customer (cus_Q2vLHFTx0j0po6) and share the Invoice ID you receive?
Sure, but in my scenario i need to confirm the payment instantly because they would e purchasing a service that needs to be processed instantly. But yeah let me try those 3 steps and share you the invoiceId without me confirming the paymentIntent
Here is the invoice ID: in_1PDa3VASvslpl77d67pAigr4
Hi there ๐ taking over, as my colleague needs to step away
Give me a few minutes to get caught up.
Okay
Sorry, it's really hard to read through all of these events from the myriad of updates on this Customer. You can either pay the Invoice by making an API call (https://docs.stripe.com/api/invoices/pay) or, (in order for us to be most helpful) can you create a new Customer and go through the steps to set them up with an auto-advancing Invoice?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That's one way to do it, yes
Okay thanks.
If the payment was unsuccessful due to insufficient funds or any other error i would get a response.
Or even if it requires confirmation, it would return it?
I got this when i tried a card that requires permission.
This payment requires additional user action before it can be completed successfully. Payment can be completed using the PaymentIntent associated with the invoice. For more details see: https://stripe.com/docs/billing/subscriptions/overview#requires-action
I reverted back to this
You have to account for the need for 3DS authentication too. I would really recommend just following this guide: https://docs.stripe.com/invoicing/integration?method=elements
It talks about all of this. It even has a section for post-payment events like invoice.payment_failed
I am not using stripe elements in this flow, i am only using the default card the user added initially.
How did they add the card?
Like, you said you want immediate payment for a new Invoice, which this guide explains how to do, so I'm wondering how you're intending to actually accept live payment methods
There is a different flow where they add the card and i store the paymentMethodid to my db to be used later, this is what i am using to pay for the invoice automatically, the user do not have to input the card details here. Just pay for the item
Got it. In that case, the steps will be similar but you would need to make sure your Payment Methods are being setup for future payments: https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements
Then always set the Payment Method as default on the Customer object once the Customer is created (as roadrunner_stripe already specified), then you would need to make sure your system is setup to handle post-payment events, as described here: https://docs.stripe.com/invoicing/integration?method=elements#handle-payment-events
Okay but just to iterate here is the flow i have followed because all is happening on the backend i am not using elements to fetch the card but i am confirming a payment intent if it requires additional confirmation. Here is the backend code. And on the frontend when it requires action i do this.
This works now, but just wanted to confirm if this flow is alright
That seems right. The Customer will have to remain in the payment flow to authenticate 3DS, but I as long as that's the case, this looks fine.
Thank you very much!