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): [Novalnet] add Recurring payment flow for cards (#5921)

Debarati Ghatak6a6ce1750693
diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs
index 025e2bed2b..dadf066a9a 100644
--- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs
+++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs
@@ -1,4 +1,6 @@
pub mod transformers;
+use std::collections::HashSet;
+
use base64::Engine;
use common_enums::enums;
use common_utils::{
@@ -9,6 +11,7 @@ use common_utils::{
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
+ payment_method_data::PaymentMethodData,
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
@@ -41,7 +44,9 @@ use masking::{ExposeInterface, Mask};
use transformers as novalnet;
use crate::{
- constants::headers, types::ResponseRouterData, utils, utils::PaymentsAuthorizeRequestData,
+ constants::headers,
+ types::ResponseRouterData,
+ utils::{self, PaymentMethodDataType, PaymentsAuthorizeRequestData},
};
#[derive(Clone)]
@@ -183,6 +188,15 @@ impl ConnectorValidation for Novalnet {
Err(errors::ConnectorError::MissingConnectorTransactionID.into())
}
+ fn validate_mandate_payment(
+ &self,
+ pm_type: Option<enums::PaymentMethodType>,
+ pm_data: PaymentMethodData,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ let mandate_supported_pmd: HashSet<PaymentMethodDataType> =
+ HashSet::from([PaymentMethodDataType::Card]);
+ utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id())
+ }
}
impl ConnectorRedirectResponse for Novalnet {
diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
index dbdbbdb643..b400555305 100644
--- a/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/novalnet/transformers.rs
@@ -3,6 +3,7 @@ use std::collections::HashMap;
use cards::CardNumber;
use common_enums::{enums, enums as api_enums};
use common_utils::{
+ consts,
ext_traits::OptionExt,
pii::{Email, IpAddress},
request::Method,
@@ -14,7 +15,9 @@ use hyperswitch_domain_models::{
router_data::{ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::refunds::{Execute, RSync},
router_request_types::{PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData, ResponseId},
- router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
+ router_response_types::{
+ MandateReference, PaymentsResponseData, RedirectForm, RefundsResponseData,
+ },
types::{
PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData,
@@ -28,7 +31,7 @@ use strum::Display;
use crate::{
types::{RefundsResponseRouterData, ResponseRouterData},
utils::{
- BrowserInformationData, PaymentsAuthorizeRequestData, PaymentsCancelRequestData,
+ self, BrowserInformationData, PaymentsAuthorizeRequestData, PaymentsCancelRequestData,
PaymentsCaptureRequestData, PaymentsSyncRequestData, RefundsRequestData,
RouterData as OtherRouterData,
},
@@ -63,7 +66,7 @@ pub struct NovalnetPaymentsRequestMerchant {
pub struct NovalnetPaymentsRequestBilling {
house_no: Secret<String>,
street: Secret<String>,
- city: String,
+ city: Secret<String>,
zip: Secret<String>,
country_code: api_enums::CountryAlpha2,
}
@@ -79,7 +82,7 @@ pub struct NovalnetPaymentsRequestCustomer {
}
#[derive(Default, Debug, Clone, Serialize, Deserialize)]
-pub struct NovalNetCard {
+pub struct NovalnetCard {
card_number: CardNumber,
card_expiry_month: Secret<String>,
card_expiry_year: Secret<String>,
@@ -87,10 +90,16 @@ pub struct NovalNetCard {
card_holder: Secret<String>,
}
+#[derive(Debug, Serialize, Deserialize, Clone)]
+pub struct NovalnetMandate {
+ token: Secret<String>,
+}
+
#[derive(Debug, Serialize, Deserialize, Clone)]
#[serde(untagged)]
pub enum NovalNetPaymentData {
- PaymentCard(NovalNetCard),
+ PaymentCard(NovalnetCard),
+ MandatePayment(NovalnetMandate),
}
#[derive(Default, Debug, Serialize, Clone)]
@@ -103,13 +112,14 @@ pub struct NovalnetPaymentsRequestTransaction {
test_mode: i8,
payment_type: NovalNetPaymentTypes,
amount: StringMinorUnit,
- currency: String,
+ currency: common_enums::Currency,
order_no: String,
payment_data: NovalNetPaymentData,
hook_url: Option<String>,
return_url: Option<String>,
error_return_url: Option<String>,
enforce_3d: Option<i8>, //NOTE: Needed for CREDITCARD, GOOGLEPAY
+ create_token: Option<i8>,
}
#[derive(Debug, Serialize, Clone)]
@@ -125,78 +135,127 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
fn try_from(
item: &NovalnetRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
- match item.router_data.request.payment_method_data.clone() {
- PaymentMethodData::Card(req_card) => {
- let auth = NovalnetAuthType::try_from(&item.router_data.connector_auth_type)?;
+ let auth = NovalnetAuthType::try_from(&item.router_data.connector_auth_type)?;
- let merchant = NovalnetPaymentsRequestMerchant {
- signature: auth.product_activation_key,
- tariff: auth.tariff_id,
- };
+ let merchant = NovalnetPaymentsRequestMerchant {
+ signature: auth.product_activation_key,
+ tariff: auth.tariff_id,
+ };
- let novalnet_card = NovalNetPaymentData::PaymentCard(NovalNetCard {
- card_number: req_card.card_number,
- card_expiry_month: req_card.card_exp_month,
- card_expiry_year: req_card.card_exp_year,
- card_cvc: req_card.card_cvc,
- card_holder: item.router_data.get_billing_full_name()?,
- });
+ let enforce_3d = match item.router_data.auth_type {
+ enums::AuthenticationType::ThreeDs => Some(1),
+ enums::AuthenticationType::NoThreeDs => None,
+ };
+ let test_mode = match item.router_data.test_mode {
+ Some(true) => 1,
+ Some(false) | None => 0,
+ };
- let enforce_3d = match item.router_data.auth_type {
- enums::AuthenticationType::ThreeDs => Some(1),
- enums::AuthenticationType::NoThreeDs => None,
- };
- let test_mode = match item.router_data.test_mode {
- Some(true) => 1,
- Some(false) | None => 0,
- };
+ let billing = NovalnetPaymentsRequestBilling {
+ house_no: item.router_data.get_billing_line1()?,
+ street: item.router_data.get_billing_line2()?,
+ city: Secret::new(item.router_data.get_billing_city()?),
+ zip: item.router_data.get_billing_zip()?,
+ country_code: item.router_data.get_billing_country()?,
+ };
+
+ let customer_ip = item
+ .router_data
+ .request
+ .get_browser_info()?
+ .get_ip_address()?;
+
+ let customer = NovalnetPaymentsRequestCustomer {
+ first_name: item.router_data.get_billing_first_name()?,
+ last_name: item.router_data.get_billing_last_name()?,
+ email: item.router_data.get_billing_email()?,
+ mobile: item.router_data.get_optional_billing_phone_number(),
+ billing,
+ customer_ip,
+ };
+
+ let lang = item
+ .router_data
+ .request
+ .get_optional_language_from_browser_info()
+ .unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string());
+ let custom = NovalnetCustom { lang };
+ let hook_url = item.router_data.request.get_webhook_url()?;
+
+ match item
+ .router_data
+ .request
+ .mandate_id
+ .clone()
+ .and_then(|mandate_id| mandate_id.mandate_reference_id)
+ {
+ None => match item.router_data.request.payment_method_data {
+ PaymentMethodData::Card(ref req_card) => {
+ let novalnet_card = NovalNetPaymentData::PaymentCard(NovalnetCard {
+ card_number: req_card.card_number.clone(),
+ card_expiry_month: req_card.card_exp_month.clone(),
+ card_expiry_year: req_card.card_exp_year.clone(),
+ card_cvc: req_card.card_cvc.clone(),
+ card_holder: item.router_data.get_billing_full_name()?,
+ });
+ let create_token = if item.router_data.request.is_mandate_payment() {
+ Some(1)
+ } else {
+ None
+ };
+ let return_url = item.router_data.request.get_return_url()?;
+
+ let transaction = NovalnetPaymentsRequestTransaction {
+ test_mode,
+ payment_type: NovalNetPaymentTypes::CREDITCARD,
+ amount: item.amount.clone(),
+ currency: item.router_data.request.currency,
+ order_no: item.router_data.connector_request_reference_id.clone(),
+ hook_url: Some(hook_url),
+ return_url: Some(return_url.clone()),
+ error_return_url: Some(return_url.clone()),
+ payment_data: novalnet_card,
+ enforce_3d,
+ create_token,
+ };
+
+ Ok(Self {
+ merchant,
+ transaction,
+ customer,
+ custom,
+ })
+ }
+ _ => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("novalnet"),
+ )
+ .into()),
+ },
+ Some(api_models::payments::MandateReferenceId::ConnectorMandateId(mandate_data)) => {
+ let connector_mandate_id = mandate_data.connector_mandate_id.ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "connector_mandate_id",
+ },
+ )?;
+
+ let novalnet_mandate_data = NovalNetPaymentData::MandatePayment(NovalnetMandate {
+ token: Secret::new(connector_mandate_id),
+ });
- let return_url = item.router_data.request.get_return_url().ok();
- let hook_url = item.router_data.request.get_webhook_url().ok();
let transaction = NovalnetPaymentsRequestTransaction {
test_mode,
payment_type: NovalNetPaymentTypes::CREDITCARD,
amount: item.amount.clone(),
- currency: item.router_data.request.currency.to_string(),
+ currency: item.router_data.request.currency,
order_no: item.router_data.connector_request_reference_id.clone(),
- hook_url,
- return_url: return_url.clone(),
- error_return_url: return_url.clone(),
- payment_data: novalnet_card,
+ hook_url: Some(hook_url),
+ return_url: None,
+ error_return_url: None,
+ payment_data: novalnet_mandate_data,
enforce_3d,
+ create_token: None,
};
- let billing = NovalnetPaymentsRequestBilling {
- house_no: item.router_data.get_billing_line1()?,
- street: item.router_data.get_billing_line2()?,
- city: item.router_data.get_billing_city()?,
- zip: item.router_data.get_billing_zip()?,
- country_code: item.router_data.get_billing_country()?,
- };
-
- let customer_ip = item
- .router_data
- .request
- .get_browser_info()?
- .get_ip_address()?;
-
- let customer = NovalnetPaymentsRequestCustomer {
- first_name: item.router_data.get_billing_first_name()?,
- last_name: item.router_data.get_billing_last_name()?,
- email: item.router_data.get_billing_email()?,
- mobile: item.router_data.get_billing_phone_number().ok(),
- billing,
- customer_ip,
- };
-
- let lang = item
- .router_data
- .request
- .get_optional_language_from_browser_info()
- .unwrap_or("EN".to_string());
-
- let custom = NovalnetCustom { lang };
-
Ok(Self {
merchant,
transaction,
@@ -204,7 +263,10 @@ impl TryFrom<&NovalnetRouterData<&PaymentsAuthorizeRouterData>> for NovalnetPaym
custom,
})
}
- _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
+ _ => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("novalnet"),
+ )
+ .into()),
}
}
}
@@ -275,7 +337,7 @@ impl From<NovalnetTransactionStatus> for common_enums::AttemptStatus {
pub struct ResultData {
redirect_url: Option<Secret<url::Url>>,
status: NovalnetAPIStatus,
- status_code: i32,
+ status_code: u16,
status_text: String,
additional_message: Option<String>,
}
@@ -283,7 +345,7 @@ pub struct ResultData {
#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct TransactionData {
payment_type: Option<String>,
- status_code: i32,
+ status_code: u16,
txn_secret: Option<String>,
tid: Option<Secret<i64>>,
test_mode: Option<i8>,
@@ -378,20 +440,20 @@ impl<F, T> TryFrom<ResponseRouterData<F, NovalnetPaymentsResponse, T, PaymentsRe
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct NovalnetResponseCustomer {
- pub billing: NovalnetResponseBilling,
- pub customer_ip: Secret<String>,
- pub email: Secret<String>,
- pub first_name: Secret<String>,
- pub gender: Secret<String>,
- pub last_name: Secret<String>,
- pub mobile: Secret<String>,
+ pub billing: Option<NovalnetResponseBilling>,
+ pub customer_ip: Option<Secret<String>>,
+ pub email: Option<Email>,
+ pub first_name: Option<Secret<String>>,
+ pub gender: Option<Secret<String>>,
+ pub last_name: Option<Secret<String>>,
+ pub mobile: Option<Secret<String>>,
}
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct NovalnetResponseBilling {
pub city: Secret<String>,
pub country_code: Secret<String>,
- pub house_no: Secret<String>,
+ pub house_no: Option<Secret<String>>,
pub street: Secret<String>,
pub zip: Secret<String>,
}
@@ -404,17 +466,17 @@ pub struct NovalnetResponseMerchant {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct NovalnetResponseTransactionData {
- pub amount: u32,
- pub currency: String,
+ pub amount: Option<u32>,
+ pub currency: Option<common_enums::Currency>,
pub date: Option<String>,
- pub order_no: String,
+ pub order_no: Option<String>,
pub payment_data: NovalnetResponsePaymentData,
pub payment_type: String,
pub status: NovalnetTransactionStatus,
pub status_code: u16,
pub test_mode: u8,
- pub tid: Secret<i64>,
- pub txn_secret: Secret<String>,
+ pub tid: Option<Secret<i64>>,
+ pub txn_secret: Option<Secret<String>>,
}
#[derive(Debug, Serialize, Deserialize, Clone)]
@@ -425,14 +487,14 @@ pub enum NovalnetResponsePaymentData {
#[derive(Serialize, Deserialize, Clone, Debug)]
pub struct NovalnetResponseCard {
- pub card_brand: Secret<String>,
+ pub card_brand: Option<Secret<String>>,
pub card_expiry_month: Secret<u8>,
pub card_expiry_year: Secret<u16>,
pub card_holder: Secret<String>,
pub card_number: Secret<String>,
- pub cc_3d: Secret<u8>,
- pub last_four: Secret<String>,
- pub token: Option<Secret<String>>,
+ pub cc_3d: Option<Secret<u8>>,
+ pub last_four: Option<Secret<String>>,
+ pub token: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -492,7 +554,7 @@ impl TryFrom<&NovalnetRouterData<&PaymentsCaptureRouterData>> for NovalnetCaptur
.router_data
.request
.get_optional_language_from_browser_info()
- .unwrap_or("EN".to_string()),
+ .unwrap_or(consts::DEFAULT_LOCALE.to_string()),
};
Ok(Self {
transaction,
@@ -527,7 +589,7 @@ impl<F> TryFrom<&NovalnetRouterData<&RefundsRouterData<F>>> for NovalnetRefundRe
.router_data
.request
.get_optional_language_from_browser_info()
- .unwrap_or("EN".to_string()),
+ .unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string()),
};
Ok(Self {
transaction,
@@ -561,7 +623,7 @@ pub struct NovalnetRefundSyncResponse {
pub struct NovalnetRefundsTransactionData {
amount: u32,
date: Option<String>,
- currency: String,
+ currency: common_enums::Currency,
order_no: String,
payment_type: String,
refund: RefundData,
@@ -575,7 +637,7 @@ pub struct NovalnetRefundsTransactionData {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RefundData {
amount: u32,
- currency: String,
+ currency: common_enums::Currency,
payment_type: String,
tid: Option<Secret<i64>>,
}
@@ -667,7 +729,7 @@ impl TryFrom<&PaymentsSyncRouterData> for NovalnetSyncRequest {
};
let custom = NovalnetCustom {
- lang: "EN".to_string(),
+ lang: consts::DEFAULT_LOCALE.to_string().to_string(),
};
Ok(Self {
transaction,
@@ -676,6 +738,18 @@ impl TryFrom<&PaymentsSyncRouterData> for NovalnetSyncRequest {
}
}
+impl NovalnetResponseTransactionData {
+ pub fn get_token(transaction_data: Option<&Self>) -> Option<String> {
+ if let Some(data) = transaction_data {
+ match &data.payment_data {
+ NovalnetResponsePaymentData::PaymentCard(card_data) => card_data.token.clone(),
+ }
+ } else {
+ None
+ }
+ }
+}
+
impl<F>
TryFrom<ResponseRouterData<F, NovalnetPSyncResponse, PaymentsSyncData, PaymentsResponseData>>
for RouterData<F, PaymentsSyncData, PaymentsResponseData>
@@ -690,12 +764,16 @@ impl<F>
.response
.transaction
.clone()
- .map(|data| data.tid.expose().to_string());
+ .and_then(|data| data.tid)
+ .map(|tid| tid.expose().to_string());
let transaction_status = item
.response
.transaction
+ .clone()
.map(|transaction_data| transaction_data.status)
.unwrap_or(NovalnetTransactionStatus::Pending);
+ let mandate_reference_id =
+ NovalnetResponseTransactionData::get_token(item.response.transaction.as_ref());
Ok(Self {
status: common_enums::AttemptStatus::from(transaction_status),
@@ -705,7 +783,12 @@ impl<F>
.map(ResponseId::ConnectorTransactionId)
.unwrap_or(ResponseId::NoResponseId),
redirection_data: None,
- mandate_reference: None,
+ mandate_reference: mandate_reference_id.as_ref().map(|id| {
+ MandateReference {
+ connector_mandate_id: Some(id.clone()),
+ payment_method_id: None,
+ }
+ }),
connector_metadata: None,
network_txn_id: None,
connector_response_reference_id: transaction_id.clone(),
@@ -730,7 +813,7 @@ impl<F>
pub struct CaptureTransactionData {
amount: Option<u32>,
capture: CaptureData,
- currency: Option<String>,
+ currency: Option<common_enums::Currency>,
order_no: Option<String>,
payment_type: Option<String>,
status: Option<NovalnetTransactionStatus>,
@@ -832,7 +915,7 @@ impl TryFrom<&RefundSyncRouterData> for NovalnetSyncRequest {
lang: item
.request
.get_optional_language_from_browser_info()
- .unwrap_or("EN".to_string()),
+ .unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string()),
};
Ok(Self {
transaction,
@@ -854,9 +937,8 @@ impl TryFrom<RefundsResponseRouterData<RSync, NovalnetRefundSyncResponse>>
.response
.transaction
.clone()
- .map(|transaction_data: NovalnetResponseTransactionData| {
- transaction_data.tid.expose().to_string()
- })
+ .and_then(|data| data.tid)
+ .map(|tid| tid.expose().to_string())
.unwrap_or("".to_string());
//NOTE: Mapping refund_id with "" incase we dont get any tid
@@ -907,7 +989,7 @@ impl TryFrom<&PaymentsCancelRouterData> for NovalnetCancelRequest {
lang: item
.request
.get_optional_language_from_browser_info()
- .unwrap_or("EN".to_string()),
+ .unwrap_or(consts::DEFAULT_LOCALE.to_string().to_string()),
};
Ok(Self {
transaction,
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index bc8502cdd8..b2979975e5 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -1,4 +1,4 @@
-use std::collections::HashMap;
+use std::collections::{HashMap, HashSet};
use api_models::payments::{self, Address, AddressDetails, OrderDetailsWithAmount, PhoneDetails};
use base64::Engine;
@@ -1641,3 +1641,320 @@ mod tests {
assert!(qr_image_data_source_url.is_ok());
}
}
+
+pub fn is_mandate_supported(
+ selected_pmd: PaymentMethodData,
+ payment_method_type: Option<enums::PaymentMethodType>,
+ mandate_implemented_pmds: HashSet<PaymentMethodDataType>,
+ connector: &'static str,
+) -> Result<(), Error> {
+ if mandate_implemented_pmds.contains(&PaymentMethodDataType::from(selected_pmd.clone())) {
+ Ok(())
+ } else {
+ match payment_method_type {
+ Some(pm_type) => Err(errors::ConnectorError::NotSupported {
+ message: format!("{} mandate payment", pm_type),
+ connector,
+ }
+ .into()),
+ None => Err(errors::ConnectorError::NotSupported {
+ message: "mandate payment".to_string(),
+ connector,
+ }
+ .into()),
+ }
+ }
+}
+
+#[derive(Debug, strum::Display, Eq, PartialEq, Hash)]
+pub enum PaymentMethodDataType {
+ Card,
+ Knet,
+ Benefit,
+ MomoAtm,
+ CardRedirect,
+ AliPayQr,
+ AliPayRedirect,
+ AliPayHkRedirect,
+ MomoRedirect,
+ KakaoPayRedirect,
+ GoPayRedirect,
+ GcashRedirect,
+ ApplePay,
+ ApplePayRedirect,
+ ApplePayThirdPartySdk,
+ DanaRedirect,
+ DuitNow,
+ GooglePay,
+ GooglePayRedirect,
+ GooglePayThirdPartySdk,
+ MbWayRedirect,
+ MobilePayRedirect,
+ PaypalRedirect,
+ PaypalSdk,
+ SamsungPay,
+ TwintRedirect,
+ VippsRedirect,
+ TouchNGoRedirect,
+ WeChatPayRedirect,
+ WeChatPayQr,
+ CashappQr,
+ SwishQr,
+ KlarnaRedirect,
+ KlarnaSdk,
+ AffirmRedirect,
+ AfterpayClearpayRedirect,
+ PayBrightRedirect,
+ WalleyRedirect,
+ AlmaRedirect,
+ AtomeRedirect,
+ BancontactCard,
+ Bizum,
+ Blik,
+ Eps,
+ Giropay,
+ Ideal,
+ Interac,
+ LocalBankRedirect,
+ OnlineBankingCzechRepublic,
+ OnlineBankingFinland,
+ OnlineBankingPoland,
+ OnlineBankingSlovakia,
+ OpenBankingUk,
+ Przelewy24,
+ Sofort,
+ Trustly,
+ OnlineBankingFpx,
+ OnlineBankingThailand,
+ AchBankDebit,
+ SepaBankDebit,
+ BecsBankDebit,
+ BacsBankDebit,
+ AchBankTransfer,
+ SepaBankTransfer,
+ BacsBankTransfer,
+ MultibancoBankTransfer,
+ PermataBankTransfer,
+ BcaBankTransfer,
+ BniVaBankTransfer,
+ BriVaBankTransfer,
+ CimbVaBankTransfer,
+ DanamonVaBankTransfer,
+ MandiriVaBankTransfer,
+ Pix,
+ Pse,
+ Crypto,
+ MandatePayment,
+ Reward,
+ Upi,
+ Boleto,
+ Efecty,
+ PagoEfectivo,
+ RedCompra,
+ RedPagos,
+ Alfamart,
+ Indomaret,
+ Oxxo,
+ SevenEleven,
+ Lawson,
+ MiniStop,
+ FamilyMart,
+ Seicomart,
+ PayEasy,
+ Givex,
+ PaySafeCar,
+ CardToken,
+ LocalBankTransfer,
+ Mifinity,
+ Fps,
+ PromptPay,
+ VietQr,
+ OpenBanking,
+ NetworkToken,
+}
+
+impl From<PaymentMethodData> for PaymentMethodDataType {
+ fn from(pm_data: PaymentMethodData) -> Self {
+ match pm_data {
+ PaymentMethodData::Card(_) => Self::Card,
+ PaymentMethodData::NetworkToken(_) => Self::NetworkToken,
+ PaymentMethodData::CardRedirect(card_redirect_data) => {
+ match card_redirect_data {
+ hyperswitch_domain_models::payment_method_data::CardRedirectData::Knet {} => Self::Knet,
+ hyperswitch_domain_models::payment_method_data::CardRedirectData::Benefit {} => Self::Benefit,
+ hyperswitch_domain_models::payment_method_data::CardRedirectData::MomoAtm {} => Self::MomoAtm,
+ hyperswitch_domain_models::payment_method_data::CardRedirectData::CardRedirect {} => Self::CardRedirect,
+ }
+ }
+ PaymentMethodData::Wallet(wallet_data) => match wallet_data {
+ hyperswitch_domain_models::payment_method_data::WalletData::AliPayQr(_) => Self::AliPayQr,
+ hyperswitch_domain_models::payment_method_data::WalletData::AliPayRedirect(_) => Self::AliPayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::AliPayHkRedirect(_) => Self::AliPayHkRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::MomoRedirect(_) => Self::MomoRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::KakaoPayRedirect(_) => Self::KakaoPayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::GoPayRedirect(_) => Self::GoPayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::GcashRedirect(_) => Self::GcashRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePay(_) => Self::ApplePay,
+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePayRedirect(_) => Self::ApplePayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePayThirdPartySdk(_) => {
+ Self::ApplePayThirdPartySdk
+ }
+ hyperswitch_domain_models::payment_method_data::WalletData::DanaRedirect {} => Self::DanaRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePay(_) => Self::GooglePay,
+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePayRedirect(_) => Self::GooglePayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePayThirdPartySdk(_) => {
+ Self::GooglePayThirdPartySdk
+ }
+ hyperswitch_domain_models::payment_method_data::WalletData::MbWayRedirect(_) => Self::MbWayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::MobilePayRedirect(_) => Self::MobilePayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::PaypalRedirect(_) => Self::PaypalRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::PaypalSdk(_) => Self::PaypalSdk,
+ hyperswitch_domain_models::payment_method_data::WalletData::SamsungPay(_) => Self::SamsungPay,
+ hyperswitch_domain_models::payment_method_data::WalletData::TwintRedirect {} => Self::TwintRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::VippsRedirect {} => Self::VippsRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::TouchNGoRedirect(_) => Self::TouchNGoRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::WeChatPayRedirect(_) => Self::WeChatPayRedirect,
+ hyperswitch_domain_models::payment_method_data::WalletData::WeChatPayQr(_) => Self::WeChatPayQr,
+ hyperswitch_domain_models::payment_method_data::WalletData::CashappQr(_) => Self::CashappQr,
+ hyperswitch_domain_models::payment_method_data::WalletData::SwishQr(_) => Self::SwishQr,
+ hyperswitch_domain_models::payment_method_data::WalletData::Mifinity(_) => Self::Mifinity,
+ },
+ PaymentMethodData::PayLater(pay_later_data) => match pay_later_data {
+ hyperswitch_domain_models::payment_method_data::PayLaterData::KlarnaRedirect { .. } => Self::KlarnaRedirect,
+ hyperswitch_domain_models::payment_method_data::PayLaterData::KlarnaSdk { .. } => Self::KlarnaSdk,
+ hyperswitch_domain_models::payment_method_data::PayLaterData::AffirmRedirect {} => Self::AffirmRedirect,
+ hyperswitch_domain_models::payment_method_data::PayLaterData::AfterpayClearpayRedirect { .. } => {
+ Self::AfterpayClearpayRedirect
+ }
+ hyperswitch_domain_models::payment_method_data::PayLaterData::PayBrightRedirect {} => Self::PayBrightRedirect,
+ hyperswitch_domain_models::payment_method_data::PayLaterData::WalleyRedirect {} => Self::WalleyRedirect,
+ hyperswitch_domain_models::payment_method_data::PayLaterData::AlmaRedirect {} => Self::AlmaRedirect,
+ hyperswitch_domain_models::payment_method_data::PayLaterData::AtomeRedirect {} => Self::AtomeRedirect,
+ },
+ PaymentMethodData::BankRedirect(bank_redirect_data) => {
+ match bank_redirect_data {
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::BancontactCard { .. } => {
+ Self::BancontactCard
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Bizum {} => Self::Bizum,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Blik { .. } => Self::Blik,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Eps { .. } => Self::Eps,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Giropay { .. } => Self::Giropay,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Ideal { .. } => Self::Ideal,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Interac { .. } => Self::Interac,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OnlineBankingCzechRepublic { .. } => {
+ Self::OnlineBankingCzechRepublic
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OnlineBankingFinland { .. } => {
+ Self::OnlineBankingFinland
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OnlineBankingPoland { .. } => {
+ Self::OnlineBankingPoland
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OnlineBankingSlovakia { .. } => {
+ Self::OnlineBankingSlovakia
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OpenBankingUk { .. } => Self::OpenBankingUk,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Przelewy24 { .. } => Self::Przelewy24,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Sofort { .. } => Self::Sofort,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::Trustly { .. } => Self::Trustly,
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OnlineBankingFpx { .. } => {
+ Self::OnlineBankingFpx
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::OnlineBankingThailand { .. } => {
+ Self::OnlineBankingThailand
+ }
+ hyperswitch_domain_models::payment_method_data::BankRedirectData::LocalBankRedirect { } => {
+ Self::LocalBankRedirect
+ }
+ }
+ }
+ PaymentMethodData::BankDebit(bank_debit_data) => {
+ match bank_debit_data {
+ hyperswitch_domain_models::payment_method_data::BankDebitData::AchBankDebit { .. } => Self::AchBankDebit,
+ hyperswitch_domain_models::payment_method_data::BankDebitData::SepaBankDebit { .. } => Self::SepaBankDebit,
+ hyperswitch_domain_models::payment_method_data::BankDebitData::BecsBankDebit { .. } => Self::BecsBankDebit,
+ hyperswitch_domain_models::payment_method_data::BankDebitData::BacsBankDebit { .. } => Self::BacsBankDebit,
+ }
+ }
+ PaymentMethodData::BankTransfer(bank_transfer_data) => {
+ match *bank_transfer_data {
+ hyperswitch_domain_models::payment_method_data::BankTransferData::AchBankTransfer { .. } => {
+ Self::AchBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::SepaBankTransfer { .. } => {
+ Self::SepaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::BacsBankTransfer { .. } => {
+ Self::BacsBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::MultibancoBankTransfer { .. } => {
+ Self::MultibancoBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::PermataBankTransfer { .. } => {
+ Self::PermataBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::BcaBankTransfer { .. } => {
+ Self::BcaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::BniVaBankTransfer { .. } => {
+ Self::BniVaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::BriVaBankTransfer { .. } => {
+ Self::BriVaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::CimbVaBankTransfer { .. } => {
+ Self::CimbVaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::DanamonVaBankTransfer { .. } => {
+ Self::DanamonVaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::MandiriVaBankTransfer { .. } => {
+ Self::MandiriVaBankTransfer
+ }
+ hyperswitch_domain_models::payment_method_data::BankTransferData::Pix { .. } => Self::Pix,
+ hyperswitch_domain_models::payment_method_data::BankTransferData::Pse {} => Self::Pse,
+ hyperswitch_domain_models::payment_method_data::BankTransferData::LocalBankTransfer { .. } => {
+ Self::LocalBankTransfer
+ }
+ }
+ }
+ PaymentMethodData::Crypto(_) => Self::Crypto,
+ PaymentMethodData::MandatePayment => Self::MandatePayment,
+ PaymentMethodData::Reward => Self::Reward,
+ PaymentMethodData::Upi(_) => Self::Upi,
+ PaymentMethodData::Voucher(voucher_data) => match voucher_data {
+ hyperswitch_domain_models::payment_method_data::VoucherData::Boleto(_) => Self::Boleto,
+ hyperswitch_domain_models::payment_method_data::VoucherData::Efecty => Self::Efecty,
+ hyperswitch_domain_models::payment_method_data::VoucherData::PagoEfectivo => Self::PagoEfectivo,
+ hyperswitch_domain_models::payment_method_data::VoucherData::RedCompra => Self::RedCompra,
+ hyperswitch_domain_models::payment_method_data::VoucherData::RedPagos => Self::RedPagos,
+ hyperswitch_domain_models::payment_method_data::VoucherData::Alfamart(_) => Self::Alfamart,
+ hyperswitch_domain_models::payment_method_data::VoucherData::Indomaret(_) => Self::Indomaret,
+ hyperswitch_domain_models::payment_method_data::VoucherData::Oxxo => Self::Oxxo,
+ hyperswitch_domain_models::payment_method_data::VoucherData::SevenEleven(_) => Self::SevenEleven,
+ hyperswitch_domain_models::payment_method_data::VoucherData::Lawson(_) => Self::Lawson,
+ hyperswitch_domain_models::payment_method_data::VoucherData::MiniStop(_) => Self::MiniStop,
+ hyperswitch_domain_models::payment_method_data::VoucherData::FamilyMart(_) => Self::FamilyMart,
+ hyperswitch_domain_models::payment_method_data::VoucherData::Seicomart(_) => Self::Seicomart,
+ hyperswitch_domain_models::payment_method_data::VoucherData::PayEasy(_) => Self::PayEasy,
+ },
+ PaymentMethodData::RealTimePayment(real_time_payment_data) => match *real_time_payment_data{
+ hyperswitch_domain_models::payment_method_data::RealTimePaymentData::DuitNow { } => Self::DuitNow,
+ hyperswitch_domain_models::payment_method_data::RealTimePaymentData::Fps { } => Self::Fps,
+ hyperswitch_domain_models::payment_method_data::RealTimePaymentData::PromptPay { } => Self::PromptPay,
+ hyperswitch_domain_models::payment_method_data::RealTimePaymentData::VietQr { } => Self::VietQr,
+ },
+ PaymentMethodData::GiftCard(gift_card_data) => {
+ match *gift_card_data {
+ hyperswitch_domain_models::payment_method_data::GiftCardData::Givex(_) => Self::Givex,
+ hyperswitch_domain_models::payment_method_data::GiftCardData::PaySafeCard {} => Self::PaySafeCar,
+ }
+ }
+ PaymentMethodData::CardToken(_) => Self::CardToken,
+ PaymentMethodData::OpenBanking(data) => match data {
+ hyperswitch_domain_models::payment_method_data::OpenBankingData::OpenBankingPIS { } => Self::OpenBanking
+ },
+ }
+ }
+}
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index a651d27adc..4fcb0785ea 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -2224,15 +2224,6 @@ impl Default for super::settings::RequiredFields {
field_type: enums::FieldType::UserFullName,
value: None,
}
- ),
- (
- "billing.phone.country_code".to_string(),
- RequiredFieldInfo {
- required_field: "payment_method_data.billing.phone.country_code".to_string(),
- display_name: "dialing_code".to_string(),
- field_type: enums::FieldType::UserPhoneNumberCountryCode,
- value: None,
- }
),
(
"billing.email".to_string(),
@@ -5197,15 +5188,6 @@ impl Default for super::settings::RequiredFields {
field_type: enums::FieldType::UserFullName,
value: None,
}
- ),
- (
- "billing.phone.country_code".to_string(),
- RequiredFieldInfo {
- required_field: "payment_method_data.billing.phone.country_code".to_string(),
- display_name: "dialing_code".to_string(),
- field_type: enums::FieldType::UserPhoneNumberCountryCode,
- value: None,
- }
),
(
"billing.email".to_string(),