mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
fix: proper error message for payment cancel (#192)
This commit is contained in:
committed by
GitHub
parent
47741b47fa
commit
55d161b826
@ -431,9 +431,12 @@ impl
|
|||||||
req: &types::PaymentsCancelRouterData,
|
req: &types::PaymentsCancelRouterData,
|
||||||
) -> CustomResult<Option<String>, errors::ConnectorError> {
|
) -> CustomResult<Option<String>, errors::ConnectorError> {
|
||||||
let stripe_req = utils::Encode::<stripe::CancelRequest>::convert_and_url_encode(req)
|
let stripe_req = utils::Encode::<stripe::CancelRequest>::convert_and_url_encode(req)
|
||||||
.change_context(errors::ConnectorError::RequestEncodingFailed)?;
|
.change_context(errors::ConnectorError::RequestEncodingFailedWithReason(
|
||||||
|
"Invalid cancellation reason".to_string(),
|
||||||
|
))?;
|
||||||
Ok(Some(stripe_req))
|
Ok(Some(stripe_req))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn build_request(
|
fn build_request(
|
||||||
&self,
|
&self,
|
||||||
req: &types::PaymentsCancelRouterData,
|
req: &types::PaymentsCancelRouterData,
|
||||||
|
|||||||
@ -281,6 +281,8 @@ pub enum ConnectorError {
|
|||||||
FailedToObtainIntegrationUrl,
|
FailedToObtainIntegrationUrl,
|
||||||
#[error("Failed to encode connector request")]
|
#[error("Failed to encode connector request")]
|
||||||
RequestEncodingFailed,
|
RequestEncodingFailed,
|
||||||
|
#[error("Request encoding failed : {0}")]
|
||||||
|
RequestEncodingFailedWithReason(String),
|
||||||
#[error("Failed to deserialize connector response")]
|
#[error("Failed to deserialize connector response")]
|
||||||
ResponseDeserializationFailed,
|
ResponseDeserializationFailed,
|
||||||
#[error("Failed to execute a processing step: {0:?}")]
|
#[error("Failed to execute a processing step: {0:?}")]
|
||||||
|
|||||||
@ -102,6 +102,9 @@ impl ConnectorErrorExt for error_stack::Report<errors::ConnectorError> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
errors::ConnectorError::RequestEncodingFailedWithReason(reason) => {
|
||||||
|
Some(serde_json::json!(reason))
|
||||||
|
}
|
||||||
_ => None,
|
_ => None,
|
||||||
};
|
};
|
||||||
self.change_context(errors::ApiErrorResponse::PaymentAuthorizationFailed { data })
|
self.change_context(errors::ApiErrorResponse::PaymentAuthorizationFailed { data })
|
||||||
|
|||||||
Reference in New Issue
Block a user