#andressa-paymentintent-subscription
1 messages · Page 1 of 1 (latest)
andressa-paymentintent-subscription
@languid grotto the PaymentIntent has the invoice property on it, see https://stripe.com/docs/api/payment_intents/object#payment_intent_object-invoice
And an Invoice has a subscription property if it's associated with one.
There isn't a way to get both in an Event though. Usually that's the wrong way to approach this and you should be listening for the Subscription or Invoice Event(s) instead like invoice.payment_failed for example
I sent the wrong code, I edited it now, sorry!
my answer holds
@languid grotto let me know if you have a follow up question though or if anything is unclear
I think I'm using the right event, it would need the email or subscriptionId, I'm not sure which approach to go with
I don't think you are though. You didn't share much context but your code expects the Event to be about a PaymentIntent. If you use Subscriptions/Invoices you should not listen to payment_intent.payment_failed. You should listen to invoice.payment_failed for example which describes an Invoice and has a link to the Subscription.
The email is on none of those objects, it's on the Customer object which is separate. Our APIs has numerous API objects and they are connected to each other and you need to keep track of how they are linked and likely cache a lot of that information in your own database
but using the clock to test the webhook, it is triggering payment_intent.payment_failed
Sure, but it would also trigger invoice.payment_failed
ok so they would be the same thing? and if I use the invoice.payment_failed, will I be able to access the subscriptionId?
I mean they are different things, they describe completely different objects, but they are related yes
I'd recommend carefully looking at each Event first in the Dashboard, looking at the JSON payload, what they have, etc.
so if i add this webhook in the stripe developer settings it will already trigger?
Sorry for so many questions, I'm new to stripe 😅
All good for the questions we're happy to help. Just nudging you to try things on your own as it's a lot easier