#avneetsingh_11747

1 messages · Page 1 of 1 (latest)

vestal fjordBOT
dreamy turret
#

Hi there, I'd strongly recommend you using wehooks

shy widget
#

How can I do it through webhooks? Please share some details or sample code.

dreamy turret
shy widget
#

I've gone through your link and this is the where we can handle the post payment events. But if look closely, stripe sends us events asynchronously and request object is something that contains stripe and payment related details. I would like to update the details in the DB or send email to customer so I need to include custom details in my request body. How can I implement that?

#

This is the request payload object. Earlier, I was able to handle events was by making a promise call to backend server by passing in request body with custom data like order no, invoice, username, email etc. How can I do this through webhooks if the events are sent to us by stripe asynchronously?

dreamy turret
#

If you listen to payment_inent.succeeded event, and you'll get a PaymentIntent object from the event. Do you have enough data from the PaymentIntent to handle the payment?

shy widget
#

When we say 'handle the payment', what specifically does it mean? Let say I want to send an email to the customer, then I would need customer details. So again my question is pretty straightforward, how can I pass in the custom details preferrably through request object in this webhook method so that based on the outcome of payment_intent.succeeded event, I should be able to send an email or update DB?

dreamy turret
#

https://stripe.com/docs/api/payment_intents/object#payment_intent_object The PaymentIntent object should contains all the info you need to send a custom email. Check the API reference and see if you have everything there.

Once you have the info, update your DB, and call you own email service to send out the email.

shy widget
#

Thanks Jack. Let me elaborate a bit. We have our own custom Coupon Management. We used to update coupon details in our DB based on successful payments. We also calculated tax which depends on the province as tax differs from province to province. Earlier, we got all these details through the request object sent from the client side. However, the issue now is that the PaymentIntent object doesn't contain these details as the events are sent by stripe through webhooks.

dreamy turret
shy widget
#

That means I can set the metadata while creating the payment intents?

dreamy turret
#

Yes you are right