Moo33
Moo33

Reputation: 1283

Stripe Checkout one time payment webhooks

I’m doing an app with Stripe payments for the first time. After researching, I’ll be using Stripe Checkout for one time payments (no subscriptions), Firebase Cloud Functions and Firebase Realtime Database. Hoping to keep costs down to 0 or minimum. These Stripe payments are for topping up the user’s wallet balance on the app.

As I’m initially a frontend developer, I’m afraid of missing something or misunderstanding so I was wondering if someone could let me know if I’m on the right track.

On my app, I will have a payment history page that logs every transaction with any status. From what I researched:

  1. Pending
  2. Success
  3. Failed
  4. Cancelled
  5. Expired
  6. Refunded

Webhooks to implement on Firebase Cloud:

checkout.sessions.completed - This is when the user finishes submitting their payment details. When webhook is triggered, to create a transaction in the realtime database with status “pending”.

payment_intent.succeeded - Transaction status in database to be changed to “success”. Adjust wallet balance.

payment_intent.payment_failed - Transaction status in database to be changed to “failed”

payment_intent.canceled - Transaction status in database to be changed to “cancelled”

checkout.session.expired - Transaction status in database to be changed to “expired”

refunded webhook - Transaction status in database to be changed to “refunded”. Adjust wallet balance.

The questions I have are:

  1. If the user has a pending transaction, is it better to prevent them from doing another transaction until that transaction clears?
  2. What's the difference between "cancelled" and "expired"? I read that if the payment intent expires after 7 days, the status will be "cancelled" instead of "expired".
  3. Is this sufficient enough to handle Stripe Checkout payments? Are there any other webhooks or scenarios I’m missing?

Thanks a lot!

Upvotes: 0

Views: 118

Answers (1)

yuting
yuting

Reputation: 1694

I'd recommend checking this guide about fulfilling the order on a Checkout Session: https://docs.stripe.com/checkout/fulfillment

Your system should listen to checkout.session.* events for the payment outcome under payment_status property.

Checkout Session allows multiple payment attempts until the payment is succeeded. payment_intent.payment_failed event will be fired for every failed payment attempt. Listening checkout.session.* event should be sufficient to determine whether a Checkout Session has succeeded or expired (payment can't be made anymore). Listening to payment_intent.* shouldn't be necessary.

For refund related information, refund events listed here can be listened: https://docs.stripe.com/refunds#refund-events

Upvotes: 0

Related Questions