autoship_add_tokenized_payment_method (function)
(src > payments.php) 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. Has filters and actions to allow for customization and takes $token_id as its parameter.
Function
/** * Calls the function to add a payment method to QPilot * Based on Token. Also can ve extended using {@see autoship_add_tokenized_payment_method_extend_gateway} * * @param int $token_id. A WC_Payment_Token_CC token id. * @param object $response * * @return bool|stdClass|WP_Error The Payment Method object on success, WP_Error on failure, false on not needed. */ 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 ) ) return false; /** * Add an action for Customers to call their own payment gateway add 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. return autoship_add_general_payment_method( $token ); }