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

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
DEEPANSHU BANSAL
2024-05-28 16:52:06 +05:30
committed by GitHub
parent d686ec7acd
commit 84e032e6c2
9 changed files with 30 additions and 3 deletions

View File

@ -2122,6 +2122,7 @@ pub struct SepaAndBacsBillingDetails {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub struct CryptoData { pub struct CryptoData {
pub pay_currency: Option<String>, pub pay_currency: Option<String>,
pub network: Option<String>,
} }
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)] #[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]

View File

@ -285,6 +285,7 @@ pub enum BankRedirectData {
#[serde(rename_all = "snake_case")] #[serde(rename_all = "snake_case")]
pub struct CryptoData { pub struct CryptoData {
pub pay_currency: Option<String>, pub pay_currency: Option<String>,
pub network: Option<String>,
} }
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)] #[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 { impl From<api_models::payments::CryptoData> for CryptoData {
fn from(value: api_models::payments::CryptoData) -> Self { fn from(value: api_models::payments::CryptoData) -> Self {
let api_models::payments::CryptoData { pay_currency } = value; let api_models::payments::CryptoData {
Self { pay_currency } pay_currency,
network,
} = value;
Self {
pay_currency,
network,
}
} }
} }

View File

@ -8195,7 +8195,6 @@ impl Default for super::settings::RequiredFields {
"TRX".to_string(), "TRX".to_string(),
"DOGE".to_string(), "DOGE".to_string(),
"BNB".to_string(), "BNB".to_string(),
"BUSD".to_string(),
"USDT".to_string(), "USDT".to_string(),
"USDC".to_string(), "USDC".to_string(),
"DAI".to_string(), "DAI".to_string(),
@ -8204,6 +8203,15 @@ impl Default for super::settings::RequiredFields {
value: None, 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(), common : HashMap::new(),
} }

View File

@ -42,6 +42,8 @@ pub struct CryptopayPaymentsRequest {
price_amount: String, price_amount: String,
price_currency: enums::Currency, price_currency: enums::Currency,
pay_currency: String, pay_currency: String,
#[serde(skip_serializing_if = "Option::is_none")]
network: Option<String>,
success_redirect_url: Option<String>, success_redirect_url: Option<String>,
unsuccess_redirect_url: Option<String>, unsuccess_redirect_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")] #[serde(skip_serializing_if = "Option::is_none")]
@ -63,6 +65,7 @@ impl TryFrom<&CryptopayRouterData<&types::PaymentsAuthorizeRouterData>>
price_amount: item.amount.to_owned(), price_amount: item.amount.to_owned(),
price_currency: item.router_data.request.currency, price_currency: item.router_data.request.currency,
pay_currency, pay_currency,
network: cryptodata.network.to_owned(),
success_redirect_url: item.router_data.request.router_return_url.clone(), success_redirect_url: item.router_data.request.router_return_url.clone(),
unsuccess_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. //Cryptopay only accepts metadata as Object. If any other type, payment will fail with error.

View File

@ -70,6 +70,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD, currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData { payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None, pay_currency: None,
network: None,
}), }),
confirm: true, confirm: true,
statement_descriptor_suffix: None, statement_descriptor_suffix: None,

View File

@ -72,6 +72,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD, currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData { payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None, pay_currency: None,
network: None,
}), }),
confirm: true, confirm: true,
statement_descriptor_suffix: None, statement_descriptor_suffix: None,

View File

@ -71,6 +71,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD, currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData { payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: Some("XRP".to_string()), pay_currency: Some("XRP".to_string()),
network: None,
}), }),
confirm: true, confirm: true,
statement_descriptor_suffix: None, statement_descriptor_suffix: None,

View File

@ -71,6 +71,7 @@ fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {
currency: enums::Currency::USD, currency: enums::Currency::USD,
payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData { payment_method_data: domain::PaymentMethodData::Crypto(domain::CryptoData {
pay_currency: None, pay_currency: None,
network: None,
}), }),
confirm: true, confirm: true,
statement_descriptor_suffix: None, statement_descriptor_suffix: None,

View File

@ -7907,6 +7907,10 @@
"pay_currency": { "pay_currency": {
"type": "string", "type": "string",
"nullable": true "nullable": true
},
"network": {
"type": "string",
"nullable": true
} }
} }
}, },