From f43de21d8b125dd95b215e4b03b0d86dc2a55a5c Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 5 Dec 2023 19:02:18 +0530 Subject: [PATCH 1/3] add connector_transaction_id to trustpay payments --- crates/router/src/connector/trustpay.rs | 4 ++-- .../src/connector/trustpay/transformers.rs | 21 +++++++++++++++---- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 2430aac6c19f..46b50ed1bb02 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -139,7 +139,7 @@ impl ConnectorCommon for Trustpay { .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: reason.or(response_data.description), attempt_status: None, - connector_transaction_id: None, + connector_transaction_id: response_data.instance_id, }) } Err(error_msg) => { @@ -374,7 +374,7 @@ impl ConnectorIntegration, pub errors: Option>, + pub instance_id: Option, } #[derive(Deserialize)] pub struct TrustPayTransactionStatusErrorResponse { pub status: i64, pub payment_description: String, + pub instance_id: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] From 9383e031ab00c627f02a40b429b25ee715f65e7f Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 6 Dec 2023 15:42:46 +0530 Subject: [PATCH 2/3] remove TrustPayTransactionStatusErrorResponse --- crates/router/src/connector/trustpay.rs | 16 ++-------------- .../src/connector/trustpay/transformers.rs | 8 +------- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 46b50ed1bb02..d8ef3d183de1 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -137,7 +137,7 @@ impl ConnectorCommon for Trustpay { message: option_error_code_message .map(|error_code_message| error_code_message.error_code) .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), - reason: reason.or(response_data.description), + reason: reason.or(response_data.description).or(response_data.payment_description), attempt_status: None, connector_transaction_id: response_data.instance_id, }) @@ -363,19 +363,7 @@ impl ConnectorIntegration CustomResult { - 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 vary for the same code, so relying on code alone as it is unique - message: response.status.to_string(), - reason: Some(response.payment_description), - attempt_status: None, - connector_transaction_id: response.instance_id, - }) + self.build_error_response(res) } fn handle_response( diff --git a/crates/router/src/connector/trustpay/transformers.rs b/crates/router/src/connector/trustpay/transformers.rs index f1a3dd927675..270a702bd6ec 100644 --- a/crates/router/src/connector/trustpay/transformers.rs +++ b/crates/router/src/connector/trustpay/transformers.rs @@ -1653,13 +1653,7 @@ pub struct TrustpayErrorResponse { pub description: Option, pub errors: Option>, pub instance_id: Option, -} - -#[derive(Deserialize)] -pub struct TrustPayTransactionStatusErrorResponse { - pub status: i64, - pub payment_description: String, - pub instance_id: Option, + pub payment_description: Option, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] From 97a415ab63e18901aaca636e99ec097cdb94d0ee Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Wed, 6 Dec 2023 10:13:44 +0000 Subject: [PATCH 3/3] chore: run formatter --- crates/router/src/connector/trustpay.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index d8ef3d183de1..286eaf9cb542 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -137,7 +137,9 @@ impl ConnectorCommon for Trustpay { message: option_error_code_message .map(|error_code_message| error_code_message.error_code) .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), - reason: reason.or(response_data.description).or(response_data.payment_description), + reason: reason + .or(response_data.description) + .or(response_data.payment_description), attempt_status: None, connector_transaction_id: response_data.instance_id, })