#dimonatg
1 messages · Page 1 of 1 (latest)
Hi, let me help you with this.
Basically you want to collect a Payment Method once and then be able to use it for one-off or recurring charges in the future?
for additional context, I'm using Node.js (NestJS) on my backend, and then React/Next.js on my frontend (so I'm using the @stripe/react-stripe-js and @stripe/stripe-js packages on my frontend, using the PaymentElement currently for PaymentIntents!)
It's a standard checkout flow. The customer adds products to the basket and then checks out. The products can either be a one-off purchase or a subscription (the basket can be a combination of both). So I'm collecting a payment method to use immediately - but I may also need to use it to set up a new subscription.
I would say it's best to use SetupIntent first, to collect the Payment Method, and then you can use it to charge for the one-off items in the cart, as well as start new Subscriptions.
If you split it in 2 stages it's easier to manage: first collect the PM, then charge it.
so if I'm understanding you, would this flow match your thinking?
- (frontend) Contact backend with order details
- (backend) Create a Customer record + SetupIntent, return to SetupIntent client secret to frontend
- (frontend) Provide billing information & payment method, confirm SetupIntent via Stripe
PaymentElement, redirect to next page in process ('Pay') - (frontend) User confirms the basket looks OK, presses 'Pay'
- (backend) Assess the order details and determine what needs to happen (i.e. create subscription where necessary, charge the payment method)
Assuming it does, for point 5 - do I still use PaymentIntents to charge the payment method, or is there something else I should be using?
Looks good.
Correct, you use PaymentIntent: https://stripe.com/docs/payments/save-and-reuse?platform=web&ui=elements#charge-saved-payment-method
Perfect. Thanks for your help!
Happy to help.