我们如何从laravel5.6中的第三方网站将发布的数据发布到我的网址?

时间:2018-05-10 09:12:54

标签: php laravel laravel-5 laravel-5.6

我有一个网站。它是使用laravel 5.6创建的。我集成了一个工作正常的支付网关(payone)。我可以做测试交易。但我不知道如何将支付网关发布的帖子数据捕获到我的网址(https://demo.project.de/payment/response)。我尝试了一些功能,但没有工作。这是我的代码。任何帮助将不胜感激。

routes-> web.php

从支付网关(payone)获取帖子的路线

Route::post('/payment/response', 'PaymentController@response')->name('payment.response');

PaymentController.php

public function response()
    {
        // you'll need to include the $defaults array somehow, or at least get the key from a secret configuration file
        if ($_POST["key"] == hash("md5", env('KEY'))) {
            // key is valid, this notification is for us
            echo "TSOK";
            if ($_POST["txaction"] == "appointed") {
                dd($_POST);
                // a freshly created transaction has been marked successfully initiated
                // update that transaction accordingly, e.g. by $_POST["reference"]
            }
            if ($_POST["txaction"] == "paid") {
                dd($_POST);
                // update your transaction accordingly, e.g. by $_POST["reference"]
            }
        }
    }

Payone回复

response of your webserver:

<!DOCTYPE HTML> <HTML LANG="EN"> <HEAD> <META CHARSET="UTF-8"> <META HTTP-EQUIV="X-UA-COMPATIBLE" CONTENT="IE=EDGE"> <META NAME="VIEWPORT" CONTENT="WIDTH=DEVICE-WIDTH, INITIAL-SCALE=1"> <TITLE>PAGE EXPIRED</TITLE> <!-- FONTS --> <LINK HREF="HTTPS://FONTS.GOOGLEAPIS.COM/CSS?FAMILY =RALEWAY:100,600" REL="STYLESHEET" TYPE="TEXT/CSS"> <!-- STYLES --> <STYLE> HTML, BODY { BACKGROUND-COLOR: #FFF; COLOR: #636B6F; FONT-FAMILY: 'RALEWAY', SANS-SERIF; FONT-WEIGHT: 100; HEIGHT: 100VH; MARGIN: 0; } .FULL-HEIGHT { HEIGHT: 100VH; } .FLEX-CENTER { ALIGN-ITEMS: CENTER; DISPLAY: FLEX; JUSTIFY-CONTENT: CENTER; } .POSITION-REF { POSITION: RELATIVE; } .CONTENT {

2 个答案:

答案 0 :(得分:0)

尝试使用该功能

public function response(Request $request)
{
    $data = $request->all();

    // then here you should have the parameters received from the payone and process as required in the $data variable

}

答案 1 :(得分:0)

没有从支付网关获得响应的两个原因。

1:在支付网关中,响应网址错误。他们张贴到我错误输入的网址。

2:我的路由没有公共访问权限,它位于auth中间件内。

现在响应越来越好了。