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

damian0021's avatar

Data transfer between functions and redirection

Hi, I have a problem with transferring data between functions and the final redirection to a specific address. Briefly, how my application works:

  1. Filling in the form by the user,
  2. Adding data to DB,
  3. Transfer of data from point 2.) to the Payment function
  4. Payment function, receives data, saves them in the database, but does not redirect to the generated Stripe URL.

My web.php

Route::get('dodaj/premium',[CompanyController::class, 'addFormPremium']);
Route::post('dodaj/premium',[CompanyController::class, 'storePremium']);
public function storePremium(Request $request)
{
			//Everything is fine with this function, the data is saved and the ID is passed on with:
			$this->paymentCheckout($company->id);
}
public function paymentCheckout($id_company)
{
			try {
            Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
    
        $product = Stripe\Product::retrieve(
            'XXX',
            []
        );

        $price = Stripe\Price::retrieve(
            $product->default_price,
            []
        );

        $portal = Stripe\Checkout\Session::create([
            'success_url' => 'success',
            'cancel_url' => 'cancel',
            'line_items' => [
                [
                'price' => $price->id,
                'quantity' => 1
                ],
            ],
            'mode' => 'payment',
        ]);

        $id_session = $portal->id;
        $payment_url = $portal->url;

         return redirect()->to($payment_url);
       
}

The data is saved, but not transferred to the URL. After executing dd (); the address is 100% generated by the code because it is saved in the database

I guess the problem is that I don't have any reference to the 'paymentCheckout' function in my web.php - could that be true?

0 likes
3 replies
vincent15000's avatar

@damian0021 So the only way I know is to put your datas in the session and then retrieve them from the session.

Please or to participate in this conversation.