Callback_handler won't fire WooCommerce Callback_handler won't fire WooCommerce wordpress wordpress

Callback_handler won't fire WooCommerce


I have the same problem. Try to add exit; or wp_die(); in the end of your callback function.

This works for me.


I had the same problem, so, this is what worked for me:

class WC_mygateway extends WC_Payment_Gateway {  public function __construct() {    //'woocommerce_api_'.strtolower(get_class($this)) will result in 'woocommerce_api_wc_mygateway'    add_action('woocommerce_api_'.strtolower(get_class($this)), array(&$this, 'handle_callback'));  }  function handle_callback() {    //Handle the thing here!  }}function woocommerce_mygateway_add_gateway( $methods ) {  $methods[] = 'WC_mygateway';  return $methods}add_filter( 'woocommerce_payment_gateways', 'woocommerce_mygateway_add_gateway');

Make sure you are not missing any of those details, other wise it wont work. Also you can call it using http://example.com/?wc-api=wc_mygateway or http://example.com/wc-api/wc_mygateway

Hope this work for everyone getting stuck with this issue!


Have you tried using http://yoursite/wc-api/WC_your_gateway/ (add slash at the end)?

Also the add_action should be "woocommerce_api_{class_name}" instead of" woocommerce_api_callback". So for your example, it should be "woocommerce_api_wc_your_gateway".