(src > payments.php)is a router for adding a method in QPilot and is hooked into the  woocommerce_payment_token_added action hook. It takes the token_id from the hook. It also has two filters, autoship_add_tokenized_payment_method_gateway_id and autoship_add_tokenized_payment_method_extend_gateway_types which can be used to extend the valid Gateway IDs, and Method Types, It also has a autoship_add_tokenized_payment_method_extend_gateway action called directly before the autoship_add_general_payment_method function is called so users can add custom add methods.


 * Calls the function to add a payment method to QPilot
 * Based on Token.  Also can be extended using {@see autoship_add_tokenized_payment_method_extend_gateway}
 * @param int $token_id. A WC_Payment_Token_CC token id.
 * @param object $response
function autoship_add_tokenized_payment_method( $token_id ){

  // Get the token
  $token = WC_Payment_Tokens::get( $token_id );

  // Allow users to override the gateway id.
  $gateway_id = apply_filters('autoship_add_tokenized_payment_method_gateway_id', $token->get_gateway_id(), $token_id, $token );

  // Get the current gateway id types. & Allow users to extend based on id & token.
  $gateway_id_types = apply_filters('autoship_add_tokenized_payment_method_extend_gateway_types', autoship_standard_gateway_id_types(), $gateway_id, $token );

  if ( !array_key_exists( $gateway_id, $gateway_id_types ) )

  * Add an action for Customers to call their own payment gateway deletion method.
  * @hooked autoship_add_tokenized_payment_method() - 11
  do_action( 'autoship_add_tokenized_payment_method_extend_gateway', $gateway_id, $gateway_id_types, $token );

  // Call the Autoship general add payment function.
  autoship_add_general_payment_method( $token );

add_action( 'woocommerce_new_payment_token', 'autoship_add_tokenized_payment_method', 10, 1 );

Still need help? Contact Us Contact Us