Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
refactor(payment_methods): Enable deletion of default Payment Methods (#4942)
Amisha Prabhatcf3d039efdba
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex 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,