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
refactor(wallet): use `billing.phone` instead of `telephone_number` (#4329)
Swangi Kumari3e6bc191fd58
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex b85734af8b..0c8924f0d2 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -2235,7 +2235,7 @@ impl GetAddressFromPaymentMethodData for WalletData {let phone = PhoneDetails {// Portuguese country code, this payment method is applicable only in portugalcountry_code: Some("+351".into()),- number: Some(mb_way_redirect.telephone_number.clone()),+ number: mb_way_redirect.telephone_number.clone(),};Some(Address {@@ -2360,7 +2360,7 @@ pub struct MobilePayRedirection {}pub struct MbWayRedirection {/// Telephone number of the shopper. Should be Portuguese phone number.#[schema(value_type = String)]- pub telephone_number: Secret<String>,+ pub telephone_number: Option<Secret<String>>,}#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rsindex a4c17fb927..23288e3819 100644--- a/crates/router/src/connector/aci/transformers.rs+++ b/crates/router/src/connector/aci/transformers.rs@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};use super::result_codes::{FAILURE_CODES, PENDING_CODES, SUCCESSFUL_CODES};use crate::{- connector::utils::{self, RouterData},+ connector::utils::{self, PhoneDetailsData, RouterData},core::errors,services,types::{self, domain, storage::enums},@@ -106,14 +106,20 @@ pub enum PaymentDetails {Mandate,}-impl TryFrom<&domain::WalletData> for PaymentDetails {+impl TryFrom<(&domain::WalletData, &types::PaymentsAuthorizeRouterData)> for PaymentDetails {type Error = Error;- fn try_from(wallet_data: &domain::WalletData) -> Result<Self, Self::Error> {+ fn try_from(+ value: (&domain::WalletData, &types::PaymentsAuthorizeRouterData),+ ) -> Result<Self, Self::Error> {+ let (wallet_data, item) = value;let payment_data = match wallet_data {- domain::WalletData::MbWayRedirect(data) => Self::Wallet(Box::new(WalletPMData {- payment_brand: PaymentBrand::Mbway,- account_id: Some(data.telephone_number.clone()),- })),+ domain::WalletData::MbWayRedirect(_) => {+ let phone_details = item.get_billing_phone()?;+ Self::Wallet(Box::new(WalletPMData {+ payment_brand: PaymentBrand::Mbway,+ account_id: Some(phone_details.get_number_with_hash_country_code()?),+ }))+ }domain::WalletData::AliPayRedirect { .. } => Self::Wallet(Box::new(WalletPMData {payment_brand: PaymentBrand::AliPay,account_id: None,@@ -486,7 +492,7 @@ impl) -> Result<Self, Self::Error> {let (item, wallet_data) = value;let txn_details = get_transaction_details(item)?;- let payment_method = PaymentDetails::try_from(wallet_data)?;+ let payment_method = PaymentDetails::try_from((wallet_data, item.router_data))?;Ok(Self {txn_details,diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rsindex 74864980cc..67b61960e8 100644--- a/crates/router/src/connector/adyen/transformers.rs+++ b/crates/router/src/connector/adyen/transformers.rs@@ -12,7 +12,7 @@ use time::{Duration, OffsetDateTime, PrimitiveDateTime};use crate::{connector::utils::{self, AddressDetailsData, BrowserInformationData, CardData, MandateReferenceData,- PaymentsAuthorizeRequestData, RouterData,+ PaymentsAuthorizeRequestData, PhoneDetailsData, RouterData,},consts,core::errors,@@ -2023,9 +2023,14 @@ impl TryFrom<&utils::CardIssuer> for CardBrand {}}-impl<'a> TryFrom<&domain::WalletData> for AdyenPaymentMethod<'a> {+impl<'a> TryFrom<(&domain::WalletData, &types::PaymentsAuthorizeRouterData)>+ for AdyenPaymentMethod<'a>+{type Error = Error;- fn try_from(wallet_data: &domain::WalletData) -> Result<Self, Self::Error> {+ fn try_from(+ value: (&domain::WalletData, &types::PaymentsAuthorizeRouterData),+ ) -> Result<Self, Self::Error> {+ let (wallet_data, item) = value;match wallet_data {domain::WalletData::GooglePay(data) => {let gpay_data = AdyenGPay {@@ -2080,10 +2085,11 @@ impl<'a> TryFrom<&domain::WalletData> for AdyenPaymentMethod<'a> {let touch_n_go_data = TouchNGoData {};Ok(AdyenPaymentMethod::TouchNGo(Box::new(touch_n_go_data)))}- domain::WalletData::MbWayRedirect(data) => {+ domain::WalletData::MbWayRedirect(_) => {+ let phone_details = item.get_billing_phone()?;let mbway_data = MbwayData {payment_type: PaymentType::Mbway,- telephone_number: data.telephone_number.clone(),+ telephone_number: phone_details.get_number_with_country_code()?,};Ok(AdyenPaymentMethod::Mbway(Box::new(mbway_data)))}@@ -3000,7 +3006,7 @@ impl<'a>let auth_type = AdyenAuthType::try_from(&item.router_data.connector_auth_type)?;let browser_info = get_browser_info(item.router_data)?;let additional_data = get_additional_data(item.router_data);- let payment_method = AdyenPaymentMethod::try_from(wallet_data)?;+ let payment_method = AdyenPaymentMethod::try_from((wallet_data, item.router_data))?;let shopper_interaction = AdyenShopperInteraction::from(item.router_data);let channel = get_channel_type(&item.router_data.request.payment_method_type);let (recurring_processing_model, store_payment_method, shopper_reference) =diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex 8254de9e3a..94539bd698 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -1152,6 +1152,7 @@ pub trait PhoneDetailsData {fn get_number(&self) -> Result<Secret<String>, Error>;fn get_country_code(&self) -> Result<String, Error>;fn get_number_with_country_code(&self) -> Result<Secret<String>, Error>;+ fn get_number_with_hash_country_code(&self) -> Result<Secret<String>, Error>;}impl PhoneDetailsData for api::PhoneDetails {@@ -1170,6 +1171,16 @@ impl PhoneDetailsData for api::PhoneDetails {let country_code = self.get_country_code()?;Ok(Secret::new(format!("{}{}", country_code, number.peek())))}+ fn get_number_with_hash_country_code(&self) -> Result<Secret<String>, Error> {+ let number = self.get_number()?;+ let country_code = self.get_country_code()?;+ let number_without_plus = country_code.trim_start_matches('+');+ Ok(Secret::new(format!(+ "{}#{}",+ number_without_plus,+ number.peek()+ )))+ }}pub trait AddressDetailsData {diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rsindex da22b1b3d1..746c100911 100644--- a/crates/router/src/types/domain/payments.rs+++ b/crates/router/src/types/domain/payments.rs@@ -190,10 +190,7 @@ pub struct GcashRedirection {}pub struct MobilePayRedirection {}#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]-pub struct MbWayRedirection {- /// Telephone number of the shopper. Should be Portuguese phone number.- pub telephone_number: Secret<String>,-}+pub struct MbWayRedirection {}#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize)]@@ -665,10 +662,8 @@ impl From<api_models::payments::WalletData> for WalletData {api_models::payments::WalletData::GooglePayThirdPartySdk(_) => {Self::GooglePayThirdPartySdk(Box::new(GooglePayThirdPartySdkData {}))}- api_models::payments::WalletData::MbWayRedirect(mbway_redirect_data) => {- Self::MbWayRedirect(Box::new(MbWayRedirection {- telephone_number: mbway_redirect_data.telephone_number,- }))+ api_models::payments::WalletData::MbWayRedirect(..) => {+ Self::MbWayRedirect(Box::new(MbWayRedirection {}))}api_models::payments::WalletData::MobilePayRedirect(_) => {Self::MobilePayRedirect(Box::new(MobilePayRedirection {}))diff --git a/crates/router/tests/connectors/aci.rs b/crates/router/tests/connectors/aci.rsindex 52f86f67b3..4da849c4e2 100644--- a/crates/router/tests/connectors/aci.rs+++ b/crates/router/tests/connectors/aci.rs@@ -1,6 +1,6 @@use std::{marker::PhantomData, str::FromStr};-use api_models::payments::{Address, AddressDetails};+use api_models::payments::{Address, AddressDetails, PhoneDetails};use masking::Secret;use router::{configs::settings::Settings,@@ -87,7 +87,10 @@ fn construct_payment_router_data() -> types::PaymentsAuthorizeRouterData {last_name: Some(Secret::new("Doe".to_string())),..Default::default()}),- phone: None,+ phone: Some(PhoneDetails {+ number: Some(Secret::new("8056594427".to_string())),+ country_code: Some("+351".to_string()),+ }),email: None,}),),diff --git a/crates/router/tests/connectors/adyen.rs b/crates/router/tests/connectors/adyen.rsindex b404f14ed3..4ecf73d533 100644--- a/crates/router/tests/connectors/adyen.rs+++ b/crates/router/tests/connectors/adyen.rs@@ -1,6 +1,6 @@use std::str::FromStr;-use api_models::payments::{Address, AddressDetails};+use api_models::payments::{Address, AddressDetails, PhoneDetails};use masking::Secret;use router::types::{self, storage::enums, PaymentAddress};@@ -65,7 +65,10 @@ impl AdyenTest {first_name: Some(Secret::new("John".to_string())),last_name: Some(Secret::new("Dough".to_string())),}),- phone: None,+ phone: Some(PhoneDetails {+ number: Some(Secret::new("8056594427".to_string())),+ country_code: Some("+351".to_string()),+ }),email: None,}),None,