#quest1515
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- quest1515, 1 hour ago, 6 messages
hi @spare glade ! just to follow up on the last thread, are you a developer writing the code here for these 'payment links' and creating Invoices?
ah you're using PaymentLinks
then i don't really understand the issue. Do you have an example I can look at like a failed request ID req_xxx or a Customer ID cus_xxx with an issue?
yes , we are using the stripe payment links. We have webhooks that trigger when the payment is sucessful. Yes I do, one second
Customer: cus_LWjQttlXKxc8Fe , payment : pi_3OdsMOKWqxTFrzeA0ucrZ8aT.
You will see the payment and pening invoice item were created at the same time of Jan 29th at 10:47 am but no invoice was created
when I test in the sandbox I expect to see a payment and invoice record created when a payment link is used.
hmm so let me explain why I'm confused
ah you mean the Hosted Invoice Page not PaymentLinks
so the issue here is what I was alluding to in the last thread
there's a race condition where if you create an InvoiceItem manually and then create an Invoice quickly after, we haven't saved the item yet, so the Invoice request fails and says there's no item
it's a common issue
you fix it by using the newer approach where you can create the Invoice first and then add the items to it
So to fix this, do we need to regenerate all the payment links we have made in the past?
no, not at all
you change your code that deals with creating the Invoice for a customer to match https://stripe.com/docs/invoicing/integration ; if you use an older API version than https://stripe.com/docs/upgrades#2022-08-01 then you need to pass exclude https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior to opt into the flow where you can create an Invoice without first creating items
alternative the fix can be to catch this "no items to invoice" error and retry the Invoice create request a few second later and retry a few times until it works, as I said it's a bit of a race condition where the item is not fully saved by the time the "create Invoice" request comes in
I think the disconnect is my misunderstanding on how payment links are made in the system. How are they made?
what you call a 'payment link' is the Hosted Invoice Page, which is linked from https://stripe.com/docs/api/invoices/object#invoice_object-hosted_invoice_url on an Invoice object. I have to assume that's what you mean and what your code on that website is linking to.
for instance here is an example of one the client has on their website - https://iheed.vercel.app/payment/deposit-paediatrics
so it's created when an Invoice object is finalised, so you need to create an Invoice first, and what you're describing is that sometimes the Invoice creation fails, due to the race condition I'm talking about
ok I think I need to speak to the customer on my side to see how they are making these links and if it is via code we need to remake them using the new method you mentioned
well yes someone wrote some Node code that calls our API from your Stripe account and integrates with the Invoices API and the developer of that code can make some changes to handle this error/change the approach. Sorry, I thought you were that developer?
Its ok I am not. I was told they dont have any custom work on stripe. I am just the one who made the webhooks so I can push the information to the 3rd party software which I am the developer for.
Thanks for the help
yeah there is definitely more to your integration than just using no-code solutions, you use backend Invoicing features to create these hosted payment links, so it's more like a hybrid approach
Thanks Karl , I have a lot to look into it seems