From 5642fef52a6d591d12c5745ed381f41a1593f183 Mon Sep 17 00:00:00 2001 From: chikke srujan <121822803+srujanchikke@users.noreply.github.com> Date: Wed, 8 Nov 2023 15:44:51 +0530 Subject: [PATCH] fix(connector): Add attempt_status in field in error_response (#2794) --- connector-template/mod.rs | 1 + crates/router/src/connector/aci.rs | 1 + crates/router/src/connector/adyen.rs | 7 +++++++ .../router/src/connector/adyen/transformers.rs | 5 +++++ crates/router/src/connector/airwallex.rs | 1 + crates/router/src/connector/authorizedotnet.rs | 3 +++ .../connector/authorizedotnet/transformers.rs | 4 ++++ crates/router/src/connector/bambora.rs | 1 + crates/router/src/connector/bankofamerica.rs | 1 + crates/router/src/connector/bitpay.rs | 1 + crates/router/src/connector/bluesnap.rs | 16 +++++++++++----- crates/router/src/connector/boku.rs | 2 ++ crates/router/src/connector/braintree.rs | 2 ++ .../braintree/braintree_graphql_transformers.rs | 1 + crates/router/src/connector/cashtocode.rs | 1 + .../src/connector/cashtocode/transformers.rs | 1 + crates/router/src/connector/checkout.rs | 1 + .../src/connector/checkout/transformers.rs | 2 ++ crates/router/src/connector/coinbase.rs | 1 + crates/router/src/connector/cryptopay.rs | 1 + crates/router/src/connector/cybersource.rs | 1 + .../src/connector/cybersource/transformers.rs | 1 + crates/router/src/connector/dlocal.rs | 1 + crates/router/src/connector/dummyconnector.rs | 1 + crates/router/src/connector/fiserv.rs | 2 ++ crates/router/src/connector/forte.rs | 1 + crates/router/src/connector/globalpay.rs | 2 ++ crates/router/src/connector/globepay.rs | 1 + .../src/connector/globepay/transformers.rs | 1 + crates/router/src/connector/gocardless.rs | 1 + crates/router/src/connector/helcim.rs | 1 + crates/router/src/connector/iatapay.rs | 2 ++ crates/router/src/connector/klarna.rs | 1 + crates/router/src/connector/mollie.rs | 1 + crates/router/src/connector/multisafepay.rs | 1 + .../src/connector/multisafepay/transformers.rs | 3 +++ crates/router/src/connector/nexinets.rs | 1 + crates/router/src/connector/nmi/transformers.rs | 1 + crates/router/src/connector/noon.rs | 1 + crates/router/src/connector/noon/transformers.rs | 1 + .../router/src/connector/nuvei/transformers.rs | 1 + crates/router/src/connector/opayo.rs | 1 + crates/router/src/connector/opennode.rs | 1 + crates/router/src/connector/payeezy.rs | 1 + crates/router/src/connector/payme.rs | 1 + .../router/src/connector/payme/transformers.rs | 2 ++ crates/router/src/connector/paypal.rs | 3 +++ crates/router/src/connector/payu.rs | 2 ++ crates/router/src/connector/powertranz.rs | 1 + .../src/connector/powertranz/transformers.rs | 2 ++ crates/router/src/connector/prophetpay.rs | 1 + crates/router/src/connector/rapyd.rs | 1 + .../router/src/connector/rapyd/transformers.rs | 2 ++ crates/router/src/connector/shift4.rs | 1 + crates/router/src/connector/square.rs | 1 + crates/router/src/connector/stax.rs | 1 + crates/router/src/connector/stripe.rs | 13 +++++++++++++ .../router/src/connector/stripe/transformers.rs | 1 + crates/router/src/connector/trustpay.rs | 3 +++ .../src/connector/trustpay/transformers.rs | 8 ++++++++ crates/router/src/connector/tsys/transformers.rs | 1 + crates/router/src/connector/volt.rs | 1 + crates/router/src/connector/wise.rs | 4 ++++ crates/router/src/connector/worldpay.rs | 1 + crates/router/src/connector/zen.rs | 1 + crates/router/src/core/payments/access_token.rs | 1 + crates/router/src/services/api.rs | 16 ++++++---------- crates/router/src/types.rs | 3 +++ crates/router/src/types/api.rs | 1 + crates/router/src/utils.rs | 1 + 70 files changed, 140 insertions(+), 15 deletions(-) diff --git a/connector-template/mod.rs b/connector-template/mod.rs index 05f527d24662..b27a0774e714 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -105,6 +105,7 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} { code: response.code, message: response.message, reason: response.reason, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs index 0e325a04ddb0..7dbe2a0cd9a2 100644 --- a/crates/router/src/connector/aci.rs +++ b/crates/router/src/connector/aci.rs @@ -78,6 +78,7 @@ impl ConnectorCommon for Aci { .collect::>() .join("; ") }), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 18a575b509cb..30b06d1ccf41 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -73,6 +73,7 @@ impl ConnectorCommon for Adyen { code: response.error_code, message: response.message, reason: None, + attempt_status: None, }) } } @@ -251,6 +252,7 @@ impl code: response.error_code, message: response.message, reason: None, + attempt_status: None, }) } } @@ -366,6 +368,7 @@ impl code: response.error_code, message: response.message, reason: None, + attempt_status: None, }) } } @@ -533,6 +536,7 @@ impl code: response.error_code, message: response.message, reason: None, + attempt_status: None, }) } @@ -699,6 +703,7 @@ impl code: response.error_code, message: response.message, reason: None, + attempt_status: None, }) } } @@ -896,6 +901,7 @@ impl code: response.error_code, message: response.message, reason: None, + attempt_status: None, }) } } @@ -1399,6 +1405,7 @@ impl services::ConnectorIntegration { @@ -909,6 +911,7 @@ fn get_error_response( message: message.to_string(), reason: Some(message.to_string()), status_code, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs index 561723be46cf..884504154e8f 100644 --- a/crates/router/src/connector/authorizedotnet/transformers.rs +++ b/crates/router/src/connector/authorizedotnet/transformers.rs @@ -573,6 +573,7 @@ impl message: error.error_text.clone(), reason: None, status_code: item.http_code, + attempt_status: None, }) }); let metadata = transaction_response @@ -647,6 +648,7 @@ impl message: error.error_text.clone(), reason: None, status_code: item.http_code, + attempt_status: None, }) }); let metadata = transaction_response @@ -789,6 +791,7 @@ impl TryFrom types::Error message: message.message[0].text.clone(), reason: None, status_code, + attempt_status: None, } } diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rs index d5e8119b66c8..d0ed9929a77b 100644 --- a/crates/router/src/connector/bambora.rs +++ b/crates/router/src/connector/bambora.rs @@ -95,6 +95,7 @@ impl ConnectorCommon for Bambora { code: response.code.to_string(), message: response.message, reason: Some(serde_json::to_string(&response.details).unwrap_or_default()), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index e25d99f9af3d..a51fcc0ad626 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -111,6 +111,7 @@ impl ConnectorCommon for Bankofamerica { code: response.code, message: response.message, reason: response.reason, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/bitpay.rs b/crates/router/src/connector/bitpay.rs index e8826e933905..63b6e41feaf7 100644 --- a/crates/router/src/connector/bitpay.rs +++ b/crates/router/src/connector/bitpay.rs @@ -120,6 +120,7 @@ impl ConnectorCommon for Bitpay { .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()), message: response.error, reason: response.message, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index 6c39fc41b721..73eeee8ca5a4 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -126,6 +126,7 @@ impl ConnectorCommon for Bluesnap { .map(|error_code_message| error_code_message.error_message) .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: Some(reason), + attempt_status: None, } } bluesnap::BluesnapErrors::Auth(error_res) => ErrorResponse { @@ -133,23 +134,28 @@ impl ConnectorCommon for Bluesnap { code: error_res.error_code.clone(), message: error_res.error_name.clone().unwrap_or(error_res.error_code), reason: Some(error_res.error_description), + attempt_status: None, }, bluesnap::BluesnapErrors::General(error_response) => { - let error_res = if res.status_code == 403 + let (error_res, attempt_status) = if res.status_code == 403 && error_response.contains(BLUESNAP_TRANSACTION_NOT_FOUND) { - format!( - "{} in bluesnap dashboard", - consts::REQUEST_TIMEOUT_PAYMENT_NOT_FOUND + ( + format!( + "{} in bluesnap dashboard", + consts::REQUEST_TIMEOUT_PAYMENT_NOT_FOUND + ), + Some(enums::AttemptStatus::Failure), // when bluesnap throws 403 for payment not found, we update the payment status to failure. ) } else { - error_response.clone() + (error_response.clone(), None) }; ErrorResponse { status_code: res.status_code, code: consts::NO_ERROR_CODE.to_string(), message: error_response, reason: Some(error_res), + attempt_status, } } }; diff --git a/crates/router/src/connector/boku.rs b/crates/router/src/connector/boku.rs index 826d218cd56e..710bcaf3842b 100644 --- a/crates/router/src/connector/boku.rs +++ b/crates/router/src/connector/boku.rs @@ -130,6 +130,7 @@ impl ConnectorCommon for Boku { code: response.code, message: response.message, reason: response.reason, + attempt_status: None, }), Err(_) => get_xml_deserialized(res), } @@ -651,6 +652,7 @@ fn get_xml_deserialized(res: Response) -> CustomResult Ok(ErrorResponse { @@ -139,6 +140,7 @@ impl ConnectorCommon for Braintree { code: consts::NO_ERROR_CODE.to_string(), message: consts::NO_ERROR_MESSAGE.to_string(), reason: Some(response.errors), + attempt_status: None, }), Err(error_msg) => { logger::error!(deserialization_error =? error_msg); diff --git a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs index b622e041915d..bf51973237c5 100644 --- a/crates/router/src/connector/braintree/braintree_graphql_transformers.rs +++ b/crates/router/src/connector/braintree/braintree_graphql_transformers.rs @@ -316,6 +316,7 @@ fn get_error_response( message: error_msg.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), reason: error_reason, status_code: http_code, + attempt_status: None, }) } diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rs index ed994dca31fc..75433cfd0f13 100644 --- a/crates/router/src/connector/cashtocode.rs +++ b/crates/router/src/connector/cashtocode.rs @@ -119,6 +119,7 @@ impl ConnectorCommon for Cashtocode { code: response.error.to_string(), message: response.error_description, reason: None, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/cashtocode/transformers.rs b/crates/router/src/connector/cashtocode/transformers.rs index 4db1bef7e3f2..2caef69db92c 100644 --- a/crates/router/src/connector/cashtocode/transformers.rs +++ b/crates/router/src/connector/cashtocode/transformers.rs @@ -217,6 +217,7 @@ impl status_code: item.http_code, message: error_data.error_description, reason: None, + attempt_status: None, }), ), CashtocodePaymentsResponse::CashtoCodeData(response_data) => { diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index f4cc4ac9640e..6904a440b147 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -131,6 +131,7 @@ impl ConnectorCommon for Checkout { .error_codes .map(|errors| errors.join(" & ")) .or(response.error_type), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/checkout/transformers.rs b/crates/router/src/connector/checkout/transformers.rs index 53182e65ed5b..6ad040da2842 100644 --- a/crates/router/src/connector/checkout/transformers.rs +++ b/crates/router/src/connector/checkout/transformers.rs @@ -576,6 +576,7 @@ impl TryFrom> .clone() .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), reason: item.response.response_summary, + attempt_status: None, }) } else { None @@ -623,6 +624,7 @@ impl TryFrom> .clone() .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), reason: item.response.response_summary, + attempt_status: None, }) } else { None diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rs index d50e490cfc30..f26100fcc8cf 100644 --- a/crates/router/src/connector/coinbase.rs +++ b/crates/router/src/connector/coinbase.rs @@ -108,6 +108,7 @@ impl ConnectorCommon for Coinbase { code: response.error.error_type, message: response.error.message, reason: response.error.code, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs index 8abe84a93532..4dff4206033c 100644 --- a/crates/router/src/connector/cryptopay.rs +++ b/crates/router/src/connector/cryptopay.rs @@ -167,6 +167,7 @@ impl ConnectorCommon for Cryptopay { code: response.error.code, message: response.error.message, reason: response.error.reason, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index 0a13aa0cf141..f038bc2c91da 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -136,6 +136,7 @@ impl ConnectorCommon for Cybersource { code, message, reason: Some(connector_reason), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rs index 55507e4f4903..9233a95d7dd7 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/router/src/connector/cybersource/transformers.rs @@ -367,6 +367,7 @@ impl message: error.message, reason: Some(error.reason), status_code: item.http_code, + attempt_status: None, }), _ => Ok(types::PaymentsResponseData::TransactionResponse { resource_id: types::ResponseId::ConnectorTransactionId( diff --git a/crates/router/src/connector/dlocal.rs b/crates/router/src/connector/dlocal.rs index b706d694a3d5..9bf4bc546cd3 100644 --- a/crates/router/src/connector/dlocal.rs +++ b/crates/router/src/connector/dlocal.rs @@ -135,6 +135,7 @@ impl ConnectorCommon for Dlocal { code: response.code.to_string(), message: response.message, reason: response.param, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index af87029a682c..0346e452ea30 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -111,6 +111,7 @@ impl ConnectorCommon for DummyConnector { code: response.error.code, message: response.error.message, reason: response.error.reason, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/fiserv.rs b/crates/router/src/connector/fiserv.rs index 35d40f1a3fb6..e31217908f25 100644 --- a/crates/router/src/connector/fiserv.rs +++ b/crates/router/src/connector/fiserv.rs @@ -151,6 +151,7 @@ impl ConnectorCommon for Fiserv { message: first_error.message.to_owned(), reason: first_error.field.to_owned(), status_code: res.status_code, + attempt_status: None, }) }) .unwrap_or(types::ErrorResponse { @@ -158,6 +159,7 @@ impl ConnectorCommon for Fiserv { message: consts::NO_ERROR_MESSAGE.to_string(), reason: None, status_code: res.status_code, + attempt_status: None, })) } } diff --git a/crates/router/src/connector/forte.rs b/crates/router/src/connector/forte.rs index 6f20e93e8c8d..af838649031e 100644 --- a/crates/router/src/connector/forte.rs +++ b/crates/router/src/connector/forte.rs @@ -130,6 +130,7 @@ impl ConnectorCommon for Forte { code, message, reason: None, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index dfcddae777e8..57c81cccae3f 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -104,6 +104,7 @@ impl ConnectorCommon for Globalpay { code: response.error_code, message: response.detailed_error_description, reason: None, + attempt_status: None, }) } } @@ -313,6 +314,7 @@ impl ConnectorIntegration message: error_response.error_info.clone(), reason: Some(error_response.error_info), status_code: item.http_code, + attempt_status: None, }), ..item.data }), @@ -808,6 +809,7 @@ impl TryFrom for types::ErrorResponse { message: response.responsetext, reason: None, status_code: http_code, + attempt_status: None, } } } diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index 156e10928d3e..6302fc0f27c2 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -136,6 +136,7 @@ impl ConnectorCommon for Noon { code: response.result_code.to_string(), message: response.class_description, reason: Some(response.message), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/noon/transformers.rs b/crates/router/src/connector/noon/transformers.rs index 4a2128f7ec64..27a874930bcc 100644 --- a/crates/router/src/connector/noon/transformers.rs +++ b/crates/router/src/connector/noon/transformers.rs @@ -511,6 +511,7 @@ impl message: error_message.clone(), reason: Some(error_message), status_code: item.http_code, + attempt_status: None, }), _ => { let connector_response_reference_id = diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rs index 88ebe1d8dbea..c23114e2a96b 100644 --- a/crates/router/src/connector/nuvei/transformers.rs +++ b/crates/router/src/connector/nuvei/transformers.rs @@ -1579,6 +1579,7 @@ fn get_error_response( .unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), reason: None, status_code: http_code, + attempt_status: None, }) } diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index 89e16416d27f..9fc1ad2931af 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -107,6 +107,7 @@ impl ConnectorCommon for Opayo { code: response.code, message: response.message, reason: response.reason, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs index 07d33382a21e..9e8283ff6376 100644 --- a/crates/router/src/connector/opennode.rs +++ b/crates/router/src/connector/opennode.rs @@ -110,6 +110,7 @@ impl ConnectorCommon for Opennode { code: consts::NO_ERROR_CODE.to_string(), message: response.message, reason: None, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/payeezy.rs b/crates/router/src/connector/payeezy.rs index 03e76af907ce..20504f91d5b6 100644 --- a/crates/router/src/connector/payeezy.rs +++ b/crates/router/src/connector/payeezy.rs @@ -123,6 +123,7 @@ impl ConnectorCommon for Payeezy { code: response.transaction_status, message: error_messages.join(", "), reason: None, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index e0d6229c004c..3790bcb66da6 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -97,6 +97,7 @@ impl ConnectorCommon for Payme { "{}, additional info: {}", response.status_error_details, response.status_additional_info )), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/payme/transformers.rs b/crates/router/src/connector/payme/transformers.rs index 1b7ce27439b3..24b7f2b3a0bd 100644 --- a/crates/router/src/connector/payme/transformers.rs +++ b/crates/router/src/connector/payme/transformers.rs @@ -226,6 +226,7 @@ impl From<(&PaymePaySaleResponse, u16)> for types::ErrorResponse { .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: pay_sale_response.status_error_details.to_owned(), status_code: http_code, + attempt_status: None, } } } @@ -308,6 +309,7 @@ impl From<(&SaleQuery, u16)> for types::ErrorResponse { .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: sale_query_response.sale_error_text.clone(), status_code: http_code, + attempt_status: None, } } } diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 854d48dcaadc..af0707070e05 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -91,6 +91,7 @@ impl Paypal { code: response.name, message: response.message.clone(), reason: error_reason.or(Some(response.message)), + attempt_status: None, }) } } @@ -203,6 +204,7 @@ impl ConnectorCommon for Paypal { code: response.name, message: response.message.clone(), reason, + attempt_status: None, }) } } @@ -340,6 +342,7 @@ impl ConnectorIntegration>() .join(", "), ), + attempt_status: None, } }) } else if !ISO_SUCCESS_CODES.contains(&item.iso_response_code.as_str()) { @@ -452,6 +453,7 @@ fn build_error_response( code: item.iso_response_code.clone(), message: item.response_message.clone(), reason: Some(item.response_message.clone()), + attempt_status: None, }) } else { None diff --git a/crates/router/src/connector/prophetpay.rs b/crates/router/src/connector/prophetpay.rs index 0e8d5100ea35..e3860eb70989 100644 --- a/crates/router/src/connector/prophetpay.rs +++ b/crates/router/src/connector/prophetpay.rs @@ -110,6 +110,7 @@ impl ConnectorCommon for Prophetpay { code: response.code, message: response.message, reason: response.reason, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index 29f21f37381d..42ba8197e74e 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -98,6 +98,7 @@ impl ConnectorCommon for Rapyd { code: response_data.status.error_code, message: response_data.status.status.unwrap_or_default(), reason: response_data.status.message, + attempt_status: None, }), Err(error_msg) => { logger::error!(deserialization_error =? error_msg); diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/router/src/connector/rapyd/transformers.rs index 9df699b938bb..08985ba022fc 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/router/src/connector/rapyd/transformers.rs @@ -457,6 +457,7 @@ impl status_code: item.http_code, message: item.response.status.status.unwrap_or_default(), reason: data.failure_message.to_owned(), + attempt_status: None, }), ), _ => { @@ -497,6 +498,7 @@ impl status_code: item.http_code, message: item.response.status.status.unwrap_or_default(), reason: item.response.status.message, + attempt_status: None, }), ), }; diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs index a17546711f14..1d1ea36fae16 100644 --- a/crates/router/src/connector/shift4.rs +++ b/crates/router/src/connector/shift4.rs @@ -99,6 +99,7 @@ impl ConnectorCommon for Shift4 { .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()), message: response.error.message, reason: None, + attempt_status: None, }) } } diff --git a/crates/router/src/connector/square.rs b/crates/router/src/connector/square.rs index a048b0f5433b..5c52728d879f 100644 --- a/crates/router/src/connector/square.rs +++ b/crates/router/src/connector/square.rs @@ -123,6 +123,7 @@ impl ConnectorCommon for Square { .and_then(|error| error.category.clone()) .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: Some(reason), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/stax.rs b/crates/router/src/connector/stax.rs index 7f5fde719389..ba9642b4f875 100644 --- a/crates/router/src/connector/stax.rs +++ b/crates/router/src/connector/stax.rs @@ -109,6 +109,7 @@ impl ConnectorCommon for Stax { .change_context(errors::ConnectorError::ResponseDeserializationFailed)? .to_owned(), ), + attempt_status: None, }) } } diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index e3551306e673..98e544105fda 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -225,6 +225,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -351,6 +352,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -473,6 +475,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -603,6 +606,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -743,6 +747,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -897,6 +902,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -1016,6 +1022,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -1170,6 +1177,7 @@ impl }) .unwrap_or(message) }), + attempt_status: None, }) } } @@ -1287,6 +1295,7 @@ impl services::ConnectorIntegration }) .or(Some(error.message.clone())), status_code: item.http_code, + attempt_status: None, }); let connector_metadata = diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 912f1575e1e0..903952dc8eb4 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -138,6 +138,7 @@ impl ConnectorCommon for Trustpay { .map(|error_code_message| error_code_message.error_code) .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), reason: reason.or(response_data.description), + attempt_status: None, }) } Err(error_msg) => { @@ -293,6 +294,7 @@ impl ConnectorIntegration TryFrom: ConnectorIntegrationAny { let error_res = connector_integration.get_error_response(body)?; - if router_data.connector == "bluesnap" - && error_res.status_code == 403 - && error_res.reason - == Some(format!( - "{} in bluesnap dashboard", - consts::REQUEST_TIMEOUT_PAYMENT_NOT_FOUND - )) - { - router_data.status = AttemptStatus::Failure; + if let Some(status) = error_res.attempt_status { + router_data.status = status; }; error_res } @@ -434,6 +429,7 @@ where message: consts::REQUEST_TIMEOUT_ERROR_MESSAGE.to_string(), reason: Some(consts::REQUEST_TIMEOUT_ERROR_MESSAGE.to_string()), status_code: 504, + attempt_status: None, }; router_data.response = Err(error_response); router_data.connector_http_status_code = Some(504); diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs index 261195d166cb..8f08ce062560 100644 --- a/crates/router/src/types.rs +++ b/crates/router/src/types.rs @@ -923,6 +923,7 @@ pub struct ErrorResponse { pub message: String, pub reason: Option, pub status_code: u16, + pub attempt_status: Option, } impl ErrorResponse { @@ -938,6 +939,7 @@ impl ErrorResponse { .error_message(), reason: None, status_code: http::StatusCode::INTERNAL_SERVER_ERROR.as_u16(), + attempt_status: None, } } } @@ -980,6 +982,7 @@ impl From for ErrorResponse { errors::ApiErrorResponse::ExternalConnectorError { status_code, .. } => status_code, _ => 500, }, + attempt_status: None, } } } diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 2179b4bde180..e815740cac48 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -111,6 +111,7 @@ pub trait ConnectorCommon { code: consts::NO_ERROR_CODE.to_string(), message: consts::NO_ERROR_MESSAGE.to_string(), reason: None, + attempt_status: None, }) } } diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rs index 386bd02ae94b..558044028f7a 100644 --- a/crates/router/src/utils.rs +++ b/crates/router/src/utils.rs @@ -401,6 +401,7 @@ pub fn handle_json_response_deserialization_failure( code: consts::NO_ERROR_CODE.to_string(), message: consts::UNSUPPORTED_ERROR_MESSAGE.to_string(), reason: Some(response_data), + attempt_status: None, }) } }