Woocommerce 2.4.12 – API Callbacks don't react
-
I wand to create an api callback in woocommerce so I can access an url and let my class do some work.
I created a new class which will handle the callback:
<?php class WC_My_Gateway_Callback { public function __construct() { error_log("constructing callback class",0); add_action('woocommerce_api_wc_my_gateway_callback','handle_payment_callback'); } function handle_payment_callback() { error_log( "MyModule Callback in callback.php" , 0 ); exit; } } ?>
(I hope you don’t mind, I’m using the error_log for debugging …)
The class has been initialized and there was no error logged while adding the action.
According to the documentation:
https://docs.woothemes.com/document/wc_api-the-woocommerce-api-callback/I can now trigger the function handle_payment_callback() of this class.
I activated the rest api, I created a new user, I generated a key and a secret.
I can access functions like /wc-api/v3/order – so my setup must be okay.
I try to access my function like this:
https://mydomain.com/wordpress/wc-api/v3/wc_my_gateway_callback?consumer_key=ck_MYGENERATEDKEY&consumer_secret=cs_MYGENERATEDSECRET
This will return:
{"errors":[{"code":"woocommerce_api_no_route","message":"No route was found matching the URL and request method"}]}
Can you see what I did wrong?
- The topic ‘Woocommerce 2.4.12 – API Callbacks don't react’ is closed to new replies.