'WooCommerce Custom Payment Gateway wp_ajax_nopriv (404 not found)
I am creating a custom WooCommerce gateway plugin. Problem is I need to get some tokens when user clicks on "Place Order" and pass the response token to the JS library of payment method. For token generation I want to pass FirstName, LastName and amount via ajax. But it is throwing 404. When I add this code out of the class. it works.
add_action('plugins_loaded', 'ss_init_gateway_class');
function ss_init_gateway_class()
{
class WC_SS_Gateway extends WC_Payment_Gateway
{
public function __construct()
{
add_action( 'wp_ajax_nopriv_ars_get_transfer_token',array($this,'ars_get_transfer_token' ));
add_action( 'wp_ajax_ars_get_transfer_token', array($this,'ars_get_transfer_token' ));
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
