Reputation: 217
Is it possible to remove the payment method field or make it not "required" with Stripe Checkout API ?
Here is my backend code:
const freeTrial = {
trial_from_plan: realSubscription.id === 4 ? true : false
}
if(customerStripeId != undefined || customerStripeId != null){
const session = await stripe.checkout.sessions.create({
mode: 'subscription',
payment_method_types: ['card'],
line_items: [
{
price: formData.monthlySetting === true ? realSubscription.monthly_price_id : realSubscription.annual_price_id,
quantity: 1
}
],
customer: customerStripeId,
success_url: `${BASE_URL}/success?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: BASE_URL,
subscription_data: freeTrial
})
return {customerHasId: 'true', sessionData: session }
}else{
return {customerHasId: 'false'}
}
In Stripe UI I have set up a 30 day trial for my first plan. It's working but when I checkout, Stripe still ask for a payment methode even though.
It's like this checkout demo from Stripe:
link to demo
Upvotes: 1
Views: 2957
Reputation: 1274
This is now possible! Add the payment_method_collection
flag with a value of if_required
when creating your checkout session, like so:
const session = await stripe.checkout.sessions.create({
...
payment_method_collection: 'if_required'
});
Now, if the "due today" price becomes $0, the checkout form will disappear and your user will be able to skip adding a payment method for the time being.
Stripe Documentation: https://stripe.com/docs/payments/checkout/free-trials
Upvotes: 2
Reputation: 25602
This is not possible today. Stripe Checkout requires valid payment method details to maximize the chance that you get the first invoice paid at the end of the trial. There is no way to skip payment method details collection on Checkout.
If you don't want a payment method upfront then you would create the Subscription with a trial on your end without using Stripe Checkout.
Upvotes: 1