From 5c29f37ab2ba7d891e22a92e01b8330f64f9dd49 Mon Sep 17 00:00:00 2001 From: Nishant Joshi Date: Tue, 28 Feb 2023 18:29:08 +0530 Subject: [PATCH] =?UTF-8?q?fix(list):=20remove=20enabled=20payment=20metho?= =?UTF-8?q?ds=20from=20list=20customer=20payment=20=E2=80=A6=20(#689)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crates/api_models/src/payment_methods.rs | 17 ---------- .../router/src/core/payment_methods/cards.rs | 32 ++----------------- 2 files changed, 3 insertions(+), 46 deletions(-) diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index 780f055252..ed0a5c875d 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -1,5 +1,3 @@ -use std::collections::HashSet; - use common_utils::pii; use serde::de; use utoipa::ToSchema; @@ -443,21 +441,6 @@ impl serde::Serialize for ListPaymentMethod { #[derive(Debug, serde::Serialize, ToSchema)] pub struct ListCustomerPaymentMethodsResponse { - /// List of enabled payment methods for a customer - #[schema(value_type = Vec,example = json!( - [ - { - "payment_method": "wallet", - "payment_experience": null, - "payment_method_issuers": [ - "labore magna ipsum", - "aute" - ] - } - ] - ))] - pub enabled_payment_methods: HashSet, - /// List of payment methods for customer pub customer_payment_methods: Vec, } diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index ed651ea8d1..7359375414 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -1039,31 +1039,6 @@ pub async fn list_customer_payment_method( customer_id: &str, ) -> errors::RouterResponse { let db = &*state.store; - let all_mcas = db - .find_merchant_connector_account_by_merchant_id_and_disabled_list( - &merchant_account.merchant_id, - false, - ) - .await - .map_err(|error| { - error.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound) - })?; - - let mut enabled_methods: HashSet = HashSet::new(); - for mca in all_mcas { - let payment_methods = match mca.payment_methods_enabled { - Some(pm) => pm, - None => continue, - }; - - for payment_method in payment_methods.into_iter() { - if let Ok(payment_method_object) = - serde_json::from_value::(payment_method) - { - enabled_methods.insert(payment_method_object); - } - } - } let resp = db .find_payment_method_by_customer_id_merchant_id_list( @@ -1080,7 +1055,7 @@ pub async fn list_customer_payment_method( errors::ApiErrorResponse::PaymentMethodNotFound )); } - let mut vec = Vec::new(); + let mut customer_pms = Vec::new(); for pm in resp.into_iter() { let payment_token = generate_id(consts::ID_LENGTH, "token"); let card = if pm.payment_method == enums::PaymentMethod::Card { @@ -1109,12 +1084,11 @@ pub async fn list_customer_payment_method( payment_experience: Some(vec![api_models::enums::PaymentExperience::RedirectToUrl]), created: Some(pm.created_at), }; - vec.push(pma); + customer_pms.push(pma); } let response = api::ListCustomerPaymentMethodsResponse { - enabled_payment_methods: enabled_methods, - customer_payment_methods: vec, + customer_payment_methods: customer_pms, }; Ok(services::ApplicationResponse::Json(response))