im trying to sell subscription via stripe , subscription have seats users can have a subscription with 4 seats without paying basically it would be a trial till next month but if user choose to have an extra seat he has to pay immediately for that extra seat
so basically i have a subscription with trial of 30 days which may include an extra payment on spot
im using checkout session to set up the subscription because i dont want to collect the user banking info
as for extra fee i found the add_invoice_items
item which i think will allow me to sell the subscription with trial and a extra payment
the problem is stripe wont accept this parameter when i try to create it with checkout session
all the documents about this item use the direct method of creating subscription with collecting user information and creating subscription via api instead of checkout
here is my code
$session = $client->checkout->sessions->create([
'success_url' => config('front.public_url').'/payment?stat=ok' ,
'cancel_url' => config('front.public_url').'/payment?stat=cancel',
'line_items' => [
[
'price' => $price->id ,
'quantity' => 1,
],
],
'mode' => 'subscription',
'subscription_data' => [
'trial_period_days' => 30 ,
'trial_settings' =>['end_behavior' => ['missing_payment_method' => 'pause']] ,
'add_invoice_items' => ['price' => $price->id , 'quantity' => 1]
],
]);
im getting this error :
"message": "Received unknown parameter: subscription_data[add_invoice_items]",
im not sure if that's even possible or maybe i misunderstood the docs and should create a separate checkout session for the extra fee
so i have to ask is it even possible to sell subscription with trial but add an extra fee on top of that to pay immediately with one checkout session ?
The Subscription's add_invoice_items
array is used to add one-time Prices to a Subscription. These can be used in this situation as they would be charged once and before the trial.
With Checkout, you can add both recurring Prices and one-time Prices in the line_items
array.
If I understand correctly, let's say a seat is $100, you would need a $100 one-time Price ($price_one
) and a $100 recurring Price ($price_sub
).
'line_items' => [
[
'price' => $price_sub->id ,
'quantity' => 5,
],
[
'price' => $price_one->id ,
'quantity' => 1,
]
]
$100 charged now, recurring $500 after the trial.