Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Gabotronix's avatar

Stripe, webhooks and SCA European law checkout flow

Hi everybody, I'm working on a website with Stripe payments, it's europe based so I'll have to deal with SCA 3D Secure auth, stripe docs recommend me to deal with payment fulfillment asynchronously instead of waiting for confirmCardPayment promise to resolve, to accomplish this you have to use webhooks.

From the docs:

stripe.confirmCardPayment(clientSecret, {
  payment_method: {
    card: card,
    billing_details: {
      name: 'Jenny Rosen'
    }
  },
  setup_future_usage: 'off_session'
}).then(function(result) {
  if (result.error) {
    // Show error to your customer
    console.log(result.error.message);
  } else {
    if (result.paymentIntent.status === 'succeeded') {
      // Show a success message to your customer
      // There's a risk of the customer closing the window before callback execution
      // Set up a webhook or plugin to listen for the payment_intent.succeeded event
      // to save the card to a Customer

      // The PaymentMethod ID can be found on result.paymentIntent.payment_method
    }
  }
});

Notice the comment that says:

// There's a risk of the customer closing the window before callback execution
// Set up a webhook or plugin to listen for the payment_intent.succeeded event

Because of that warning I'm confused about how to deal with confirmCardPayment promise.

Should I just take the user to another page after I call confirmCardPayment from client and show the order in that new page with status: PENDING or PROCCESING.

Should I do this a few seconds after calling confirmCardPayment with a timer or check there is no error in callback, inside the else brackets of the promise callback and use location.href there to move user to see the order?

After that I would deal with order fulfillment in backend with webhooks (listen to payment_intent.succeded event, remove from stock, send order email and do remaining database operations)

If I do this would the SCA modal still show up? Stripe says Stripe.js deals with SCA and showing modal but if I redirect user to pending orde page with no stripe.js how would SCA modal action complete?

This is pretty confusing.

0 likes
3 replies
AlexElementarteilchen's avatar

You could take a look at Octobat.com - we use it for our payment and it handles all the VAT stuff and it works well (takes away a lot of complexity).

Or take another look at the process as described on the stripe website (I had to read it several times to finally get it :))

https://stripe.com/docs/payments/checkout/client-subscription

It says:

  1. When your customer completes a payment, Stripe sends the checkout.session.completed event.
  2. This event includes the Checkout Session object, which contains details about your customer and their subscription. 1- With a webhook endpoint, your customer is redirected to the success_url when you acknowledged you received the event.

In scenarios where your endpoint is down or the event isn’t acknowledged properly, your customer is redirected to the success_url 10 seconds after a successful payment.

Please or to participate in this conversation.