【发布时间】:2018-10-07 03:12:13
【问题描述】:
我正在使用这个 laravel 包“https://github.com/kanazaca/easypay”使用 Easypay API 创建一个 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 将调用“通知 URL”。 我们应该在easypay后台的“URL配置”下进行配置。 因为当easypay 服务收到付款时,他们会调用我们提供的URL。所以我在easypay的后台定义了一个url,并在项目中创建了一个路由:
Route::get('/easypay/notification-callback', [
'uses' => 'PaymentController@receiveNotifications',
'as' =>'mb.notifications'
]);
在 api 后台有一个模拟付款的按钮,单击此按钮后没有任何反应,如果我手动访问“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
}
【问题讨论】:
标签: php laravel api payment-gateway payment-processing