3
votes

I've making a SaaS that allows customers to subscribe to a plan, and use coupons at the checkout stage. The coupons give the customers X% off for X months, and by default, everyone gets a 7 day trial when they subscribe.

What is confusing me is the documentation. In one section it says that you should create SetupIntents to take a payment and elsewhere it says to use tokens.

I'm in the middle of coding the payment flow, but I just wanted to check to see if my logic and understanding is correct. Could anyone validate the below?

  1. Customer enters card number and coupon
  2. Call Stripe, get token for card
  3. Send token and coupon to server
  4. Create Stripe customer with token
  5. Create Subscription with discount and pass customer ID

What has now happened is an authorisation attempt was made. If SCA is required, then the subscription status is incomplete and the latest invoice payment intent status requires action.

At this point, I can redirect my user to the SCA Flow using handleCardPayment() to prompt 3DS, and once complete the subscription status is then active.

If the invoice payment fails for any reason, then the subscription state is incomplete and the payment intent requires has a payment action required status. At this point, I should present my customer with the React Elements form again, and call the stripe.invoices.pay endpoint with the new card token

Going forwards, all subscription charges should not need further SCA approval, however if the customer changes plan or the bank requests it, then I can point my user back through the SCA Flow process

A diagram of the flow is here: Green is UI, Orange is Server, Blue is Stripe

enter image description here

Is there anything I have missed or misunderstood here? I've been reading about creating SetupIntents and PaymentIntents, but I'm not sure I need this?

2
That diagram looks great to me! That is SCA-ready as-is. The only point I'd make is that in the 'next monthly payment'->'invoice generated'->'SCA needed' flow, you don't have to have a page that does handleCardPayment yourself, Stripe can be configured to send an email to the customer automatically stripe.com/docs/billing/migration/… But the diagram there is correct for the initial paymentkarllekko
Ah yes, I should have added that. For me, id like to notify the user in app to inform them additional info/new payment is needed but yes, I did see that on the docs. Thanks!K20GH

2 Answers

2
votes

If you are creating subscriptions using the Stripe Billing product they handle creating the PaymentIntent(if you are taking a payment immediately) or a SetupIntent (if you are setting up a trial or metered billing). All that you really have to do different is handleCardPayment (for payments) or handleCardSetup (for setting up trials and metered billing). This section in the docs is pretty good.

If you are not using billing they have a video on their Stripe Developers Youtube channel which may help clear up any confusion.

Hope this helps :)

1
votes

Welcome fellow sufferer, cards and tokens are implemented in Stripe Charges API which is not SCA compilant. If you want use Stripe for payments inside the EU you should use payment intents.

Card tokens are also allowed for creating payment intents.

But if you want reduce the number of necessary authentications you should use setup intents (with usage = "off-session") for creating payment methods and not card tokens.

I have a lot of old customers who have still registered with the Charges API. I use the following strategy:

  • New customers always register via Setup Intents and Payment Methods.
  • Old customers use the Charges API until their tokens become invalid. Then they must also use setup intents and payment methods.

Of course, the customers do not notice much of it.

In summary, I would always use payment methods and setup intents for new customers and card updates. Only with the setup intents can you ensure that your customers have to authenticate themselves as rarely as possible.

EDIT: The crucial point is off-session payments that occur with subscriptions. The Stripe procedure is described here: https://stripe.com/docs/payments/cards/saving-cards#saving-card-without-payment