fix(payment_methods): return an empty array when the merchant does not have any payment methods (#1601)

This commit is contained in:
Shankar Singh C
2023-07-04 18:48:30 +05:30
committed by GitHub
parent 9794079c79
commit 04c60d73cb
2 changed files with 53 additions and 21 deletions

View File

@ -1106,19 +1106,16 @@ pub async fn list_payment_methods(
});
}
response
.is_empty()
.then(|| Err(report!(errors::ApiErrorResponse::PaymentMethodNotFound)))
.unwrap_or(Ok(services::ApplicationResponse::Json(
api::PaymentMethodListResponse {
redirect_url: merchant_account.return_url,
merchant_name: merchant_account.merchant_name,
payment_methods: payment_method_responses,
mandate_payment: payment_attempt
.and_then(|inner| inner.mandate_details)
.map(ForeignInto::foreign_into),
},
)))
Ok(services::ApplicationResponse::Json(
api::PaymentMethodListResponse {
redirect_url: merchant_account.return_url,
merchant_name: merchant_account.merchant_name,
payment_methods: payment_method_responses,
mandate_payment: payment_attempt
.and_then(|inner| inner.mandate_details)
.map(ForeignInto::foreign_into),
},
))
}
#[allow(clippy::too_many_arguments)]