我使用这个laravel包"https://github.com/kanazaca/easypay“来使用Easypay创建一个MB引用。
我有这样的方法来创建引用:
public function generateReference()
{
$amount = Session::get('total');
$payment_info = [
't_value' => $amount,
'o_obs' => '',
't_key' => 1
];
$easypay = new EasyPay($payment_info);
$reference = $easypay->createReference();
Session::put('entity', $reference['ep_entity']);
Session::put('reference', $reference['ep_reference']);
Session::put('value', $reference['ep_value']);
}这个代码很好,我得到了一些参考代码,可以用MB或信用卡支付。
然后,当付款时,easypay将调用"Notification“。我们应该在easypay的后台在"URL配置“下配置。因为当easypay服务收到付款时,他们将调用我们提供的URL。因此,我在easypay的后台办公室中定义了一个url,并在项目中创建了一条路径:
Route::get('/easypay/notification-callback', [
'uses' => 'PaymentController@receiveNotifications',
'as' =>'mb.notifications'
]);在appears中有一个模拟支付的按钮,单击该按钮后什么都不会发生,如果我手动访问"http://....ngrok.io/easypay/notification-callback“,它将出现一个空数组:
[]但是在文档(https://docs.easypay.pt/workflow/payment-notification)中,Easypay调用这个端点时,它附带了一些参数:"ep_cin“、"ep_user”和"ep_doc“,这些参数在这个过程中是必需的。因此,不应该出现空数组。
你知道有什么问题吗?我是一个使用API的初学者,所以我不理解这个问题是什么。
PaymentController receiveNotifications()方法:
public function receiveNotifications(Request $request)
{
dd($request->all());
//$easypay = new EasyPay($payment_info);
//$xml = $easypay->processPaymentInfo();
//return \Response::make($xml, '200')->header('Content-Type', 'text/xml'); //must return in text/xml for easypay
}带有日志的receiveNotifications()方法:
public function receiveNotifications(Request $request)
{
//dd($request->all());
Log::info('Showing info: ' .var_export($request->all(),true));
$payment_info = [
'ep_cin' => $request->ep_cin,
'ep_user' => $request->ep_user,
'ep_doc' => $request->ep_doc
];
Log::info('Showing info: ' .var_export($payment_info,true));
//dd($payment_info);
$easypay = new EasyPay($payment_info);
$xml = $easypay->processPaymentInfo();
return \Response::make($xml, '200')->header('Content-Type', 'text/xml'); //must return in text/xml for easypay
}发布于 2018-06-12 11:13:31
会话保存在访问您发起付款的网站的用户的会话文件中。
如果您正在进行任何操作,receiveNotifications将从属于支付网关服务器的会话文件中调用数据。数据是不匹配的,因为这两个人不知道对方。
此外,在请求处理中可能没有将会话数据写入文件的Session::save()。
将引用存储在数据库中。创建一个用于存储该数据的模型,这样您就可以查询该模型以获得正确的引用ID来验证/执行操作。
当请求从支付网关返回时,使用变量ep_cin、ep_user和ep_doc从模型中获取数据。
当您手动请求该数据时,您将使用GET请求来请求该数据,GET请求不会同时发送上述数据。
付款提供者提出的请求将得到DD的结果,但是没有任何记录,所以什么都不会发生。
记录你的数据用于远程api触发的请求,以查看发生了什么。
https://stackoverflow.com/questions/50042652
复制相似问题