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): Change 5xx to 4xx for Coinbase and Iatapay (#1975)
Arvind Patele64d5a3fc286
diff --git a/crates/router/src/connector/coinbase/transformers.rs b/crates/router/src/connector/coinbase/transformers.rsindex 96632cfff6..acc08e36e4 100644--- a/crates/router/src/connector/coinbase/transformers.rs+++ b/crates/router/src/connector/coinbase/transformers.rs@@ -260,7 +260,10 @@ fn get_crypto_specific_payment_data(billing_address.and_then(|add| add.get_first_name().ok().map(|name| name.to_owned()));let description = item.get_description().ok();let connector_meta: CoinbaseConnectorMeta =- utils::to_connector_meta_from_secret(item.connector_meta_data.clone())?;+ utils::to_connector_meta_from_secret_with_required_field(+ item.connector_meta_data.clone(),+ "Pricing Type Not present in connector meta data",+ )?;let pricing_type = connector_meta.pricing_type;let local_price = get_local_price(item);let redirect_url = item.request.get_return_url()?;diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rsindex 298f9967cc..ebdba84916 100644--- a/crates/router/src/connector/iatapay.rs+++ b/crates/router/src/connector/iatapay.rs@@ -229,7 +229,7 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, tOk(ErrorResponse {status_code: res.status_code,code: response.error,- message: response.error_description,+ message: response.path,reason: None,})}diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rsindex 9ad5d845d4..39dfd61b9a 100644--- a/crates/router/src/connector/iatapay/transformers.rs+++ b/crates/router/src/connector/iatapay/transformers.rs@@ -372,5 +372,5 @@ pub struct IatapayErrorResponse {#[derive(Deserialize, Debug)]pub struct IatapayAccessTokenErrorResponse {pub error: String,- pub error_description: String,+ pub path: String,}diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex 2df7da873e..c9fa402f57 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -925,6 +925,23 @@ wherejson.parse_value(std::any::type_name::<T>()).switch()}+pub fn to_connector_meta_from_secret_with_required_field<T>(+ connector_meta: Option<Secret<serde_json::Value>>,+ error_message: &'static str,+) -> Result<T, Error>+where+ T: serde::de::DeserializeOwned,+{+ let connector_error = errors::ConnectorError::MissingRequiredField {+ field_name: error_message,+ };+ let parsed_meta = to_connector_meta_from_secret(connector_meta).ok();+ match parsed_meta {+ Some(meta) => Ok(meta),+ _ => Err(connector_error.into()),+ }+}+pub fn to_connector_meta_from_secret<T>(connector_meta: Option<Secret<serde_json::Value>>,) -> Result<T, Error>