Which webhooks to look after in Stripe Checkout?

Viewed 1378

I'm implementing subscription with Stripe Checkout, but I have some questions that I couldn't get definitive answers for even from their support.

I have following scenario:

  1. User clicks on a Subscribe button
  2. User gets redirected to Stripe Checkout page (along with session token)
  3. User successfully pays (and from now on is a Customer)
    • and here I get 14 webhook calls (each one is different event type):
      • checkout.session.completed
      • payment_method.attached
      • invoice.created
      • customer.updated
      • customer.subscription.created
      • customer.created (even though I used the same email - test mode, but still...)
      • invoice.finalized
      • invoice.updated
      • invoice.payment_succeeded
      • customer.subscription.updated
      • charge.succeeded
      • payment_intent.succeeded
      • payment_intent.created
      • invoice.updated
      • edit: I get all of them at once because I use Stripe CLI's listen feature and it probably shows all calls which normally wouldn't happen because they have to be defined in dashboard event by event. For instance if I create invoice in the dashboard and pay it then if no webhook is defined explicitly then my server won't know about anything

Until here it all works good. My concern is that:

  • if a Customer will be charged next month which webhook should I listen to? I need to differentiate between first-time Customer (because I create new account for that user) and existing Customer that I just need to note in database that this user is still active (or listen for event of subscription cancellation? subscription_schedule.canceled maybe?). One idea is to just listen to successful payment and upon that check if customer exists in database - if he does just update, if not then create account.
  • when I do another subscription payment using the very same email I get exactly the same webhooks (including customer.created which I think shouldn't be there) or am I missing something?
  • is there any possibility to double-charge a Customer by accident like I read in other Stripe implementations (see: idempotency)?
  • what are other things to take into account while implementing Stripe Checkout? I feel like their instructions are not reassuring that I've done everything that is considered good practice.

Flow that I want to achieve:

  1. User successful payment (as above in points from 1 - 3). Already done!
  2. Register new customer in database (Firebase in this case) and log him in automatically so after payment he has instant access.
  3. As long as customer's card is charged he has access. While he cancels or card has no insufficient funds I need to have my server notified about this to downgrade access.
0 Answers
Related