From cf3d039efdbaa95ae9e75de60b3cea67e21d11db Mon Sep 17 00:00:00 2001 From: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com> Date: Wed, 12 Jun 2024 15:45:37 +0530 Subject: [PATCH] refactor(payment_methods): Enable deletion of default Payment Methods (#4942) --- crates/router/src/core/payment_methods/cards.rs | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 499eddafc1..0641c84239 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -3993,16 +3993,6 @@ pub async fn delete_payment_method( .await .to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?; - let payment_methods_count = db - .get_payment_method_count_by_customer_id_merchant_id_status( - &key.customer_id, - &merchant_account.merchant_id, - api_enums::PaymentMethodStatus::Active, - ) - .await - .change_context(errors::ApiErrorResponse::InternalServerError) - .attach_printable("Failed to get a count of payment methods for a customer")?; - let customer = db .find_customer_by_customer_id_merchant_id( &key.customer_id, @@ -4014,12 +4004,6 @@ pub async fn delete_payment_method( .to_not_found_response(errors::ApiErrorResponse::InternalServerError) .attach_printable("Customer not found for the payment method")?; - utils::when( - customer.default_payment_method_id.as_ref() == Some(&pm_id.payment_method_id) - && payment_methods_count > 1, - || Err(errors::ApiErrorResponse::PaymentMethodDeleteFailed), - )?; - if key.payment_method == Some(enums::PaymentMethod::Card) { let response = delete_card_from_locker( &state,