Reputation: 21
I have setup the Stripe Events webhook to send all events. For a payment I post to checkout/sessions and get a session ID along the lines of cs_test_12345...
If this payment is successfully completed I get the following events: (this is the type at the end of the event)
payment_intent.succeeded
mandate.updated
charge.succeeded
checkout.session.completed
(sorry for the formatting, SO forced it on me)
That's all great. The checkout.session.completed has the same session id I got at the start so I can add the payment into the system etc.
Now, for a declined card (triggerd via the specific card number) I get only the following events:
payment_intent.payment_failed
charge.failed
Neither of these have any ids that I can link to the session id I got at the start. I can see the amount, email, name etc but I'm looking for something that says "this decline is for session id cs_test_12345...".
Is there a way I can use only the contents of a payment_intent or charge event to find the underlying session?
I called the PaymentIntents endpoint and got the Payment Intent structure but it doesn't contain anything I can see that connects it to a session.
Now, I could try calling the Sessions endpoints to get all the current sessions (or even call it and ask for my current session) to get the Payment Intent ID and then compare that to the recently received payment_intent.payment_failed event but that feels like it's a reverse search, I'm looking for the forward search...
I intend to reduce the incoming events to the fewest number required to identify a success or failure ideally without me having to call back into Stripe, immediately or on a schedule, to get additional data.
Upvotes: 0
Views: 86