#jmadlena_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/1243297769368584222
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Can you share what you mean by doing this manually?
And what are you trying to do with this information, ultimately? Perhaps there is another way to achieve what you want.
By manually I mean either hitting the /invoices/id/pay endpoint, or clicking "Retry Charge" button on a failed invoice on the Dashboard.
Ultimately I want to send a failed payment email to customers only when an invoice payment fails as part of the automatic collection cycle (when Stripe retries a few times). I don't want them to receive an email every time payment is attempted and fails, as I might retry the charge on the dashboard or via the API another time. I don't want to overload them with failed payment emails.
I'm listening for invoice.payment_failed events at the moment to kick off emails from my service.
Ok gotcha
So there is nothing on the invoice/charge itself about this, but there is an indication on the Event you receive to your webhook endpoint(s):
https://docs.stripe.com/api/events/object#event_object-request-id
if the event was emitted as part of handling an api request, you'll find the request id like req_123 in the event's request.id and it will be null where it was related to an automatic process
So, you can use that to determine whether a given invoice.payment_failed event was from automatic payment attempts managed by Stripe BIlling for you vs your own dashboard action or API request
You can test that out using the Dashboard and Test Clocks to see if that gives you what you need here
Ahh, I see that now. Thanks so much, I think that will do the job. Thanks for your help!
NP! If you have more questions don't hesitate to ask!
If possible to pass on some feedback, I think it would be nice for this info to be made available inside the Payment Intent or Charge object somewhere. Mainly because the part of my code that handles the logic around this doesn't have access to the Event object itself. I can certainly make it work, but it would be great to see billing_reason = manual, or something like that in the object itself.
๐ Stepping in for my teammate.
Noted on the feedback. I think there's a way to handle this on your end where you can keep track of calls to invoices/id/pay and ignore any invoice.payment_failed events for that invoice. This won't help for invoice payments you initiate via the Dashboard though