I'm trying to build a custom payment gateway on Woocommerce. And I'm trying to redirect to a new page for payment page from process_payment.
Is there any proper way to redirect to a page and also I can pass the data I need?
My folder struct:
wp-content
|_ plugins
|_ my-payment
|_ redirect_page.php
wc_my_gateway.php
The process_payment function I have edit so far in wc_my_gateway.php :
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
];
}
If there any further information need, please feel free to comment.
Update:
The following code is the solution for me.
Since I only need to redirect to somewhere for client to process payment, by redirecting to /checkout/order-pay
page, I can try to custom what I need for the payment process with my own gateway.
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
];
}