Session automatically gets destroyed on payment gateway call back in Laravel(在Laravel中的支付网关回叫时,会话自动销毁)
本文介绍了在Laravel中的支付网关回叫时,会话自动销毁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试将CCvenue.com支付网关集成到我的Laravel 7项目中。我面临的唯一问题是在回拨URL中,在从支付网关获得帖子数据后,活动会话自动销毁。我还向中间件添加了CSRF异常。
PayController(生成付款请求和URL)
<?php
namespace AppHttpControllersuser;
use AppHttpControllersController;
use IlluminateHttpRequest;
class PayController extends Controller
{
public function __construct()
{
$this->middleware('auth:web');
}
public function index()
{
return view('user.addmoney');
}
public function addmoney(Request $request)
{
$validatedData = $request->validate([
'Amount' => 'required|numeric',
]);
$Amount = $validatedData['Amount'];
$working_key = '5dfsdfsdf3323423'; //Shared by CCAVENUES
$access_code = 'asdasdas234234'; //Shared by CCAVENUES
echo $merchant_data = 'merchant_id=555&order_id=123654789&amount=' . $Amount . '¤cy=AED&redirect_url=http://localhost:8000/addmoneyresponse&cancel_url=http://localhost:8000/addmoneyresponse&language=EN&billing_name=Charli&billing_address=Room no 1101, near Railway station Ambad&billing_city=Indore&billing_country=India&billing_tel=9595226054&billing_email=atul.kadam@avenues.info&promo_code=&customer_identifier=&integration_type=iframe_normal&';
$encrypted_data = $this->encrypt($merchant_data, $working_key); // Method for encrypting the data.
echo "<br>";
$production_url = 'https://secure.ccavenue.ae/transaction/transaction.do?command=initiateTransaction&encRequest=' . $encrypted_data . '&access_code=' . $access_code;
return redirect()->away($production_url);
//return view('user.addmoneyrequest', compact('production_url'));
}
function encrypt($plainText, $key)
{
$key = $this->hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$openMode = openssl_encrypt($plainText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
$encryptedText = bin2hex($openMode);
return $encryptedText;
}
function decrypt($encryptedText, $key)
{
$key = $this->hextobin(md5($key));
$initVector = pack("C*", 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f);
$encryptedText = $this->hextobin($encryptedText);
$decryptedText = openssl_decrypt($encryptedText, 'AES-128-CBC', $key, OPENSSL_RAW_DATA, $initVector);
return $decryptedText;
}
//*********** Padding Function *********************
function pkcs5_pad($plainText, $blockSize)
{
$pad = $blockSize - (strlen($plainText) % $blockSize);
return $plainText . str_repeat(chr($pad), $pad);
}
//********** Hexadecimal to Binary function for php 4.0 version ********
function hextobin($hexString)
{
$length = strlen($hexString);
$binString = "";
$count = 0;
while ($count < $length) {
$subString = substr($hexString, $count, 2);
$packedString = pack("H*", $subString);
if ($count == 0) {
$binString = $packedString;
} else {
$binString .= $packedString;
}
$count += 2;
}
return $binString;
}
}
PayResponseController(进程回调)
<?php
namespace AppHttpControllersuser;
use AppHttpControllersController;
use IlluminateHttpRequest;
class PayResponseController extends Controller
{
public function addmoneyresponse(Request $request)
{
return $request->all();
//return view('user.dashboard');
}
}
api
我遇到了这个问题,我添加了一个推荐答案回调路由并在其中返回一个视图:
在routes
文件夹中,api.php
文件:
Route::post('/callback','callbackController@callback');
内部controller
:
public function callback(Request $request) {
// some code here
return view('callback');
}
并将此设置为回调:
http://yourdomain.com/api/callback
这篇关于在Laravel中的支付网关回叫时,会话自动销毁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
沃梦达教程
本文标题为:在Laravel中的支付网关回叫时,会话自动销毁
基础教程推荐
猜你喜欢
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 超薄框架REST服务两次获得输出 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- Libpuzzle 索引数百万张图片? 2022-01-01