I'm trying to migrate my code to be SCA-compliant but the problem is there doesn't seem to be a clear guide on how to do this on Stripe.
I already tried various things but I can't seem to get the regulatory test cards to work (the one in here: https://stripe.com/docs/testing#regulatory-cards). The ordinary card (4242 4242) works though.
The first thing I tried is the confirmCardSetup: https://stripe.com/docs/billing/subscriptions/overview#authentication-failures
What I did was to listen for the paymentintent.succeeded via webhooks once the user has confirmed their card. I got the 3DS confirmation to show up in here, but once it gets to the webhook, I couldn't use the payment method to create a new user subscription. I'm getting an error that there is no payment method attached to the user. Though when I checked the Stripe dashboard, the payment method I was using was attached in there. I even tried doing it manually, but it really doesn't recognize it. It seems that you can't use the payment method created via confirmCardSetup to create a subscription.
The second approach I tried was this guide: https://codenebula.io/node.js/stripe/sca/2020/03/03/how-to-use-stripes-new-payment-intents-api-with-node-js-to-create-subscriptions-with-built-in-sca/
It's implemented using the createPaymentMethod(). The created payment method is then submitted to the server to create the customer and the subscription. This fails with the following error:
the payment attempt failed because additional action is required before it can be completed
The last thing I tried was to follow this guide: https://stripe.com/docs/payments/save-and-reuse
It says in the docs that it can be used for "recurring payments" so I assumed this was for subscriptions. The integration works but it's not really for subscriptions. It's using a setupIntent call on the server and a confirmCardSetup on the client side. This only works if you use it on a paymentIntent::create call.
What I'm trying to do is create a customer using the payment method generated via the confirmCardSetup. And then create a subscription for that user. I'm getting the same issue as approach #1 above. It's complaining that the user doesn't have a payment method attached. So I just assumed the payment method generated through this call is only meant for creating payment intents.
The code snippet in here: https://stripe.com/docs/billing/subscriptions/overview#authentication-failures
is giving a hint on how this can be implemented, but where do I even get this subscription variable when I can't even create a subscription:
const {pending_setup_intent} = subscription;
if (pending_setup_intent) {
const {client_secret, status} = subscription.pending_setup_intent;
if (status === "requires_action") {
stripe.confirmCardSetup(client_secret).then(function(result) {
if (result.error) {
// Display error.message in your UI.
} else {
// The setup has succeeded. Display a success message.
}
});
}
}
Please help. Even just the general steps on how this can be accomplished would do. Thanks!