Background:
I've implemented Stripe Checkout in a React app, and a webhook that successfully listens to events.
These are the events that the webhook hears after a successful Checkout:
checkout.session.completed
charge.succeeded
payment_method.attached
customer.created
customer.updated
invoice.created
invoice.finalized
customer.subscription.created
invoice.updated
customer.subscription.updated
invoice.paid
invoice.payment_succeeded
payment_intent.succeeded
payment_intent.created
What I'm trying to do:
I need to save a value to the database after a customer successfully creates a subscription. This value helps enable paid features, so I have to be sure the webhook catches all successful events.
Question:
Can I consistently rely on only one of these webhook events to indicate success? If not, which ones are the most important to listen for?
I think the most important events for my use case are probably checkout.session.completed
, charge.succeeded
, and payment_intent.succeeded
, but I'm not too sure on how these are different and if/when some of them may not appear.
The docs indicate:
There are three ways to accept payments on Stripe today:
- Stripe Checkout
- Charges API
- Payment Intents API
and:
checkout.session.completed
: Occurs when a Checkout Session has been successfully completed.charge.succeeded
: Occurs whenever a charge is successful.payment_intent.succeeded
: Occurs when a PaymentIntent has successfully completed payment.
So my guess is that each of checkout.session.completed
, charge.succeeded
, and payment_intent.succeeded
indicate success, and the reason all three are returned is that they correspond to the three ways to currently accept payments on Stripe.
If this is the case, can I reliably listen for only checkout.session.completed
to indicate success?
Other info:
stripe listen --forward-to localhost:4242/myWebHook
output after a successful Checkout session:
(actual evt_
values replaced for simplicity)
2022-05-08 --> checkout.session.completed [evt_123456]
2022-05-08 --> charge.succeeded [evt_123456]
2022-05-08 --> payment_method.attached [evt_123456]
2022-05-08 --> customer.created [evt_123456]
2022-05-08 --> customer.updated [evt_123456]
2022-05-08 --> invoice.created [evt_123456]
2022-05-08 --> invoice.finalized [evt_123456]
2022-05-08 --> customer.subscription.created [evt_123456]
2022-05-08 --> invoice.updated [evt_123456]
2022-05-08 --> customer.subscription.updated [evt_123456]
2022-05-08 --> invoice.paid [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 --> invoice.payment_succeeded [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 <-- [200] POST http://localhost:4242/myWebHook [evt_123456]
2022-05-08 --> payment_intent.succeeded [evt_123456]
2022-05-08 <-- [200] POST http://localhost:3000/myWebHook [evt_123456]
2022-05-08 --> payment_intent.created [evt_123456]
2022-05-08 <-- [200] POST http://localhost:3000/myWebHook [evt_123456]