Reputation: 1283
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:
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:
Thanks a lot!
Upvotes: 0
Views: 118
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