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

refactor(router): handle connector errors for tax calculation flow (#5949)

Swangi Kumari776b5482e931
diff --git a/crates/hyperswitch_connectors/src/connectors/taxjar.rs b/crates/hyperswitch_connectors/src/connectors/taxjar.rs
index 009a9cb0c9..56559b75ab 100644
--- a/crates/hyperswitch_connectors/src/connectors/taxjar.rs
+++ b/crates/hyperswitch_connectors/src/connectors/taxjar.rs
@@ -136,7 +136,7 @@ impl ConnectorCommon for Taxjar {
Ok(ErrorResponse {
status_code: res.status_code,
- code: response.status.clone(),
+ code: response.error.clone(),
message: response.detail.clone(),
reason: Some(response.detail),
attempt_status: None,
diff --git a/crates/hyperswitch_connectors/src/connectors/taxjar/transformers.rs b/crates/hyperswitch_connectors/src/connectors/taxjar/transformers.rs
index 53c120a278..1bdc2d2049 100644
--- a/crates/hyperswitch_connectors/src/connectors/taxjar/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/taxjar/transformers.rs
@@ -183,7 +183,7 @@ impl<F>
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
pub struct TaxjarErrorResponse {
- pub status: String,
+ pub status: i64,
pub error: String,
pub detail: String,
}
diff --git a/crates/router/src/core/payments/operations/tax_calculation.rs b/crates/router/src/core/payments/operations/tax_calculation.rs
index 64252762e6..b30d1c4546 100644
--- a/crates/router/src/core/payments/operations/tax_calculation.rs
+++ b/crates/router/src/core/payments/operations/tax_calculation.rs
@@ -16,6 +16,7 @@ use crate::{
payments::{self, helpers, operations, PaymentData},
utils as core_utils,
},
+ db::errors::ConnectorErrorExt,
routes::{app::ReqState, SessionState},
services,
types::{
@@ -288,7 +289,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsDynamicTaxCalculationRequest, Payme
None,
)
.await
- .change_context(errors::ApiErrorResponse::InternalServerError)
+ .to_payment_failed_response()
.attach_printable("Tax connector Response Failed")?;
let tax_response = response.response.map_err(|err| {