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:
Shankar Singh C
2023-06-14 15:12:56 +05:30
committed by GitHub
parent ec2bf2160d
commit 6563587564

View File

@ -1562,6 +1562,10 @@ pub async fn list_customer_payment_method(
) -> errors::RouterResponse<api::CustomerPaymentMethodsListResponse> {
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
.find_payment_method_by_customer_id_merchant_id_list(
customer_id,
@ -1570,11 +1574,6 @@ pub async fn list_customer_payment_method(
.await
.to_not_found_response(errors::ApiErrorResponse::PaymentMethodNotFound)?;
//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();
for pm in resp.into_iter() {
let parent_payment_method_token = generate_id(consts::ID_LENGTH, "token");