Woocommerce自定义支付网关重定向


Woocommerce custom payment gateway redirect

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

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

$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,
            );