mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
fix(cards): Return a 200 response indicating that a customer is none (#3773)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -717,6 +717,8 @@ impl serde::Serialize for PaymentMethodList {
|
|||||||
pub struct CustomerPaymentMethodsListResponse {
|
pub struct CustomerPaymentMethodsListResponse {
|
||||||
/// List of payment methods for customer
|
/// List of payment methods for customer
|
||||||
pub customer_payment_methods: Vec<CustomerPaymentMethod>,
|
pub 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)]
|
#[derive(Debug, serde::Serialize, ToSchema)]
|
||||||
|
|||||||
@ -2569,18 +2569,28 @@ pub async fn do_list_customer_pm_fetch_customer_if_not_passed(
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
let customer_id = payment_intent
|
match payment_intent
|
||||||
.as_ref()
|
.as_ref()
|
||||||
.and_then(|intent| intent.customer_id.to_owned())
|
.and_then(|intent| intent.customer_id.to_owned())
|
||||||
.ok_or(errors::ApiErrorResponse::CustomerNotFound)?;
|
{
|
||||||
Box::pin(list_customer_payment_method(
|
Some(customer_id) => {
|
||||||
&state,
|
Box::pin(list_customer_payment_method(
|
||||||
merchant_account,
|
&state,
|
||||||
key_store,
|
merchant_account,
|
||||||
payment_intent,
|
key_store,
|
||||||
&customer_id,
|
payment_intent,
|
||||||
))
|
&customer_id,
|
||||||
.await
|
))
|
||||||
|
.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 {
|
let mut response = api::CustomerPaymentMethodsListResponse {
|
||||||
customer_payment_methods: customer_pms,
|
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
|
let payment_attempt = payment_intent
|
||||||
.as_ref()
|
.as_ref()
|
||||||
|
|||||||
@ -7510,6 +7510,11 @@
|
|||||||
"$ref": "#/components/schemas/CustomerPaymentMethod"
|
"$ref": "#/components/schemas/CustomerPaymentMethod"
|
||||||
},
|
},
|
||||||
"description": "List of payment methods for customer"
|
"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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user