error in printing form in woocommerce

I am creating a payment gateway plugin for woocommerce form my payment gateway.
After i click on the checkout page through my payment gateway. I am getting an syntax error.I think i am not wrong below is my process_payment function code

         /**
         * Process the payment and return the result
         **/
        function process_payment($order_id){
            global $woocommerce;
            $order = new WC_Order($order_id);
            $order_id = $order_id;
            $the_order_total = $order->order_total;
            $mercahntId=$this->merchant_id;
            $merchantPassword=$this ->merchant_password;
            $retrunUrl=$this->notify_url;
            $paymentGatewayUrl=$this ->liveurl;

            echo '<form name="Generator" method="post" action="' . $paymentGatewayUrl . '">';
            echo '<input type="hidden" name="UID" value="' . $mercahntId . '">';
            echo '<input type="hidden" name="PWD" value="' . $merchantPassword . '">';
            echo '<input type="hidden" name="ProductDesc" value="' . $order_id . '">';
            echo '<input type="hidden" name="returnURL" value="' . $retrunUrl . '">';
            echo '<input type="hidden" name="Amount" value="' . $the_order_total . '">';
            echo'</form>';
            die();

            //return array('result' => 'success', 'redirect' => $order->get_checkout_payment_url( true ));
        }

its give me an error SyntaxError: Unexpected token <

Read More

I think i am using the correct syntax for printing form in woocommerce.Any idea?

One more question how can i enable to find out the error on which page and line no. in woocommerce.

Related posts

2 comments

  1. It is probably not the syntax of the HTML that produces the error. The server could be producing a HTML response (starting with <) while it is not expected by the client performing the request. The response could be something like a HTTP status code wrapped in HTML, or the HTML form that you print.

  2. The process_payment method of a payment gateway is triggered when a user submits an order in WooCommerce. That function is run with Ajax. I believe that attempting to print anything inside that function will cause an error. If you need to view the data while you are developing and debugging your plugin, try using the wc_add_notice function and don’t return result as success.

Comments are closed.