I am using Stripe for subscription billing in my Node.js application. I have two key features:
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.
collection_method: 'charge_automatically'
.payment_behavior: 'default_incomplete'
and default_incomplete: 'error_if_incomplete'
, off_session: true
, and save_default_payment_method: 'on_subscription'
.payment_method_options
, I used { card: { request_three_d_secure: 'any' } }
.Despite these settings, I'm still facing the invoice.payment_action_required
event.
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.
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'],
});
}
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?
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.