我在laravel中使用flywire实现了一个支付网关。 我有一种方法可以毫无问题地将数据更新为crm,当调用另一个方法以重定向到外部url(是向导)时,我需要此数据。麻烦是在进行重定向后,会话的值是丢失。 重定向到外部网址后如何保存这些值?
use Session;
public function update(Request $request)
{
//code..
Session::put('value1',$request->val1);
Session::put('value2',$request->val2);
$url = 'https://www.urldemo.payment.com/payment/';
$data=[
'value1'= $request->val1,
'value2' = $request->val2,
];
$params = json_encode($data);
$curl = curl_init();
curl_setopt($curl,CURLOPT_URL,$url);
curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_POST,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,$params);
try{
$response = curl_exec($curl);
$info = curl_getinfo($curl);
$err = curl_error($curl);
curl_close($curl);
return response()->json(['success'=>'the update was completed success','url'=> $url],200);
}catch(Exception $e){
return response()->json(['errors'=> $e->getMessage()],422);
}
}
/*This function retrieve the response data from the payment update*/
public function returnData(Request $request){
$obj = json_decode($request->getContent());
if(Session::exists('value1')){
$p1 = $obj->id;
}elseif(Session::exists('value2')){
$p2 = $obj->id;
}else{
$p1 = '';
$p2 = '';
}
$data2 = [
'value1' => $p1,
'value2' => $p2,
];
$values = json_encode($data2);
dd($values);
/*Here print the $p1 and $p2 empty thats after redirect to a external url the point is that here the session is lost*/
}
此刻我的问题是在Laravel 5.5中重定向后如何举行会议?