I am using Laravel 7 and using PayTabs payment gateway for payments. When the user is redirected back from the Paytabs, all the sessions and Auth are cleared.
Before redirecting to the Paytabs, im saving the session when the data is put in the session. as
Session::put('data', $data);
Session::save();
And the redirection to Paytabs is as follows:
if ($response->response_code == "4012") { //Page created
return redirect()->to($response->payment_url);
} else {
abort(404);
}
I have also excluded the return url from CSRF Token check as follow:
VerifyCsrfToke.php
protected $except = [
'/paytab_return'
];
Also I have checked that the Paytabs redirects to the correct URL with https and www.
Favor needed to tackle this issue. Thanks
This worked for Laravel 6.19.1:
$sessionKey = config('session.cookie') . '=' . session()->getId();
$successUrl = route('wirecardSuccess') . '?' . $sessionKey;
The URL I'd got is eg
http://beatbox.vnr:8082/vnr/payment/wirecard/success?self_service_local_vnr_session=qNSQ7SessionIdtEA3Z72ReuvgsFt
as the url, where self_service_local_vnr_session is my session cookie name and qNSQ7SessionIdtEA3Z72ReuvgsFt the ID of the current session.
<?php
declare(strict_types=1);
namespace App\Http\Middleware;
use Illuminate\Contracts\Session\Session;
use Illuminate\Http\Request;
/**
* Class StartSession
* @package App\Http\Middleware
*/
class StartSession extends \Illuminate\Session\Middleware\StartSession
{
/**
* Get the session implementation from the manager.
*
* @param Request $request
* @return Session
*/
public function getSession(Request $request): Session
{
return tap($this->manager->driver(), static function ($session) use ($request) {
$sessionCookieName = config('session.cookie');
if ($request->has($sessionCookieName)) {
$sessionId = $request->input($sessionCookieName);
} else {
$sessionId = $request->cookies->get($session->getName());
}
$session->setId($sessionId);
});
}
}
I hope it'll help someone, who lands on this page :)
edit this fields in config/session.php
'path' => '/;samesite=none',
'secure' => true,
'same_site' => 'none',
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.