I am using Stripe to create product subscriptions. The workflow is:
When I do this in Stripe, I am finding two subscriptions on the customer.
The subscription is created with parameters:
{customer: customer,
trial_period_days: 30,
proration_behavior: 'none',
items: [{price: ENV['STRIPE_SUBSCRIPTION_PRICE']}]}
When the customer wants to enter their card details, the checkout session is created with:
session = Stripe::Checkout::Session.create(
customer: customer,
payment_method_types: ['card'],
mode: 'subscription',
line_items: [
{price: ENV['STRIPE_SUBSCRIPTION_PRICE'], quantity: 1},
],
success_url: "#{domain}/subscription-success?session_id={CHECKOUT_SESSION_ID}",
cancel_url: "#{domain}/subscription-cancel",
)
In Stripe, you can see two subscriptions created for this customer (one with a trial and one without). An invoice is immediately raised for one of the subscriptions.
How can I create a Checkout Session that will keep the first subscription only and start billing at the end of the trial?
Many thanks
Nick
If you're updating an existing subscription via Stripe Checkout, you need to use mode: 'setup'
instead, and pass the subscription_id
inside the setup intent's metadata.
https://stripe.com/docs/payments/checkout/subscriptions/update-payment-details
Alternative, consider implementing the customer billing portal instead:
https://stripe.com/docs/billing/subscriptions/customer-portal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With