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

feat(connector): [CRYPTOPAY] Pass network details in payment request (#4779)

DEEPANSHU BANSAL84e032e6c28a
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 5d767a5001..c24193ef38 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -2122,6 +2122,7 @@ pub struct SepaAndBacsBillingDetails {
#[serde(rename_all = "snake_case")]
pub struct CryptoData {
pub pay_currency: Option<String>,
+ pub network: Option<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index 7517918ed9..065290b6b2 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -285,6 +285,7 @@ pub enum BankRedirectData {
#[serde(rename_all = "snake_case")]
pub struct CryptoData {
pub pay_currency: Option<String>,
+ pub network: Option<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
@@ -693,8 +694,14 @@ impl From<api_models::payments::BankRedirectData> for BankRedirectData {
impl From<api_models::payments::CryptoData> for CryptoData {
fn from(value: api_models::payments::CryptoData) -> Self {
- let api_models::payments::CryptoData { pay_currency } = value;
- Self { pay_currency }
+ let api_models::payments::CryptoData {
+ pay_currency,
+ network,
+ } = value;
+ Self {
+ pay_currency,
+ network,
+ }
}
}
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 0405f31807..a582a00ee1 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -8195,7 +8195,6 @@ impl Default for super::settings::RequiredFields {
"TRX".to_string(),
"DOGE".to_string(),
"BNB".to_string(),
- "BUSD".to_string(),
"USDT".to_string(),
"USDC".to_string(),
"DAI".to_string(),
@@ -8204,6 +8203,15 @@ impl Default for super::settings::RequiredFields {
value: None,
}
),
+ (
+ "payment_method_data.crypto.network".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.crypto.network".to_string(),
+ display_name: "network".to_string(),
+ field_type: enums::FieldType::Text,
+ value: None,
+ }
+ ),
]),
common : HashMap::new(),
}
diff --git a/crates/router/src/connector/cryptopay/transformers.rs b/crates/router/src/connector/cryptopay/transformers.rs
index 1a1f23b93b..bcbc9a043a 100644
--- a/crates/router/src/connector/cryptopay/transformers.rs
+++ b/crates/router/src/connector/cryptopay/transformers.rs
@@ -42,6 +42,8 @@ pub struct CryptopayPaymentsRequest {
price_amount: String,
price_currency: enums::Currency,
pay_currency: String,
+ #[serde(skip_serializing_if = "Option::is_none")]
+ network: Option<String>,
success_redirect_url: Option<String>,
unsuccess_redirect_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
@@ -63,6 +65,7 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>>
price_amount: item.amount.to_owned(),
price_currency: item.router_data.request.currency,
pay_currency,
+ network: cryptodata.network.to_owned(),
success_redirect_url: item.router_data.request.router_return_url.clone(),
unsuccess_redirect_url: item.router_data.request.router_return_url.clone(),
//Cryptopay only accepts metadata as Object. If any other type, payment will fail with error.
diff --git a/crates/router/tests/connectors/bitpay.rs b/crates/router/tests/connectors/bitpay.rs
index 85026c9c44..69c6bfac61 100644
--- a/crates/router/tests/connectors/bitpay.rs
+++ b/crates/router/tests/connectors/bitpay.rs
@@ -70,6 +70,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None,
+ network: None,
}),
confirm: true,
statement_descriptor_suffix: None,
diff --git a/crates/router/tests/connectors/coinbase.rs b/crates/router/tests/connectors/coinbase.rs
index 306255c94c..569b2222e8 100644
--- a/crates/router/tests/connectors/coinbase.rs
+++ b/crates/router/tests/connectors/coinbase.rs
@@ -72,6 +72,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None,
+ network: None,
}),
confirm: true,
statement_descriptor_suffix: None,
diff --git a/crates/router/tests/connectors/cryptopay.rs b/crates/router/tests/connectors/cryptopay.rs
index 6d52a174b5..20c727756e 100644
--- a/crates/router/tests/connectors/cryptopay.rs
+++ b/crates/router/tests/connectors/cryptopay.rs
@@ -71,6 +71,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: Some("XRP".to_string()),
+ network: None,
}),
confirm: true,
statement_descriptor_suffix: None,
diff --git a/crates/router/tests/connectors/opennode.rs b/crates/router/tests/connectors/opennode.rs
index 91162b829e..df54f0caf8 100644
--- a/crates/router/tests/connectors/opennode.rs
+++ b/crates/router/tests/connectors/opennode.rs
@@ -71,6 +71,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None,
+ network: None,
}),
confirm: true,
statement_descriptor_suffix: None,
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 93adec74de..544908a4f4 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -7907,6 +7907,10 @@
"pay_currency": {
"type": "string",
"nullable": true
+ },
+ "network": {
+ "type": "string",
+ "nullable": true
}
}
},