WordPress.org

Ready to get started?Download WordPress

Forums

WooCommerce - excelling eCommerce
API payment gateway issue on callback (4 posts)

  1. David Rosendo
    Member
    Posted 5 months ago #

    Im having the same issue here, I have created a gateway payment everything works but cant seem to get the call back working... it allway returns "1", (I know this means it doesnt find it or doesnt exist)

    The payment is done from the ATM and when it's payed the atm company will execute my callback url: example: http://www.xpto.com/wc-api/WC_Multibanco/?orderid=123&blabla=adb

    For simple porpose the code:

    add_action('plugins_loaded', 'woocommerce_multibanco_init', 0);
    
        if (!class_exists('WC_Payment_Gateway')) {
            return;
        }
    
        class WC_Multibanco extends WC_Payment_Gateway {
    
            /** @var string Access key for MB */
            var $chave_anti_phishing;
    
            public function __construct() {
                global $woocommerce;
    //I HAVE HAVE HIDDEN ALL THE OTHER FIELDS ON PORPOSE
                $this->return_url = str_replace('https:', 'http:', add_query_arg('wc-api', 'WC_Multibanco', home_url('/')));
    
                // Payment listener/API hook
                add_action('woocommerce_api_wc_multibanco', array($this, 'check_mb_response'));
            }
            /**
             * MB response function.
             *
             * @access public
             * @return void
             */
            public function check_mb_response() {
                global $woocommerce;
                    echo "WORKING CALLBACK";
            }
        }
    
        function add_multibanco_gateway($methods) {
            $methods[] = 'WC_Multibanco';
            return $methods;
        }
    
        add_filter('woocommerce_payment_gateways', 'add_multibanco_gateway');
    }

    Please help...

    https://wordpress.org/plugins/woocommerce/

  2. eugenevdm
    Member
    Posted 4 months ago #

    I have exactly the same error. I'm glad I came here to find out "1" means cannot be found.

    My class is class WC_Gateway_PayNow extends WC_Payment_Gateway {}

    add_action does this add_action( 'woocommerce_api_wc_gateway_paynow', array( $this, 'check_ipn_response' ) );

    This function exists: function check_ipn_response() {}

    What might I be doing wrong?

  3. Ala Falaki
    Member
    Posted 3 months ago #

    You should make a new class outside of the payment class, and name it in your url, for example:

    class callback_function{
    	public function __construct(){
    			header("location: http://www.example.com/");
    	}
    }

    and, write this as your callback url:

    http://example.com/wc-api/callback_function

    i dont know if its the way that is supposed to be, but it worked for me ...

  4. Amirima
    Member
    Posted 1 month ago #

    try this
    function add_multibanco_gateway($methods) {
    $methods[] = 'wc_multibanco';
    return $methods;
    }

Reply

You must log in to post.

About this Plugin

About this Topic