Woocommerce:如何从 'process_payment' 函数重定向到新页面?

Woocommerce: How to redirect to a new page from 'process_payment' function?

我正在尝试在 Woocommerce 上构建自定义支付网关。 我正在尝试从 process_payment.

重定向到支付页面的新页面

有什么正确的方法可以重定向到一个页面并且我可以传递我需要的数据吗?

我的文件夹结构:

wp-content
|_ plugins
   |_ my-payment
      |_ redirect_page.php
         wc_my_gateway.php

我目前在 wc_my_gateway.php 中编辑的 process_payment 函数 :

public function process_payment($order_id)
{
        global $woocommerce;
        $order = new WC_Order($order_id);
        
        // todo something ...
        
        $redirect_url = plugin_dir_url(__FILE__) . 'redirect_page.php';
        return [
            'result' => 'success', // return success status
            'redirect' => $redirect_url, // web page url to redirect
        ];
}

如果需要更多信息,请随时发表评论。

更新: 以下代码是我的解决方案。 由于我只需要重定向到某个地方让客户处理付款,通过重定向到 /checkout/order-pay 页面,我可以尝试使用我自己的网关自定义支付过程所需的内容。

public function process_payment($order_id){

  ...

  return [
     'result' => 'success', // return success status
     'redirect' => apply_filters('process_payment_redirect', $order->get_checkout_payment_url(true), $order), // web page redirect
  ];
}