mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +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,
|
||||
) -> CustomResult<Option<String>, errors::ConnectorError> {
|
||||
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))
|
||||
}
|
||||
|
||||
fn build_request(
|
||||
&self,
|
||||
req: &types::PaymentsCancelRouterData,
|
||||
|
||||
@ -281,6 +281,8 @@ pub enum ConnectorError {
|
||||
FailedToObtainIntegrationUrl,
|
||||
#[error("Failed to encode connector request")]
|
||||
RequestEncodingFailed,
|
||||
#[error("Request encoding failed : {0}")]
|
||||
RequestEncodingFailedWithReason(String),
|
||||
#[error("Failed to deserialize connector response")]
|
||||
ResponseDeserializationFailed,
|
||||
#[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,
|
||||
};
|
||||
self.change_context(errors::ApiErrorResponse::PaymentAuthorizationFailed { data })
|
||||
|
||||
Reference in New Issue
Block a user