#jmadlena_api

1 messages ยท Page 1 of 1 (latest)

hot pathBOT
#

๐Ÿ‘‹ 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.

hot crane
#

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.

safe jackal
#

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.

hot crane
#

Ok gotcha

#

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

hot pathBOT
safe jackal
#

Ahh, I see that now. Thanks so much, I think that will do the job. Thanks for your help!

hot crane
#

NP! If you have more questions don't hesitate to ask!

safe jackal
#

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.

wicked shadow
#

๐Ÿ‘‹ 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

safe jackal
#

Yeah, definitely could be tracking the manual API attempts on my end to resolve part of this.

#

Thanks again for your assistance!