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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(connector): [coinbase][opennode][bitpay] handle error response (#1406)
Arvind Patel301c3dc44bb7
diff --git a/crates/router/src/connector/bitpay.rs b/crates/router/src/connector/bitpay.rsindex e80cebb4b7..2a670375cb 100644--- a/crates/router/src/connector/bitpay.rs+++ b/crates/router/src/connector/bitpay.rs@@ -9,6 +9,7 @@ use transformers as bitpay;use self::bitpay::BitpayWebhookDetails;use crate::{configs::settings,+ consts,core::errors::{self, CustomResult},headers,services::{@@ -109,9 +110,11 @@ impl ConnectorCommon for Bitpay {Ok(ErrorResponse {status_code: res.status_code,- code: response.code,- message: response.message,- reason: response.reason,+ code: response+ .code+ .unwrap_or_else(|| consts::NO_ERROR_CODE.to_string()),+ message: response.error,+ reason: response.message,})}}diff --git a/crates/router/src/connector/bitpay/transformers.rs b/crates/router/src/connector/bitpay/transformers.rsindex d4354591fc..c108b34dd7 100644--- a/crates/router/src/connector/bitpay/transformers.rs+++ b/crates/router/src/connector/bitpay/transformers.rs@@ -222,12 +222,11 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>}}-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]+#[derive(Debug, Deserialize)]pub struct BitpayErrorResponse {- pub status_code: u16,- pub code: String,- pub message: String,- pub reason: Option<String>,+ pub error: String,+ pub code: Option<String>,+ pub message: Option<String>,}fn get_crypto_specific_payment_data(diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rsindex 8afc9c458a..976b200fca 100644--- a/crates/router/src/connector/coinbase.rs+++ b/crates/router/src/connector/coinbase.rs@@ -103,9 +103,9 @@ impl ConnectorCommon for Coinbase {Ok(ErrorResponse {status_code: res.status_code,- code: response.code,- message: response.message,- reason: response.reason,+ code: response.error.error_type,+ message: response.error.message,+ reason: response.error.code,})}}diff --git a/crates/router/src/connector/coinbase/transformers.rs b/crates/router/src/connector/coinbase/transformers.rsindex ec47202114..9f81dd5254 100644--- a/crates/router/src/connector/coinbase/transformers.rs+++ b/crates/router/src/connector/coinbase/transformers.rs@@ -229,11 +229,17 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>}}-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]-pub struct CoinbaseErrorResponse {- pub code: String,+#[derive(Debug, Deserialize)]+pub struct CoinbaseErrorData {+ #[serde(rename = "type")]+ pub error_type: String,pub message: String,- pub reason: Option<String>,+ pub code: Option<String>,+}++#[derive(Debug, Deserialize)]+pub struct CoinbaseErrorResponse {+ pub error: CoinbaseErrorData,}#[derive(Default, Debug, Deserialize, PartialEq)]diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rsindex 8cedb32fd3..c3ee0e86cf 100644--- a/crates/router/src/connector/opennode.rs+++ b/crates/router/src/connector/opennode.rs@@ -10,6 +10,7 @@ use self::opennode::OpennodeWebhookDetails;use crate::{configs::settings,connector::utils as conn_utils,+ consts,core::errors::{self, CustomResult},db, headers,services::{@@ -103,9 +104,9 @@ impl ConnectorCommon for Opennode {Ok(ErrorResponse {status_code: res.status_code,- code: response.code,+ code: consts::NO_ERROR_CODE.to_string(),message: response.message,- reason: response.reason,+ reason: None,})}}diff --git a/crates/router/src/connector/opennode/transformers.rs b/crates/router/src/connector/opennode/transformers.rsindex 16572b0700..3fc79a7800 100644--- a/crates/router/src/connector/opennode/transformers.rs+++ b/crates/router/src/connector/opennode/transformers.rs@@ -211,12 +211,9 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>}//TODO: Fill the struct with respective fields-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]+#[derive(Debug, Deserialize)]pub struct OpennodeErrorResponse {- pub status_code: u16,- pub code: String,pub message: String,- pub reason: Option<String>,}fn get_crypto_specific_payment_data(