#Akin
1 messages · Page 1 of 1 (latest)
Hi there! Sorry for the delay
Can you share more details about what's failing exactly? I'm not sure what you mean by "custom email within an event"
With webhooks, you should be listening for specific events and responding to Stripe to confirm the event was received. Any webhook handler code on your end would be totally custom.
So I am listening to charges.succeeded event and would like to send email with receipt attached to customer when this is fired
I wrote a function that does this(send email to customer) but noticed when i called this function i get a failed event log in stripe for this event
Is that clear or would like me to send more info or screenshot if it would make it clearer?
The function to send the email to the customer should be called after your endpoint returns a 200 response to Stripe
Can you share details about the failed event log you're receiving?
Yes will send the screenshot now
Here is where i am calling the function in my code
Here is the failed log in stripe for that event
hm, I don't think you want to use await here, as you want to send the 200 response to Stripe as soon as possible
also, for the default action, you can try logging something instead of responding to Stripe with a 400
You could also try calling onSendSubscriptionReceiptEmail outside of your webhook handler code
Ah okay, i will try removing the await and try to log something for the default action. Thanks
Also, invoice.paid event doesn’t not return receipt url in the response right?
that's right. invoice.paid returns an invoice object. you can have your handler code retrieve the invoice and expand charge.receipt_url
How do you expand charge.receipt_url from the invoice?
After you receive invoice.paid, you'll need to make a separate call to Stripe to retrieve the invoice: https://stripe.com/docs/api/invoices/retrieve?lang=node
Your request should include something like:
expand: [charge.receipt_url]
I recommend reading our docs on expansion here: https://stripe.com/docs/expand