mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
fix(core): return an empty array when the customer does not have any payment methods (#1431)
Co-authored-by: ItsMeShashank <shashank.attarde@juspay.in>
This commit is contained in:
@ -1562,6 +1562,10 @@ pub async fn list_customer_payment_method(
|
|||||||
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
|
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
|
||||||
let db = &*state.store;
|
let db = &*state.store;
|
||||||
|
|
||||||
|
db.find_customer_by_customer_id_merchant_id(customer_id, &merchant_account.merchant_id)
|
||||||
|
.await
|
||||||
|
.to_not_found_response(errors::ApiErrorResponse::CustomerNotFound)?;
|
||||||
|
|
||||||
let resp = db
|
let resp = db
|
||||||
.find_payment_method_by_customer_id_merchant_id_list(
|
.find_payment_method_by_customer_id_merchant_id_list(
|
||||||
customer_id,
|
customer_id,
|
||||||
@ -1570,11 +1574,6 @@ pub async fn list_customer_payment_method(
|
|||||||
.await
|
.await
|
||||||
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;
|
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;
|
||||||
//let mca = query::find_mca_by_merchant_id(conn, &merchant_account.merchant_id)?;
|
//let mca = query::find_mca_by_merchant_id(conn, &merchant_account.merchant_id)?;
|
||||||
if resp.is_empty() {
|
|
||||||
return Err(error_stack::report!(
|
|
||||||
errors::ApiErrorResponse::PaymentMethodNotFound
|
|
||||||
));
|
|
||||||
}
|
|
||||||
let mut customer_pms = Vec::new();
|
let mut customer_pms = Vec::new();
|
||||||
for pm in resp.into_iter() {
|
for pm in resp.into_iter() {
|
||||||
let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token");
|
let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token");
|
||||||
|
|||||||
Reference in New Issue
Block a user