(src > payments.php) Calls function to delete a payment method in QPilot. Takes the token_id and token as parameters.


 * Calls the function to delete 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_delete_tokenized_payment_method( $token_id, $token ){

  // The id for the token being removed.
  $gateway_id = apply_filters('autoship_delete_tokenized_payment_method_gateway_id', $token->get_gateway_id(), $token );

  // Get the current gateway id types. & Allow users to extend based on id & token.
  $gateway_id_types = apply_filters('autoship_delete_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.
  do_action( 'autoship_delete_tokenized_payment_method_extend_gateway', $gateway_id, $gateway_id_types, $token );

  // Call the Autoship general delete payment function.
  autoship_delete_general_payment_method( $token_id, $token, $gateway_id_types[$gateway_id] );

add_action( 'woocommerce_payment_token_deleted', 'autoship_delete_tokenized_payment_method', 10, 2 );