Reputation: 982
I would like to create trial period to be used with stripe checkout session:
session = stripe.checkout.Session.create(
customer=customer.stripe_id,
payment_method_types=['card'],
line_items=[{
'price': "price_1HjynjHdAhQwSUAK",
'quantity': 1,
'tax_rates': ["txr_1Hkntg4yXtzmX", ],
},
mode='payment',
allow_promotion_codes=True,
success_url=request.build_absolute_uri(reverse('thanks')) + '?session_id=CHECKOUT_SESSION_ID}',
cancel_url=request.build_absolute_uri(reverse('index_payment')),
)
in the tripe.Subscription.create looks like we just need to add trial_end=1605387163, but it doesnt work in checkout session. I cant seem to find the way to do it even though I am pretty sure it is doable as displayed in this demo:
I appreciate if someone can help.
Upvotes: 27
Views: 10165
Reputation: 1239
Brendan's answer pointed me in the right direction, for PHP the syntax to add the trial_end would be for example:
$session = \Stripe\Checkout\Session::create([
.......
Your Other parameters
.......
'subscription_data' => ['trial_end' => 1624110173],
]);
Where 1624110173 is unix timestamp for the end of the free period. See this Stripe document for general explanation of checkout process and code:
Upvotes: 5
Reputation: 1306
You've got the right idea with trial_end
, it just needs to be a child parameter under subscription_data
.
// other parameters
subscription_data: {
trial_end=1605387163
}
Upvotes: 47