未收到通知回调



im使用此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"。我们应该在" URL配置"下的Easypay的退缩情况下配置。 因为当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_user"one_answers" 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
    }

带有日志的recevenotification((方法:

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
    }

会话保存在访问启动付款网站的用户的会话文件中。

如果您在此处执行任何操作,则接收器将从会话文件中调用属于付款网关服务器的数据。数据不匹配,因为两者彼此不认识。

另外,您的请求处理中的某个地方可能没有Session::save(),该会话数据写入文件。

将参考存储在数据库中。创建一个用于存储此数据的模型,因此您可以查询该模型是否正确的参考ID来验证/做事。

当请求从付款网关返回时,请使用变量EP_CIN,EP_USER和EP_DOC从模型中获取数据。

当您手动请求该数据时,请使用GET请求请求,该请求不会将上述数据发送。

付款提供商提出的请求将获得DD的结果,但无处可记录,所以什么也不会发生。

记录您的数据以查看远程API触发的请求以查看发生的情况。

最新更新