Skip to content

Commit

Permalink
fix(connector): Add attempt_status in field in error_response (#2794)
Browse files Browse the repository at this point in the history
  • Loading branch information
srujanchikke authored Nov 8, 2023
1 parent 6678689 commit 5642fef
Show file tree
Hide file tree
Showing 70 changed files with 140 additions and 15 deletions.
1 change: 1 addition & 0 deletions connector-template/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} {
code: response.code,
message: response.message,
reason: response.reason,
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/aci.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ impl ConnectorCommon for Aci {
.collect::<Vec<String>>()
.join("; ")
}),
attempt_status: None,
})
}
}
Expand Down
7 changes: 7 additions & 0 deletions crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ impl ConnectorCommon for Adyen {
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}
}
Expand Down Expand Up @@ -251,6 +252,7 @@ impl
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}
}
Expand Down Expand Up @@ -366,6 +368,7 @@ impl
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}
}
Expand Down Expand Up @@ -533,6 +536,7 @@ impl
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}

Expand Down Expand Up @@ -699,6 +703,7 @@ impl
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}
}
Expand Down Expand Up @@ -896,6 +901,7 @@ impl
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}
}
Expand Down Expand Up @@ -1399,6 +1405,7 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
code: response.error_code,
message: response.message,
reason: None,
attempt_status: None,
})
}
}
Expand Down
5 changes: 5 additions & 0 deletions crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2900,6 +2900,7 @@ pub fn get_adyen_response(
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: response.refusal_reason,
status_code,
attempt_status: None,
})
} else {
None
Expand Down Expand Up @@ -2991,6 +2992,7 @@ pub fn get_redirection_response(
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None,
status_code,
attempt_status: None,
})
} else {
None
Expand Down Expand Up @@ -3052,6 +3054,7 @@ pub fn get_present_to_shopper_response(
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None,
status_code,
attempt_status: None,
})
} else {
None
Expand Down Expand Up @@ -3101,6 +3104,7 @@ pub fn get_qr_code_response(
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: None,
status_code,
attempt_status: None,
})
} else {
None
Expand Down Expand Up @@ -3138,6 +3142,7 @@ pub fn get_redirection_error_response(
message: response.refusal_reason.clone(),
reason: Some(response.refusal_reason),
status_code,
attempt_status: None,
});
// We don't get connector transaction id for redirections in Adyen.
let payments_response_data = types::PaymentsResponseData::TransactionResponse {
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/airwallex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ impl ConnectorCommon for Airwallex {
code: response.code,
message: response.message,
reason: response.source,
attempt_status: None,
})
}
}
Expand Down
3 changes: 3 additions & 0 deletions crates/router/src/connector/authorizedotnet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -893,13 +893,15 @@ fn get_error_response(
message: error.error_text.to_owned(),
reason: Some(error.error_text),
status_code,
attempt_status: None,
})
})
.unwrap_or_else(|| types::ErrorResponse {
code: consts::NO_ERROR_CODE.to_string(), // authorizedotnet sends 200 in case of bad request so this are hard coded to NO_ERROR_CODE and NO_ERROR_MESSAGE
message: consts::NO_ERROR_MESSAGE.to_string(),
reason: None,
status_code,
attempt_status: None,
})),
Some(authorizedotnet::TransactionResponse::AuthorizedotnetTransactionResponseError(_))
| None => {
Expand All @@ -909,6 +911,7 @@ fn get_error_response(
message: message.to_string(),
reason: Some(message.to_string()),
status_code,
attempt_status: None,
})
}
}
Expand Down
4 changes: 4 additions & 0 deletions crates/router/src/connector/authorizedotnet/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ impl<F, T>
message: error.error_text.clone(),
reason: None,
status_code: item.http_code,
attempt_status: None,
})
});
let metadata = transaction_response
Expand Down Expand Up @@ -647,6 +648,7 @@ impl<F, T>
message: error.error_text.clone(),
reason: None,
status_code: item.http_code,
attempt_status: None,
})
});
let metadata = transaction_response
Expand Down Expand Up @@ -789,6 +791,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AuthorizedotnetRefundRespons
message: error.error_text.clone(),
reason: None,
status_code: item.http_code,
attempt_status: None,
})
});

Expand Down Expand Up @@ -1021,6 +1024,7 @@ fn get_err_response(status_code: u16, message: ResponseMessages) -> types::Error
message: message.message[0].text.clone(),
reason: None,
status_code,
attempt_status: None,
}
}

Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/bambora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/bankofamerica.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl ConnectorCommon for Bankofamerica {
code: response.code,
message: response.message,
reason: response.reason,
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/bitpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
})
}
}
Expand Down
16 changes: 11 additions & 5 deletions crates/router/src/connector/bluesnap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,30 +126,36 @@ 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 {
status_code: res.status_code,
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,
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/boku.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
Expand Down Expand Up @@ -651,6 +652,7 @@ fn get_xml_deserialized(res: Response) -> CustomResult<ErrorResponse, errors::Co
code: consts::NO_ERROR_CODE.to_string(),
message: consts::UNSUPPORTED_ERROR_MESSAGE.to_string(),
reason: Some(response_data),
attempt_status: None,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/braintree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,15 @@ impl ConnectorCommon for Braintree {
code,
message,
reason: Some(response.api_error_response.message),
attempt_status: None,
})
}
Ok(braintree::ErrorResponse::BraintreeErrorResponse(response)) => Ok(ErrorResponse {
status_code: res.status_code,
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ fn get_error_response<T>(
message: error_msg.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: error_reason,
status_code: http_code,
attempt_status: None,
})
}

Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cashtocode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl ConnectorCommon for Cashtocode {
code: response.error.to_string(),
message: response.error_description,
reason: None,
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cashtocode/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ impl<F, T>
status_code: item.http_code,
message: error_data.error_description,
reason: None,
attempt_status: None,
}),
),
CashtocodePaymentsResponse::CashtoCodeData(response_data) => {
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/checkout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ impl ConnectorCommon for Checkout {
.error_codes
.map(|errors| errors.join(" & "))
.or(response.error_type),
attempt_status: None,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/checkout/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ impl TryFrom<types::PaymentsResponseRouterData<PaymentsResponse>>
.clone()
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: item.response.response_summary,
attempt_status: None,
})
} else {
None
Expand Down Expand Up @@ -623,6 +624,7 @@ impl TryFrom<types::PaymentsSyncResponseRouterData<PaymentsResponse>>
.clone()
.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()),
reason: item.response.response_summary,
attempt_status: None,
})
} else {
None
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/coinbase.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ impl ConnectorCommon for Coinbase {
code: response.error.error_type,
message: response.error.message,
reason: response.error.code,
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cryptopay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ impl ConnectorCommon for Cryptopay {
code: response.error.code,
message: response.error.message,
reason: response.error.reason,
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cybersource.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl ConnectorCommon for Cybersource {
code,
message,
reason: Some(connector_reason),
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/cybersource/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ impl<F, T>
message: error.message,
reason: Some(error.reason),
status_code: item.http_code,
attempt_status: None,
}),
_ => Ok(types::PaymentsResponseData::TransactionResponse {
resource_id: types::ResponseId::ConnectorTransactionId(
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/dlocal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ impl ConnectorCommon for Dlocal {
code: response.code.to_string(),
message: response.message,
reason: response.param,
attempt_status: None,
})
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/dummyconnector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ impl<const T: u8> ConnectorCommon for DummyConnector<T> {
code: response.error.code,
message: response.error.message,
reason: response.error.reason,
attempt_status: None,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/connector/fiserv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,15 @@ 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 {
code: consts::NO_ERROR_CODE.to_string(),
message: consts::NO_ERROR_MESSAGE.to_string(),
reason: None,
status_code: res.status_code,
attempt_status: None,
}))
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/connector/forte.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ impl ConnectorCommon for Forte {
code,
message,
reason: None,
attempt_status: None,
})
}
}
Expand Down
Loading

0 comments on commit 5642fef

Please sign in to comment.