node.jsautomationstripe-paymentssubscriptionrecurring-billing

How to Automate Stripe Subscription Payments Without `invoice.payment_action_required` Event?


I am using Stripe for subscription billing in my Node.js application. I have two key features:

  1. Trial/No-Trial Periods: Users can subscribe with or without a trial period.
  2. Annual Recurring Subscriptions: Subscriptions renew annually.

However, I'm encountering an issue where, when the trial ends or during the subscription renewal, Stripe triggers the invoice.payment_action_required event. This event requires additional user action to complete the payment, but I want the payment to be processed automatically without user intervention—similar to how Netflix and other platforms handle renewals.

What I Have Tried:

Despite these settings, I'm still facing the invoice.payment_action_required event.

My Goal:

I want to ensure that the payment is automatically deducted without requiring any additional action from the user at the time of trial end or renewal, just like how subscription services like Netflix manage their recurring payments.

Code Example:

Here’s a simplified version of the relevant part of my code:

const createSubscriptionOnStripe = async (customerId, priceId, data) => {
    return stripe.subscriptions.create({
        customer: customerId,
        collection_method: 'charge_automatically',
        payment_behavior: 'default_incomplete',
        off_session: true,
        trial_end: data.trialEnd,
        items: [{ price: priceId }],
        payment_settings: {
            payment_method_options: {
                card: { request_three_d_secure: 'any' }
            },
            save_default_payment_method: 'on_subscription',
        },
        expand: ['latest_invoice.payment_intent'],
    });
}

Question:

How can I configure Stripe to automatically charge the customer's card at the end of the trial period or upon subscription renewal without triggering the invoice.payment_action_required event? What changes should I make to my current setup to ensure seamless automatic renewals?


Solution

  • You should omit the payment_settings[payment_method_options][card][request_three_d_secure] parameter from your API call. By setting that to any, you are force requesting 3DS for all recurring/invoice payments associated to the subscription, not just the initial payment.