简体   繁体   中英

woocommerce after payment redirection in webhook

i am following this tutorial Woocommerce Payment Gateway

but instead of direct, i am doing form method. For this, I have used webhook using

add_action( 'woocommerce_api_vista_response', array( $this, 'vistaMoneyResponseWebhook' ) );

and my vistaMoneyResponseWebhook is as follows:

public function vistaMoneyResponseWebhook() {

            $order = wc_get_order( $_GET['trackid'] );
            //var_dump($order);
            if($_GET['responsecode']==='000') {
                $order->payment_complete();

                //$order->reduce_order_stock();
                wc_reduce_stock_levels( $order->get_id() );
            }
            else{
                //$order->
                var_dump($_GET);die;
            }

            update_option('webhook_debug', $_GET);

        }

The response from payment gateway is in $_GET. and this code works fine.

Now, I am stuck in redirecting the user to the corresponding nice pages like order successful and unsuccessful pages. Need guidance in that scenario.

You can redirect from the webhook using the : wp_redirect() function

Ex : to perform a redirection to the order success page

return wp_redirect($this->get_return_url( $order ));

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM