'Which Stripe webhooks confirm Subscription and Product payments?
The Stripe API is quite overwhelming. I found out, that there are some webhooks which are present because of backward compability (i.e.: Plan, Charge..)
My intention is quite "simple":
My app should allow users do something, when they successfully paid their subscriptions or products. Some of the things I sell are Subscriptions and some are "One Time"-payments.
I don't know which webhooks I should use to and not miss any payments.
There is:
- invoice.paid
- invoice.finalized
- payment_intent.succeeded
- order.payment_succeeded
- checkout.session.completed
- checkout.session.async_payment_succeeded
and of course some callbacks if payments are failed:
- invoice.payment_failed
- invoice.finalization_failed
- payment_intent.payment_failed
- checkout.session.async_payment_failed
- order.payment_failed
- ...
- ..
My current assumption is that
- invoice.paid
- invoice.payment_failed
could be "the right" hooks
My second assumption is
- payment_intent.payment_failed
- payment_intent.succeeded
Am I going into right direction?
EDIT:
I add the content of Webhooks:
Webhook | status | contains recurring products | product | contains one-time products | plan | customer | address |
---|---|---|---|---|---|---|---|
customer.subscription.created | incomplete | yes | id | yes | customer | — | |
customer.subscription.updated | active | yes | id | yes | customer | — | |
payment_intent.created | requires_payment_method | — | id | — | — | customer | — |
payment_intent.succeeded | succeeded | — | id | — | — | customer | billing_details.address |
invoice.finalized | open | yes (lines) | yes | yes | yes | customer | customer_address |
invoice.updated (contains "previous_attributes") | paid | yes (lines) | yes | yes | yes | customer | customer_address |
invoice.paid | paid | yes (lines) | yes | yes | yes | customer | customer_address |
invoice.payment_succeeded | paid | yes (lines) | yes | yes | yes | customer | customer_address |
checkout.session.completed | complete | — | — | — | — | customer | billing_details.address |
Solution 1:[1]
For the recurring payments, the short answer is your current assumptions are correct as per this doc you should be listening for invoice.paid
and invoice.payment_failed
for handling recurrent payments. You might also need to listen to customer.subscription.updated
for accounting for subscription changes and invoice.payment_action_required
for instances where something like 3DS (SCA) is needed and you might need to get your customer back to make a confirmation of the payment on-session.
When it comes to one-off payments, if you’re using Checkout than you should listen to checkout.session.completed
, on the other hand if you’re using the Payment Intent API, then you should listen to payment_intent.succeeded
, payment_intent.payment_failed
and payment_intent.requires_action
.
Keep in mind if you’re listening to both payment_intent.*
and invoice.*
events, the Payment Intent events might also fire for recurring payments. If the invoice
field is not null in the Payment Intent received in that event then ignore this event since it will be handled in the invoice.*
events instead.
You can find all event types and descriptions here.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Tarzan |