Ok, I found it. You can't
return $checkout;
you have to:
return $checkout->checkout([
'success_url' => route('dashboard.subscribed', ['user' => $request->user()]),
'cancel_url' => route('dashboard'),
]);
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hello, I'm trying to create a Stripe checkout session for a Subscription with optional multiple products. Some of these products require the user to specify the quantity, but I can't figure out how to tell Stripe to increase the quantity dinamically.
This is what I'm trying to do:
//The $order I'm passing contains a collection with the selected extras
public function createStripeCheckoutSession(Order $order)
{
//I used this to get the "stripe_price" of the main subscription plan
$subscription_plan = $order->plans->where('plan_type', 2)->first();
$checkout = $request->user()->company()->newSubscription('default', $subscription_plan->stripe_price);
//Here I'm getting the remaining selected products without the $subscrition_plan
$extras = $order->plans->filter(function($value) {
return $value->id > 2;
});
//Here I tried to loop trough every "extra" and calling the quantity() method of Cashier
foreach($extras as $extra){
$checkout->quantity($extra->pivot->quantity, $extra->stripe_price);
}
$checkout->skipTrial()
->allowPromotionCodes()
->checkout(
[
'success_url' => route('dashboard.subscribed', ['user' => $request->user()]),
'cancel_url' => route('dashboard')
]);
return $checkout;
}
But instead of returning Stripe's checkout it gives me a
"Symfony\Component\HttpFoundation\Response::setContent(): Argument #1 ($content) must be of type ?string, Laravel\Cashier\SubscriptionBuilder given, called in /var/www/html/vendor/laravel/framework/src/Illuminate/Http/Response.php on line 73"
If I use this instead it returns the stripe checkout, but I don't know how to specify the quantity
return $checkout = $request->user()->company()
->newSubscription('default', $subscription_plan->stripe_price)
->skipTrial()
->allowPromotionCodes()
->checkout([
'success_url' => route('dashboard.subscribed', ['user' => $request->user()]),
'cancel_url' => route('dashboard'),
]);
Thank you very much for your help.
Please or to participate in this conversation.