Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DoeJohn's avatar

Initiating multiple (many) Stripe Checkout sessions at the same time?

Hi,

I am using Laravel Cashier / Stripe Checkout (subscriptions).

I have multiple plans and I want to have only one page (/subscribe) where all the plans will be listed and for each plan there will be a link (button) that will send user to Stripe Checkout page (to subscribe).

When user visits /subscribepage, I initiate Stripe Checkout sessions for each plan:

Route::get('/subscribe', function () {
    $checkout1 = Auth::user()->newSubscription('Supporter', 'price_1')->checkout([
        'success_url' => route('dashboard'),
        'cancel_url' => route('dashboard'),
        'client_reference_id' => auth()->id(),
    ]);

    $checkout2 = Auth::user()->newSubscription('Supporter', 'price_2')->checkout([
        'success_url' => route('dashboard'),
        'cancel_url' => route('dashboard'),
        'client_reference_id' => auth()->id(),
    ]);
	
	$checkout3 = Auth::user()->newSubscription('Supporter', 'price_3')->checkout([
        'success_url' => route('dashboard'),
        'cancel_url' => route('dashboard'),
        'client_reference_id' => auth()->id(),
    ]);
	
	$checkout4 = Auth::user()->newSubscription('Supporter', 'price_4')->checkout([
        'success_url' => route('dashboard'),
        'cancel_url' => route('dashboard'),
        'client_reference_id' => auth()->id(),
    ]);
	
	// ... AND MANY MORE ...
	
	
	$checkout10 = Auth::user()->newSubscription('Supporter', 'price_10')->checkout([
        'success_url' => route('dashboard'),
        'cancel_url' => route('dashboard'),
        'client_reference_id' => auth()->id(),
    ]);

    return view('subscribe', compact('checkout1', 'checkout2', 'checkout3', 'checkout4' ... '$checkout10'));
});

Is this wrong and bad? I ask because initiating all of these sessions seems to slow down the loading of the /subscribepage, and I guess it's because whenever we call checkout() method (that initiates session) - a new API call will be made + Cashier will hit the DB.

If initiating multiple sessions at the same time is wrong, then what would be the correct way? I know that I can add extra page (view) for each plan and then I would have only one session initiation per page, but I want to avoid that if possible (I just want one single page with plans listed, where each plan has own "Subscribe" button and when user clicks on that button - he goes directly to Stripe).

0 likes
0 replies

Please or to participate in this conversation.