php - Woocommerce Custom payment gateway callback function not working -


i have been struggling time now. explored google replies etc...

here code:

class wc_gateway_mysolugion extends wc_payment_gateway {  public function __construct() {      ...     ...      /* hook ipn callback logic*/     add_action( 'woocommerce_api_wc_gateway_mysolugion', array( $this, 'check_callback' ) );    }    ....    function check_callback() {      // other code   } 

the problem function check_callback never called when controll returns site payment gateway site.

what doing wrong?

any appreciated.

thanks.

payment gateways should created additional plugins hook woocommerce. inside plugin, need create class after plugins loaded (or alternatively at initialisation if on function.php file of active theme, see below).

so code this:

// plugin (the better choice) add_action( 'plugins_loaded', 'init_mysolugion_gateway' );  // or theme function.php file // add_action( 'init', 'init_mysolugion_gateway' );  function init_mysolugion_gateway() {      class wc_gateway_mysolugion extends wc_payment_gateway {          public function __construct() {              // ...             // ...              /* hook ipn callback logic*/             add_action( 'woocommerce_api_wc_gateway_mysolugion', array( $this, 'check_callback' ) );          }      }  } 

as defining class, need tell woocommerce (wc) exists. filtering woocommerce_payment_gateways:

add_filter( 'woocommerce_payment_gateways', 'add_gateway_mysolugion' ); function add_gateway_mysolugion( $methods ) {     $methods[] = 'wc_gateway_mysolugion';      return $methods; } 

then can add callback function , should work now:

function check_callback() {    // other code } 

references:


Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -