Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(connector): [HELCIM] Handle 4XX Errors (#3458)

DEEPANSHU BANSALec859eabbfb8
diff --git a/crates/router/src/connector/helcim.rs b/crates/router/src/connector/helcim.rs
index c3a6c5e9f5..0b2cac5d76 100644
--- a/crates/router/src/connector/helcim.rs
+++ b/crates/router/src/connector/helcim.rs
@@ -128,9 +128,12 @@ impl ConnectorCommon for Helcim {
.response
.parse_struct("HelcimErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- let error_string = match response.errors {
- transformers::HelcimErrorTypes::StringType(error) => error,
- transformers::HelcimErrorTypes::JsonType(error) => error.to_string(),
+ let error_string = match response {
+ transformers::HelcimErrorResponse::Payment(response) => match response.errors {
+ transformers::HelcimErrorTypes::StringType(error) => error,
+ transformers::HelcimErrorTypes::JsonType(error) => error.to_string(),
+ },
+ transformers::HelcimErrorResponse::General(error_string) => error_string,
};
Ok(ErrorResponse {
diff --git a/crates/router/src/connector/helcim/transformers.rs b/crates/router/src/connector/helcim/transformers.rs
index 599054163c..5e076be651 100644
--- a/crates/router/src/connector/helcim/transformers.rs
+++ b/crates/router/src/connector/helcim/transformers.rs
@@ -756,6 +756,13 @@ pub enum HelcimErrorTypes {
}
#[derive(Debug, Deserialize)]
-pub struct HelcimErrorResponse {
+pub struct HelcimPaymentsErrorResponse {
pub errors: HelcimErrorTypes,
}
+
+#[derive(Debug, Deserialize)]
+#[serde(untagged)]
+pub enum HelcimErrorResponse {
+ Payment(HelcimPaymentsErrorResponse),
+ General(String),
+}