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): fix trustpay error response for transaction status api (#1445)

Arjun Karthik7db94a620882
diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs
index a0c8a95a90..76371d7691 100644
--- a/crates/router/src/connector/trustpay.rs
+++ b/crates/router/src/connector/trustpay.rs
@@ -307,7 +307,16 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
&self,
res: Response,
) -> CustomResult<ErrorResponse, errors::ConnectorError> {
- self.build_error_response(res)
+ let response: trustpay::TrustPayTransactionStatusErrorResponse = res
+ .response
+ .parse_struct("trustpay transaction status ErrorResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: response.status.to_string(),
+ message: response.payment_description,
+ reason: None,
+ })
}
fn handle_response(
diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rs
index 4bba26339e..3199abf81b 100644
--- a/crates/router/src/connector/trustpay/transformers.rs
+++ b/crates/router/src/connector/trustpay/transformers.rs
@@ -1171,6 +1171,12 @@ pub struct TrustpayErrorResponse {
pub errors: Vec<Errors>,
}
+#[derive(Deserialize)]
+pub struct TrustPayTransactionStatusErrorResponse {
+ pub status: i64,
+ pub payment_description: String,
+}
+
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "UPPERCASE")]
pub enum CreditDebitIndicator {