'Stripe Subscription active even with pending/failed card authentication

I am working on a Metered Billing Subscription with Stripe, I am doing the integration with Elements.

My task here is to handle the scenarios where cards needs a 3D Secure verification.

As said on the doc ( https://stripe.com/docs/billing/subscriptions/metered#manage-payment-authentication ) on the step "9 Manage payment authentication", after creating the subscription with a card requiring a 3D Secure verification the subscription object should looks like this:

{
  "id": "sub_1ELI8bClCIKljWvsvK36TXlC",
  "object": "subscription",
  "status": "incomplete",
  ...
  "pending_setup_intent": {
    "status": "requires_action",
    "client_secret": "pi_91_secret_W9",
    "next_action": {
      "type": "use_stripe_sdk",
      ...
    },
    ...
  }
}

But in my case the subscription looks like this:

{
  "id": "sub_1ELI8bClCIKljWvsvK36TXlC",
  "object": "subscription",
  "status": "active",
  ...
  "pending_setup_intent": {
    "status": "requires_action",
    "client_secret": "pi_91_secret_W9",
    "next_action": {
      "type": "use_stripe_sdk",
      ...
    },
    ...
  }
}

The only difference is that in my case the status of the subscription is already "active", even with cards waiting for 3D Secure confirmation. With a fresh new customers with no existing payment method attached.

Stripe even sends a invoice.paid webhooks without the 3D Secure confirmation done by the user. Much more stranger, if I fail the verification, the subscription remains "active" ...

I don't know how to deal with that. I was thinking of verifying something like sub.status === 'active' && sub.pending_setup_intent === null sort of thing, instead of simply verifying sub.status === 'active' ... but I am really confused as I don't get the expected behavior from the documentation ..

Thank you !



Solution 1:[1]

It's hard to say for sure given the information you provided, but I think this may be a result of using an old API version. In Stripe API version 2019-03-14 the default payment_behavior of Subscriptions changed, which might be causing what you're seeing. The documentation assumes you're using the current API version.

If you explicitly set payment_behavior to default_incomplete does that change what you're seeing?

Alternatively, this could be a result of your first Subscription Invoice not requiring any payment. Metered Subscriptions in Stripe are post-paid, meaning your customers pay for their metered usage at the end of a Subscription period, not at the beginning. Thus, if there's no payment due immediately, the Subscription will immediately be active and the first $0 will be automatically marked as paid.

In any case, you should be using the pending_setup_intent the Subscription creates for you to set up your Customer's Payment Method for future use to optimize future recurring payments.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Justin Michael