如何在控制器中使用 post 值在回调中接收表单数据?

How can I receive form data in callback with post value in controller?

我正在尝试验证在线支付。

在我使用 function actionToken 连接到 bank getway 并付款后,银行向我发送了一些信息以使用 POST 方法验证付款,但我可以' 使用 POST 方法接收信息。

这是我的payment controllerfunction actionToken用于从我的网站发送数据,例如金额function actionVerify用于验证付款我已经收到银行信息。这是我的问题,我不知道我必须做什么。

<?php

namespace frontend\controllers;

use Yii;
use common\models\Order;

class PaymentController extends \yii\web\Controller {

public function actionRequest() {
    include_once('lib/nusoap.php');
    $terminalId     = "xxxx";                    // Terminal ID
    $userName       = "xxxx";                    // Username
    $userPassword   = "xxxxxxx";                 // Password
    $orderId        = time();                       // Order ID
    $amount         = $amount.'0';                  // Price / Rial
    $localDate      = date('Ymd');                  // Date
    $localTime      = date('Gis');                  // Time
    $additionalData = $model['notes'];
    $callBackUrl    = "http://dastsazkala.com/payment/verify?id=".$id;  // Callback URL
    $payerId        =  $id;

    $parameters = [
    'terminalId'        => $terminalId,
    'userName'          => $userName,
    'userPassword'      => $userPassword,
    'orderId'           => $orderId,
    'amount'            => $amount,
    'localDate'         => $localDate,
    'localTime'         => $localTime,
    'additionalData'    => $additionalData,
    'callBackUrl'       => $callBackUrl,
    'payerId'           => $payerId];

    $client = new \nusoap_client('https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl');
    $namespace='http://interfaces.core.sw.bps.com/';
    $result     = $client->call('bpPayRequest', $parameters, $namespace);

}

public function actionVerify($id = null, $check = null) {
//my promblem is in this function, that I cant receive posts.

if ($_POST['ResCode'] == '0') {
    //payment is correct
    include_once('lib/nusoap.php');
    $client = new nusoap_client('https://bpm.shaparak.ir/pgwchannel/services/pgw?wsdl');
    $namespace='http://interfaces.core.sw.bps.com/';

            $terminalId             = "xxxx";                    // Terminal ID
            $userName               = "xxxxx";                    // Username
            $userPassword           = "xxxxx";                   // Password
            $orderId                = $_POST['SaleOrderId'];        // Order ID
            $verifySaleOrderId      = $_POST['SaleOrderId'];
            $verifySaleReferenceId  = $_POST['SaleReferenceId'];

            $parameters = [
            'terminalId' => $terminalId,
            'userName' => $userName,
            'userPassword' => $userPassword,
            'orderId' => $orderId,
            'saleOrderId' => $verifySaleOrderId,
            'saleReferenceId' => $verifySaleReferenceId];
            // Call the SOAP method
            $result = $client->call('bpVerifyRequest', $parameters, $namespace);
            if($result == 0) {
                //verify is correct
                 echo 'The transaction was successful';
            } else {
                //error in pyament
            }
        } else {
            //error in pyament
        }
    }
}

在这个function我什么都没收到。

我是否必须对我的控制器或其他东西的行为做些什么?

为什么我的控制器收不到任何帖子?

一般chrome:

Request URL: http://dastsazkala.com/payment/verify
Request Method: POST
Status Code: 301 Moved Permanently
Remote Address: 138.201.30.123:80
Referrer Policy: no-referrer-when-downgrade

这是我收到的:

问题是这样的:我的网站url开头有www,但是没有 wwwcallBackUrl.

所以我改变了

$callBackUrl = "http://www.dastsazkala.com/payment/verify?id=".$id; //add www. in the beginning

而不是

$callBackUrl = "http://dastsazkala.com/payment/verify?id=".$id;

并且我可以使用 POST 方法从银行 getway 接收 表单数据

dastsazkala.com/payment/verify 重定向到 www.dastsazkala.com/payment/verify 注意 www!

查询结果:

Status Code: 301 Moved Permanently

明确暗示可能正在进行重定向