#simonecervini

1 messages ยท Page 1 of 1 (latest)

sharp lightBOT
sterile ember
#

๐Ÿ‘‹ happy to help

#

why are you using the payment_intent.succeeded event? You should probably listen to invoice.paid event

icy ginkgo
#

I am using the payment_intent.succeeded event simply because I am extending an already written system based on nonrecurring payments that uses payment_intent.succeeded as the only event and I would like to keep the logic in common. Using the invoice.paid event could I easily get the metadata of the subscription object?

sterile ember
#

if you already have been listening to payment_intent.* events for one-off payments you should do the following :
1- in your payment_intent.* events you should look at the invoice https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice field in the PaymentIntent object if it's not null you should disregard the message
2- listen to invoice.paid for recurring payments (Subscriptions)
3- if you want the metadata of the Subscription, you can retrieve the Subscription https://stripe.com/docs/api/subscriptions/retrieve by using the subscription https://stripe.com/docs/api/invoices/object#invoice_object-subscription field on the Invoice object of that event.

icy ginkgo
#

Thank you very much, it's all clear!

sterile ember
#

let me know if you need any more help