User automatically getting signed out after calling a SOAP API in Laravel 8

Viewed 76

I'm working on a Laravel 8 project. Here I need to integrate a SOAP API. Calling of the url is working and callback url is also working. But problem is when I'm calling the API URL, user automatically getting signed out. Badly need to fix this issue. Here is my controller for calling the API. Thanks in advance.

public function dbblpay(Request $req){
    $errmsg = "";
    $userid = '*******';
    $pwd    = '**********';
    
    $dbblurl = "https://ecomtest.dutchbanglabank.com";
    
    try {   
            $txnrefnum = $req->payref;
            $clientIp = $_SERVER['REMOTE_ADDR'];
            $cardType = $req->optcard;
            $totalamount = $req->total; 
            
            $wsdlUrl = $dbblurl.'/ecomws/dbblecomtxn?wsdl';
            $options = array(
            'cache_wsdl' => 0,
            'trace' => 1,
            'stream_context' => stream_context_create(array(
                  'ssl' => array(
                        'verify_peer' => false,
                        'verify_peer_name' => false,
                        'allow_self_signed' => true
                  )
            )));
            $client = new SoapClient($wsdlUrl, $options);
            $cParameters = array(
            'userid' => $userid,
            'pwd' => $pwd,
            'amount' => $totalamount,
            'cardtype' => $cardType,
            'txnrefnum' => $txnrefnum,
            'clientip' => $clientIp
            );
    
            $result = $client->getransid($cParameters);
                
            foreach ($result as $value)
            $TRANSACTION_ID = "N/A"; 
            $part1 = "";
            $part2 = "";
            $errmsg = '';
            
            if (strpos($value,"TRANSACTION_ID") !== false) {
            
                $arr = explode(":",$value);
                $part1 = $arr[0];
                $part2 = $arr[1];
                if ($part1 == "TRANSACTION_ID") {
                    $TRANSACTION_ID = $part2;
                    $_SESSION['trans_id'] = $TRANSACTION_ID;
                    setcookie('trans_id',$TRANSACTION_ID,time()+300,"/");
                    $trans_id_en = urlencode($TRANSACTION_ID);
    
                    header("Location: ".$dbblurl."/ecomm2/ClientHandler?card_type=".$cardType."&trans_id=".$trans_id_en);
                    exit();
    
                } else {
                    $errmsg = $value;
                    return view('dbbl.dbblcheckout', compact('errmsg'));
                } 
           } else {
                $errmsg = $value;
                return view('dbbl.dbblcheckout', compact('errmsg'));
           }
    
    } catch(Exception $e) {
        $errmsg =  "System Problem";
    }
}
1 Answers

I figured out the problem for myself.

In the config/session.php file I changed the configuration from 'same_site' => "strict", to 'same_site' => "lax", And it worked for me.

Related