#dimonatg

1 messages · Page 1 of 1 (latest)

bright coralBOT
left mural
#

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?

teal axle
#

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.

left mural
#

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.

teal axle
#

so if I'm understanding you, would this flow match your thinking?

  1. (frontend) Contact backend with order details
  2. (backend) Create a Customer record + SetupIntent, return to SetupIntent client secret to frontend
  3. (frontend) Provide billing information & payment method, confirm SetupIntent via Stripe PaymentElement , redirect to next page in process ('Pay')
  4. (frontend) User confirms the basket looks OK, presses 'Pay'
  5. (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?

left mural
teal axle
#

Perfect. Thanks for your help!

left mural
#

Happy to help.