SCA may be required at payment information submit

Created on 2 February 2023, over 1 year ago
Updated 25 June 2023, about 1 year ago

Since mid January '23 we see errors in the Stripe API logs we haven't seen before:

During the creation of Stripe customer object (with attached payment method IDs), or during the attaching of payment method IDs to existing Stripe customer objects, we receive 402 Errors saying "authentication_required". Those errors indicate, that the payment method (mastercard in this case) may have to be authenticated via 3DS *before* referencing it to a Stripe customer object.

This happens in the payment_information checkout pane submit handler when calling the payment gateway createPayment method:
Stripe::doCreatePaymentMethod() -> $stripe_payment_method->attach() or Customer::create().

Reference: https://git.drupalcode.org/project/commerce_stripe/-/blob/8.x-1.0-rc6/sr...

But Drupal Commerce Stripe never does a 3DS authentification in the payment_information checkout pane, nor does it check the attributes of the payment method for 3DS requirements or such.
All these 3DS checks happens later in the stripe_review pane, which is supposed to be in a later step of the checkout flow after the payment_information pane was submitted. Also these checks are performed on the client side with Stripe's own javascript.

We have no idea why we haven't seen this behaviour before mid January '23. Also we got no further clue from Stripe's support on whether this is something new (and undocumented) on their side or if we got something messed up on our side.

Funny enough we can't reproduce these Stripe API error responses with any of the test card numbers Stripes offers in the testing sandbox. It only appears for live payments, and only for mastercard.

For better understanding I add some screenshots from the Stripe dashboard.

I'm looking forward reading from you whether or not you experience same errors on your sites.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇹Austria guedressel

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @guedressel
  • 🇮🇱Israel jsacksick

    Do you have the "Stripe review" checkout pane added to your checkout flow? 3DS integration is done through this pane.

    Also, did you try updating to the latest version to see if the issue persists?

  • 🇦🇹Austria guedressel

    Yes - the stripe review checkout pane is active, one step after the "Payment Information" checkout pane (where the API error response happens).

    And no - we are currently on 1.0-rc7. Issue Allow for payments without stripe review pane Fixed may influence the behavior in question, though I doubt it.
    We well upgrade our site and report back if anything changed.

  • 🇮🇱Israel jsacksick

    Yes - the stripe review checkout pane is active, one step after the "Payment Information" checkout pane (where the API error response happens).

    Is it placed on the "review" step though?

  • 🇦🇹Austria guedressel

    The Steps are configured like this:

    Payment

    • Contact information
    • Payment information

    Review

    • Review
    • Stripe review
    • Agree to legal terms
  • 🇮🇱Israel jsacksick

    Unfortunately, I'm not currently working on projects that use Stripe myself... So perhaps worth sending an email to either @John Pitcairn or @jonathanshaw that are currently the 2 most active contributors to this project.

  • 🇳🇿New Zealand John Pitcairn

    Just to avoid confusion those are 402 errors from Stripe API, not 403.

    Not being able to reproduce it with a test Mastercard requiring 3DS auth makes followup tricky.

  • 🇳🇿New Zealand John Pitcairn

    Are you running any custom php or js code to create customers or attach payment methods? Any issue patches?

    Is it only some mastercards? Are they all issued in a specific country, or by a specific bank, or something else in common?

    Are you able to push back further on Stripe support about a test mastercard number that is equivalent to one of your failng mastercards, asking for auth at payment method setup? Emphasise that it isn't possible to debug the problem at our end without a test card, or more specific documentation.

    Can Stripe support confirm whether requiring authentication at payment method setup is an expected behavior, and if so can they point to the specific documentation for that?

    Anyone else seeing this behavior? Please do post here.

  • 🇦🇹Austria guedressel

    We updated our site to commerce_stripe 1.0-rc10, however some Mastercards still get rejected - hence no difference to 1.0-rc7.
    On this site only one patch gets applied 📌 Allow translating Strip error messages. Needs review No further code modifications are in place for commerce_stripe.

    So far we only tracked down only Mastercards (DebitCards and Credit cards aswell). We know of some cards issued from different Austrian banks, but we can't get any details on the cards from Stripe - neither for the logs in the dashboard nor from the Stripe support.

  • 🇦🇹Austria guedressel

    Another chat with the Stripe support gave following suggestions:

    Asking for test card-numbers wasn't very helpful, I just got reminded to have a look at https://support.stripe.com/questions/test-card-requiring-3d-secure-authe...

  • 🇳🇿New Zealand John Pitcairn

    Uh-oh. Thanks for persisting with Stripe support @guedressel.

    I think we are indeed using the attach endpoint directly when we call $stripe_payment_method->attach() in Stripe::doCreatePaymentMethod().

    Changing the issue title to broaden the scope, there might be considerable work involved. Something like:

    • Create a Stripe Customer and SetupIntent from card form javascript submit.
    • This may trigger a 3DS auth request at billing info submit, and we need to be able to handle that.
    • Use the payment method returned for Stripe::createPaymentMethod()
    • Stripe::doCreatePaymentMethod() may need changes.
    • Stripe::createPaymentIntent() may need changes.
    • Probably other issues as a result.

    SetupIntents API docs: https://stripe.com/docs/api/setup_intents.

    Getting this right should help provide a buffer against the pace of change, and might resolve a few other people's hard to reproduce bugs, especially with commerce_recurring in the mix.

  • 🇦🇹Austria guedressel

    Stripe API docs state:

    By using SetupIntents, you ensure that your customers experience the minimum set of required friction, even as regulations change over time.

    So I vote for using SetupIntents over PaymentIntents with "setup_future_usage".

    I also discovered, that the PaymentMethodAddForm already creates SetupIntents for authenticated users:
    https://git.drupalcode.org/project/commerce_stripe/-/blob/8.x-1.0/src/Pl...

    Though I don't understand yet why this happens that way. This code was created in context of #3039032: 3D Secure 2

  • 🇦🇹Austria guedressel

    Today I undertook a mind-boggling dive into the sources of this module to find a path to implement SetupIntents and overcome the shortcomings with strong 3DS checks.
    I learned a lot about the structure of commerce, commerce payment, commerce checkout, the Stripe API and - last but not least - commerce stripe 🤓

    After some back and forth I might have found a quite straight forward modification to use SetupIntents. It was especially easy since SetupIntents were already in place to add payment methods outside a checkout flow.
    I'll create an issue-fork to show you what I came up with. It's supposed to have a foundation to iterate on - and to build UnitTests.

  • Open in Jenkins → Open on Drupal.org →
    Core: 9.5.x + Environment: PHP 7.4 & MySQL 5.7
    last update about 1 year ago
    20 pass, 2 fail
  • @guedressel opened merge request.
Production build 0.69.0 2024