Php Woocommerce自定义支付网关重定向

Php Woocommerce自定义支付网关重定向,php,curl,woocommerce,payment-gateway,payment-processing,Php,Curl,Woocommerce,Payment Gateway,Payment Processing,我有个问题。我应该做一个自定义网关。我知道基本情况。我看了文件。要传输的URL数据(如用户名、交易金额)。我的问题是如何将用户重定向到银行的付款页面?命令是什么,在哪里给出确切的url?然后返回的数据必须用什么方法处理?卷发还是别的什么?我找不到任何真正的解决方案。不同的网关有不同的需求,如果您的网关使用POST,您可以使用它发布数据,并获得响应。。这比卷发好 $response = wp_remote_post( $environment_url, array(

我有个问题。我应该做一个自定义网关。我知道基本情况。我看了文件。要传输的URL数据(如用户名、交易金额)。我的问题是如何将用户重定向到银行的付款页面?命令是什么,在哪里给出确切的url?然后返回的数据必须用什么方法处理?卷发还是别的什么?我找不到任何真正的解决方案。

不同的网关有不同的需求,如果您的网关使用POST,您可以使用它发布数据,并获得响应。。这比卷发好

$response = wp_remote_post( $environment_url, array(
                    'method'    => 'POST',
                    'body'      => http_build_query( $payload ),
                    'timeout'   => 90,
                    'sslverify' => false,
                ) );

// Retrieve the body's response if no errors found
$response_body = wp_remote_retrieve_body( $response );
$response_headers = wp_remote_retrieve_headers( $response );

// Payload would look something like this.
$payload = array(
    "amount" => $order.get_total(), 
    "reference" => $order->get_order_number(),
    "orderid" => $order->id,
    "return_url" => $this->get_return_url($order)  //return to thank you page.
);

//use this if you need to redirect the user to the payment page of the bank.
$querystring = http_build_query( $payload );

return array(
                'result'   => 'success',
                'redirect' => $environment_url . '?' . $querystring,
            );

哈米什,给你的答案一个链接或评论会很有帮助!