简体   繁体   English

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

[英]How can we get posted data to my url from a third party website in laravel5.6?

I have a website. 我有一个网站。 It is created using laravel 5.6. 它是使用laravel 5.6创建的。 I integrated a payment gateway (payone) that is working fine. 我集成了运行良好的支付网关(payone)。 I can do test transactions. 我可以测试交易。 But I don't know how can I capture the post data posted by payment gateway to my url ( https://demo.project.de/payment/response ). 但是我不知道如何捕获付款网关发布到我的URL( https://demo.project.de/payment/response )的帖子数据。 I had tried some functionality but not working. 我尝试了一些功能,但无法正常工作。 Here is my code. 这是我的代码。 Any help will be appreciated. 任何帮助将不胜感激。

routes->web.php 路线-> web.php

Route for getting post from payment gateway (payone) 从付款网关(收款人)获取帖子的路线

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

PaymentController.php 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 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 {

Try this on that function 试试这个功能

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

}

Two reason for not getting the response from payment gateway. 无法从支付网关获得响应的两个原因。

1: In payment gateway the response url was wrong. 1:在付款网关中,响应URL错误。 They are posting in to I wrongly entered url. 他们正在张贴到我错误输入的网址。

2: My route doesn't have public access it is inside auth middleware. 2:我的路由没有公共访问权限,它位于身份验证中间件中。

Now response is getting and working fine. 现在,响应越来越好,并且工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM