refactor(mandates): refactor mandates to check for misleading error codes in mandates (#1377)

This commit is contained in:
BallaNitesh
2023-06-27 15:52:27 +05:30
committed by GitHub
parent 784847b08c
commit a899c97389
5 changed files with 14 additions and 8 deletions

View File

@ -144,7 +144,7 @@ where
.store
.find_mandate_by_merchant_id_mandate_id(resp.merchant_id.as_ref(), mandate_id)
.await
.change_context(errors::ApiErrorResponse::MandateNotFound)?;
.to_not_found_response(errors::ApiErrorResponse::MandateNotFound)?;
let mandate = match mandate.mandate_type {
storage_enums::MandateType::SingleUse => state
.store
@ -197,7 +197,9 @@ where
let mandate_ids = mandate_reference
.map(|md| {
Encode::<types::MandateReference>::encode_to_value(&md)
.change_context(errors::ApiErrorResponse::MandateNotFound)
.change_context(
errors::ApiErrorResponse::MandateSerializationFailed,
)
.map(masking::Secret::new)
})
.transpose()?;
@ -224,7 +226,7 @@ where
.parse_value::<api_models::payments::ConnectorMandateReferenceId>(
"ConnectorMandateId",
)
.change_context(errors::ApiErrorResponse::MandateNotFound)
.change_context(errors::ApiErrorResponse::MandateDeserializationFailed)
})
.transpose()?
.map_or(