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
fix(cards): Return a 200 response indicating that a customer is none (#3773)
Vrishab Srivatsa2c95dcd19778
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 281da5066d..83e1a2c488 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -717,6 +717,8 @@ impl serde::Serialize for PaymentMethodList {pub struct CustomerPaymentMethodsListResponse {/// List of payment methods for customerpub customer_payment_methods: Vec<CustomerPaymentMethod>,+ /// Returns whether a customer id is not tied to a payment intent (only when the request is made against a client secret)+ pub is_guest_customer: Option<bool>,}#[derive(Debug, serde::Serialize, ToSchema)]diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex dbd8efcd1c..6ddb333eb5 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -2569,18 +2569,28 @@ pub async fn do_list_customer_pm_fetch_customer_if_not_passed().await?;- let customer_id = payment_intent+ match payment_intent.as_ref().and_then(|intent| intent.customer_id.to_owned())- .ok_or(errors::ApiErrorResponse::CustomerNotFound)?;- Box::pin(list_customer_payment_method(- &state,- merchant_account,- key_store,- payment_intent,- &customer_id,- ))- .await+ {+ Some(customer_id) => {+ Box::pin(list_customer_payment_method(+ &state,+ merchant_account,+ key_store,+ payment_intent,+ &customer_id,+ ))+ .await+ }+ None => {+ let response = api::CustomerPaymentMethodsListResponse {+ customer_payment_methods: Vec::new(),+ is_guest_customer: Some(true),+ };+ Ok(services::ApplicationResponse::Json(response))+ }+ }}}@@ -2776,6 +2786,7 @@ pub async fn list_customer_payment_method(let mut response = api::CustomerPaymentMethodsListResponse {customer_payment_methods: customer_pms,+ is_guest_customer: payment_intent.as_ref().map(|_| false), //to return this key only when the request is tied to a payment intent};let payment_attempt = payment_intent.as_ref()diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.jsonindex 27989e1eae..05cbed3728 100644--- a/openapi/openapi_spec.json+++ b/openapi/openapi_spec.json@@ -7510,6 +7510,11 @@"$ref": "#/components/schemas/CustomerPaymentMethod"},"description": "List of payment methods for customer"+ },+ "is_guest_customer": {+ "type": "boolean",+ "description": "Returns whether a customer id is not tied to a payment intent (only when the request is made against a client secret)",+ "nullable": true}}},