WooCommerce custom payment gateway integration not doing POST

I’m wondering if you could help me. I’m working on a custom payment gateway integration with WooCommerce and I’m stuck now. The moment I click on pay I get a 500 Internal Server error in Chromes console and it gets stuck in the receipt page.

You can check the code I got so far here

Read More

https://github.com/tora-soft/visanet-uy-payment-gateway/blob/master/visanet-uy-payment-gateway.php

It is supposed to generate an html form and make a POST to the payment gateway where the user would enter his/her CC details and then come back. This is working now

UPDATE Aug 15th

Now the post is working but when coming back from the payment gateway is landing on a default checkout page and is not processing the result.

Any help would be appreciated.

Thanks in advance.

Related posts

Leave a Reply

1 comment

  1. @Federico You should not rely on the user pressing “return to website” to receive the payment response payload. you should rely on the IPN response talk from their backend to your backend. your payment provider tells the user the payment is successful and the user closes the browser.

    Step 1. When redirecting the user to the VisaNetUY, make it return back on the Thank You URL.

    $return_url = $this->get_return_url($order);
    

    Step 2. Give this URL to your payment gateway so that it can notify your website when a transaction has approved. (sometimes known as webhook or ipn response)

    http://myurl.com/?wc-api=WC_VisaNetUY
    

    Step 3. You need to remove this line.

    add_action('woocommerce_thankyou_' . $this->id, array( $this, 'check_response'  ));
    

    Step 4. and use this line instead:

    add_action('woocommerce_api_wc_visanetuy', array($this, 'check_response') ); 
    //the WC_VisaNetUY from step2 url gets converted to lowercase by wordpress and appended to woocommerce_api_, and if it matches then it calls your function name, in this case it calls your 'check_response', but you could have put any function name here instead of check_reponse in fact some people call it handle_callback or check_ipn_response. 
    

    Step 5. Don’t call $order->reduce_order_stock() because $order->payment_complete() already does the reducing stock, and changing status for you.