1
votes

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.

1
did yo have any luck with your issue? I'm struggling with a similar problem and would appreciate if you post how you solve it.DanielHolguin

1 Answers

0
votes

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