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

refactor: updated HS<>UCS transformers for new flattened payment_method proto change (#10303)

gopikrishna0008695ff1017a8
diff --git a/Cargo.lock b/Cargo.lock
index a5e0000b18..894d170a7a 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -3789,7 +3789,7 @@ dependencies = [
[[package]]
name = "grpc-api-types"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
+source = "git+https://github.com/juspay/connector-service?rev=8edf9f744597c4f8712550a060a2bc1700c174d9#8edf9f744597c4f8712550a060a2bc1700c174d9"
dependencies = [
"axum 0.8.4",
"error-stack 0.5.0",
@@ -7427,7 +7427,7 @@ dependencies = [
[[package]]
name = "rust-grpc-client"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
+source = "git+https://github.com/juspay/connector-service?rev=8edf9f744597c4f8712550a060a2bc1700c174d9#8edf9f744597c4f8712550a060a2bc1700c174d9"
dependencies = [
"grpc-api-types",
]
@@ -10217,7 +10217,7 @@ checksum = "ed646292ffc8188ef8ea4d1e0e0150fb15a5c2e12ad9b8fc191ae7a8a7f3c4b9"
[[package]]
name = "ucs_cards"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
+source = "git+https://github.com/juspay/connector-service?rev=8edf9f744597c4f8712550a060a2bc1700c174d9#8edf9f744597c4f8712550a060a2bc1700c174d9"
dependencies = [
"bytes 1.10.1",
"error-stack 0.4.1",
@@ -10233,7 +10233,7 @@ dependencies = [
[[package]]
name = "ucs_common_enums"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
+source = "git+https://github.com/juspay/connector-service?rev=8edf9f744597c4f8712550a060a2bc1700c174d9#8edf9f744597c4f8712550a060a2bc1700c174d9"
dependencies = [
"serde",
"strum 0.26.3",
@@ -10244,7 +10244,7 @@ dependencies = [
[[package]]
name = "ucs_common_utils"
version = "0.1.0"
-source = "git+https://github.com/juspay/connector-service?rev=5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d#5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d"
+source = "git+https://github.com/juspay/connector-service?rev=8edf9f744597c4f8712550a060a2bc1700c174d9#8edf9f744597c4f8712550a060a2bc1700c174d9"
dependencies = [
"anyhow",
"base64 0.21.7",
diff --git a/crates/external_services/Cargo.toml b/crates/external_services/Cargo.toml
index 23825cc1f5..d99c6771a7 100644
--- a/crates/external_services/Cargo.toml
+++ b/crates/external_services/Cargo.toml
@@ -69,7 +69,7 @@ reqwest = { version = "0.11.27", features = ["rustls-tls"] }
http = "0.2.12"
url = { version = "2.5.4", features = ["serde"] }
quick-xml = { version = "0.31.0", features = ["serialize"] }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "8edf9f744597c4f8712550a060a2bc1700c174d9", package = "rust-grpc-client" }
open-feature = { version = "0.2.5", optional = true }
superposition_provider = { version = "0.88.1", optional = true }
diff --git a/crates/hyperswitch_interfaces/Cargo.toml b/crates/hyperswitch_interfaces/Cargo.toml
index 688f55d705..ad62e10fc2 100644
--- a/crates/hyperswitch_interfaces/Cargo.toml
+++ b/crates/hyperswitch_interfaces/Cargo.toml
@@ -29,7 +29,7 @@ serde_json = "1.0.140"
strum = { version = "0.26", features = ["derive"] }
thiserror = "1.0.69"
time = "0.3.41"
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "rust-grpc-client" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "8edf9f744597c4f8712550a060a2bc1700c174d9", package = "rust-grpc-client" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
tokio = { version = "1.45.1", features = ["macros", "rt-multi-thread"] }
# First party crates
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index cd5c3e2483..112f3b4389 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -89,8 +89,8 @@ reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "mult
ring = "0.17.14"
rust_decimal = { version = "1.37.1", features = ["serde-with-float", "serde-with-str"] }
rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" }
-unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "rust-grpc-client" }
-unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "5df0c7cde787b3d49ce222fb6ffbbe7932b0af4d", package = "ucs_cards" }
+unified-connector-service-client = { git = "https://github.com/juspay/connector-service", rev = "8edf9f744597c4f8712550a060a2bc1700c174d9", package = "rust-grpc-client" }
+unified-connector-service-cards = { git = "https://github.com/juspay/connector-service", rev = "8edf9f744597c4f8712550a060a2bc1700c174d9", package = "ucs_cards" }
unified-connector-service-masking = { git = "https://github.com/juspay/hyperswitch", tag = "2025.09.24.0", package = "masking" }
rustc-hash = "1.1.0"
rustls = "0.22"
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 723214c707..d37b0f709e 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -42,9 +42,8 @@ use masking::{ExposeInterface, PeekInterface, Secret};
use router_env::{instrument, logger, tracing};
use unified_connector_service_cards::CardNumber;
use unified_connector_service_client::payments::{
- self as payments_grpc, payment_method::PaymentMethod, wallet_payment_method_type::WalletType,
- CardDetails, CardPaymentMethodType, CryptoCurrency, CryptoCurrencyPaymentMethodType,
- PaymentServiceAuthorizeResponse, RewardPaymentMethodType, WalletPaymentMethodType,
+ self as payments_grpc, payment_method::PaymentMethod, CardDetails, ClassicReward,
+ CryptoCurrency, EVoucher, PaymentServiceAuthorizeResponse,
};
#[cfg(feature = "v2")]
@@ -747,7 +746,7 @@ pub async fn should_call_unified_connector_service_for_webhooks(
pub fn build_unified_connector_service_payment_method(
payment_method_data: hyperswitch_domain_models::payment_method_data::PaymentMethodData,
- payment_method_type: PaymentMethodType,
+ payment_method_type: Option<PaymentMethodType>,
) -> CustomResult<payments_grpc::PaymentMethod, UnifiedConnectorServiceError> {
match payment_method_data {
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Card(card) => {
@@ -786,25 +785,8 @@ pub fn build_unified_connector_service_payment_method(
card_issuing_country_alpha2: card.card_issuing_country.clone(),
};
- let grpc_card_type = match payment_method_type {
- PaymentMethodType::Credit => {
- payments_grpc::card_payment_method_type::CardType::Credit(card_details)
- }
- PaymentMethodType::Debit => {
- payments_grpc::card_payment_method_type::CardType::Debit(card_details)
- }
- _ => {
- return Err(UnifiedConnectorServiceError::NotImplemented(format!(
- "Unimplemented payment method subtype: {payment_method_type:?}"
- ))
- .into());
- }
- };
-
Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::Card(CardPaymentMethodType {
- card_type: Some(grpc_card_type),
- })),
+ payment_method: Some(PaymentMethod::Card(card_details)),
})
}
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Upi(upi_data) => {
@@ -844,14 +826,8 @@ pub fn build_unified_connector_service_payment_method(
};
Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::OnlineBanking(
- payments_grpc::OnlineBankingPaymentMethodType {
- online_banking_type: Some(
- payments_grpc::online_banking_payment_method_type::OnlineBankingType::OpenBankingUk(open_banking_uk)
- ),
- }
- )),
- })
+ payment_method: Some(PaymentMethod::OpenBankingUk(open_banking_uk)),
+ })
}
_ => Err(UnifiedConnectorServiceError::NotImplemented(format!(
"Unimplemented bank redirect type: {bank_redirect_data:?}"
@@ -860,17 +836,13 @@ pub fn build_unified_connector_service_payment_method(
},
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Reward => {
match payment_method_type {
- PaymentMethodType::ClassicReward => Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::Reward(RewardPaymentMethodType {
- reward_type: 1,
- })),
+ Some(PaymentMethodType::ClassicReward) => Ok(payments_grpc::PaymentMethod {
+ payment_method: Some(PaymentMethod::ClassicReward(ClassicReward {})),
}),
- PaymentMethodType::Evoucher => Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::Reward(RewardPaymentMethodType {
- reward_type: 2,
- })),
+ Some(PaymentMethodType::Evoucher) => Ok(payments_grpc::PaymentMethod {
+ payment_method: Some(PaymentMethod::EVoucher(EVoucher {})),
}),
- _ => Err(UnifiedConnectorServiceError::NotImplemented(format!(
+ None | Some(_) => Err(UnifiedConnectorServiceError::NotImplemented(format!(
"Unimplemented payment method subtype: {payment_method_type:?}"
))
.into()),
@@ -881,13 +853,45 @@ pub fn build_unified_connector_service_payment_method(
hyperswitch_domain_models::payment_method_data::WalletData::Mifinity(
mifinity_data,
) => Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::Wallet(WalletPaymentMethodType {
- wallet_type: Some(WalletType::Mifinity(payments_grpc::MifinityWallet {
- date_of_birth: Some(
- mifinity_data.date_of_birth.peek().to_string().into(),
- ),
- language_preference: mifinity_data.language_preference,
- })),
+ payment_method: Some(PaymentMethod::Mifinity(payments_grpc::MifinityWallet {
+ date_of_birth: Some(mifinity_data.date_of_birth.peek().to_string().into()),
+ language_preference: mifinity_data.language_preference,
+ })),
+ }),
+ hyperswitch_domain_models::payment_method_data::WalletData::ApplePay(
+ apple_pay_wallet_data
+ ) => Ok(payments_grpc::PaymentMethod {
+ payment_method: Some(PaymentMethod::ApplePay(payments_grpc::AppleWallet {
+ payment_data: Some(payments_grpc::apple_wallet::PaymentData {
+ payment_data: Some(payments_grpc::apple_wallet::payment_data::PaymentData::foreign_try_from(&apple_pay_wallet_data.payment_data)?),
+ }),
+ payment_method: Some(payments_grpc::apple_wallet::PaymentMethod {
+ display_name: apple_pay_wallet_data.payment_method.display_name,
+ network: apple_pay_wallet_data.payment_method.network,
+ r#type: apple_pay_wallet_data.payment_method.pm_type,
+ }),
+ transaction_identifier: apple_pay_wallet_data.transaction_identifier,
+ })),
+ }),
+ hyperswitch_domain_models::payment_method_data::WalletData::GooglePay(
+ google_pay_wallet_data,
+ ) => Ok(payments_grpc::PaymentMethod {
+ payment_method: Some(PaymentMethod::GooglePay(payments_grpc::GoogleWallet {
+ r#type: google_pay_wallet_data.pm_type,
+ description: google_pay_wallet_data.description,
+ info: Some(payments_grpc::google_wallet::PaymentMethodInfo {
+ card_network: google_pay_wallet_data.info.card_network,
+ card_details: google_pay_wallet_data.info.card_details,
+ assurance_details: google_pay_wallet_data.info.assurance_details.map(|details| {
+ payments_grpc::google_wallet::payment_method_info::AssuranceDetails {
+ card_holder_authenticated: details.card_holder_authenticated,
+ account_verified: details.account_verified,
+ }
+ }),
+ }),
+ tokenization_data: Some(payments_grpc::google_wallet::TokenizationData {
+ tokenization_data: Some(payments_grpc::google_wallet::tokenization_data::TokenizationData::foreign_try_from(&google_pay_wallet_data.tokenization_data)?),
+ }),
})),
}),
_ => Err(UnifiedConnectorServiceError::NotImplemented(format!(
@@ -898,11 +902,9 @@ pub fn build_unified_connector_service_payment_method(
}
hyperswitch_domain_models::payment_method_data::PaymentMethodData::Crypto(crypto_data) => {
Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::Crypto(CryptoCurrencyPaymentMethodType {
- crypto_currency: Some(CryptoCurrency {
- pay_currency: crypto_data.pay_currency.clone(),
- network: crypto_data.network.clone(),
- }),
+ payment_method: Some(PaymentMethod::Crypto(CryptoCurrency {
+ pay_currency: crypto_data.pay_currency.clone(),
+ network: crypto_data.network.clone(),
})),
})
}
@@ -915,7 +917,7 @@ pub fn build_unified_connector_service_payment_method(
pub fn build_unified_connector_service_payment_method_for_external_proxy(
payment_method_data: hyperswitch_domain_models::payment_method_data::ExternalVaultPaymentMethodData,
- payment_method_type: PaymentMethodType,
+ payment_method_type: Option<PaymentMethodType>,
) -> CustomResult<payments_grpc::PaymentMethod, UnifiedConnectorServiceError> {
match payment_method_data {
hyperswitch_domain_models::payment_method_data::ExternalVaultPaymentMethodData::Card(
@@ -941,24 +943,9 @@ pub fn build_unified_connector_service_payment_method_for_external_proxy(
nick_name: external_vault_card.nick_name.map(|n| n.expose()),
card_issuing_country_alpha2: external_vault_card.card_issuing_country.clone(),
};
- let grpc_card_type = match payment_method_type {
- PaymentMethodType::Credit => {
- payments_grpc::card_payment_method_type::CardType::CreditProxy(card_details)
- }
- PaymentMethodType::Debit => {
- payments_grpc::card_payment_method_type::CardType::DebitProxy(card_details)
- }
- _ => {
- return Err(UnifiedConnectorServiceError::NotImplemented(format!(
- "Unimplemented payment method subtype: {payment_method_type:?}"
- ))
- .into());
- }
- };
+
Ok(payments_grpc::PaymentMethod {
- payment_method: Some(PaymentMethod::Card(CardPaymentMethodType {
- card_type: Some(grpc_card_type),
- })),
+ payment_method: Some(PaymentMethod::CardProxy(card_details)),
})
}
hyperswitch_domain_models::payment_method_data::ExternalVaultPaymentMethodData::VaultToken(_) => {
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index c263e710c9..ece6b2a19d 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -29,6 +29,7 @@ pub use hyperswitch_interfaces::{
};
use masking::{ExposeInterface, PeekInterface};
use router_env::tracing;
+use unified_connector_service_cards::CardNumber;
use unified_connector_service_client::payments::{
self as payments_grpc, ConnectorState, Identifier, PaymentServiceTransformRequest,
PaymentServiceTransformResponse,
@@ -81,16 +82,12 @@ impl
) -> Result<Self, Self::Error> {
let currency = payments_grpc::Currency::foreign_try_from(router_data.request.currency)?;
- let payment_method = router_data
- .request
- .payment_method_type
- .map(|payment_method_type| {
- unified_connector_service::build_unified_connector_service_payment_method(
- router_data.request.payment_method_data.clone(),
- payment_method_type,
- )
- })
- .transpose()?;
+ let payment_method = Some(
+ unified_connector_service::build_unified_connector_service_payment_method(
+ router_data.request.payment_method_data.clone(),
+ router_data.request.payment_method_type,
+ )?,
+ );
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
@@ -274,16 +271,6 @@ impl
})
.ok();
- let encoded_data = router_data
- .request
- .encoded_data
- .as_ref()
- .map(|data| Identifier {
- id_type: Some(payments_grpc::identifier::IdType::EncodedData(
- data.to_string(),
- )),
- });
-
let connector_ref_id = router_data
.request
.connector_reference_id
@@ -320,7 +307,8 @@ impl
.map(ConnectorState::foreign_from);
Ok(Self {
- transaction_id: connector_transaction_id.or(encoded_data),
+ transaction_id: connector_transaction_id,
+ encoded_data: router_data.request.encoded_data.clone(),
request_ref_id: connector_ref_id,
capture_method: capture_method.map(|capture_method| capture_method.into()),
handle_response,
@@ -393,14 +381,14 @@ impl
router_data.request.currency.unwrap_or_default(),
)?;
- let payment_method_type = router_data.request.payment_method_type;
- let payment_method_data = router_data.request.payment_method_data.as_ref();
- let payment_method = payment_method_data
- .zip(payment_method_type)
- .map(|(payment_method_data, payment_method_type)| {
+ let payment_method = router_data
+ .request
+ .payment_method_data
+ .clone()
+ .map(|payment_method_data| {
unified_connector_service::build_unified_connector_service_payment_method(
- payment_method_data.clone(),
- payment_method_type,
+ payment_method_data,
+ router_data.request.payment_method_type,
)
})
.transpose()?;
@@ -483,14 +471,15 @@ impl
)?;
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
- let payment_method_type = router_data.request.payment_method_type;
- let payment_method_data = router_data.request.payment_method_data.as_ref();
- let payment_method = payment_method_data
- .zip(payment_method_type)
- .map(|(payment_method_data, payment_method_type)| {
+
+ let payment_method = router_data
+ .request
+ .payment_method_data
+ .clone()
+ .map(|payment_method_data| {
unified_connector_service::build_unified_connector_service_payment_method(
- payment_method_data.clone(),
- payment_method_type,
+ payment_method_data,
+ router_data.request.payment_method_type,
)
})
.transpose()?;
@@ -570,16 +559,12 @@ impl
router_data.request.currency.unwrap_or_default(),
)?;
- let payment_method = router_data
- .request
- .payment_method_type
- .map(|payment_method_type| {
- unified_connector_service::build_unified_connector_service_payment_method(
- router_data.request.payment_method_data.clone(),
- payment_method_type,
- )
- })
- .transpose()?;
+ let payment_method = Some(
+ unified_connector_service::build_unified_connector_service_payment_method(
+ router_data.request.payment_method_data.clone(),
+ router_data.request.payment_method_type,
+ )?,
+ );
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
let merchant_account_metadata = router_data
@@ -725,14 +710,14 @@ impl
) -> Result<Self, Self::Error> {
let currency = payments_grpc::Currency::foreign_try_from(router_data.request.currency)?;
- let payment_method_type = router_data.request.payment_method_type;
- let payment_method_data = router_data.request.payment_method_data.as_ref();
- let payment_method = payment_method_data
- .zip(payment_method_type)
- .map(|(payment_method_data, payment_method_type)| {
+ let payment_method = router_data
+ .request
+ .payment_method_data
+ .clone()
+ .map(|payment_method_data| {
unified_connector_service::build_unified_connector_service_payment_method(
- payment_method_data.clone(),
- payment_method_type,
+ payment_method_data,
+ router_data.request.payment_method_type,
)
})
.transpose()?;
@@ -856,16 +841,12 @@ impl
) -> Result<Self, Self::Error> {
let currency = payments_grpc::Currency::foreign_try_from(router_data.request.currency)?;
- let payment_method = router_data
- .request
- .payment_method_type
- .map(|payment_method_type| {
- unified_connector_service::build_unified_connector_service_payment_method(
- router_data.request.payment_method_data.clone(),
- payment_method_type,
- )
- })
- .transpose()?;
+ let payment_method = Some(
+ unified_connector_service::build_unified_connector_service_payment_method(
+ router_data.request.payment_method_data.clone(),
+ router_data.request.payment_method_type,
+ )?,
+ );
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
@@ -1029,16 +1010,12 @@ impl
) -> Result<Self, Self::Error> {
let currency = payments_grpc::Currency::foreign_try_from(router_data.request.currency)?;
- let payment_method = router_data
- .request
- .payment_method_type
- .map(|payment_method_type| {
- unified_connector_service::build_unified_connector_service_payment_method_for_external_proxy(
- router_data.request.payment_method_data.clone(),
- payment_method_type,
- )
- })
- .transpose()?;
+ let payment_method = Some(
+ unified_connector_service::build_unified_connector_service_payment_method_for_external_proxy(
+ router_data.request.payment_method_data.clone(),
+ router_data.request.payment_method_type,
+ )?
+ );
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
@@ -1189,16 +1166,12 @@ impl
router_data: &RouterData<SetupMandate, SetupMandateRequestData, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let currency = payments_grpc::Currency::foreign_try_from(router_data.request.currency)?;
- let payment_method = router_data
- .request
- .payment_method_type
- .map(|payment_method_type| {
- unified_connector_service::build_unified_connector_service_payment_method(
- router_data.request.payment_method_data.clone(),
- payment_method_type,
- )
- })
- .transpose()?;
+ let payment_method = Some(
+ unified_connector_service::build_unified_connector_service_payment_method(
+ router_data.request.payment_method_data.clone(),
+ router_data.request.payment_method_type,
+ )?,
+ );
let address = payments_grpc::PaymentAddress::foreign_try_from(router_data.address.clone())?;
let auth_type = payments_grpc::AuthenticationType::foreign_try_from(router_data.auth_type)?;
let browser_info = router_data
@@ -1959,6 +1932,103 @@ impl transformers::ForeignTryFrom<common_enums::CardNetwork> for payments_grpc::
}
}
+impl transformers::ForeignTryFrom<&common_types::payments::ApplePayPaymentData>
+ for payments_grpc::apple_wallet::payment_data::PaymentData
+{
+ type Error = error_stack::Report<UnifiedConnectorServiceError>;
+
+ fn foreign_try_from(
+ payment_data: &common_types::payments::ApplePayPaymentData,
+ ) -> Result<Self, Self::Error> {
+ match payment_data {
+ common_types::payments::ApplePayPaymentData::Encrypted(encrypted_data) => {
+ Ok(Self::EncryptedData(encrypted_data.clone()))
+ }
+ common_types::payments::ApplePayPaymentData::Decrypted(decrypted_data) => {
+ let application_primary_account_number = CardNumber::from_str(
+ &decrypted_data
+ .application_primary_account_number
+ .get_card_no(),
+ )
+ .change_context(
+ UnifiedConnectorServiceError::RequestEncodingFailedWithReason(
+ "Failed to parse card number".to_string(),
+ ),
+ )?;
+ Ok(Self::DecryptedData(payments_grpc::ApplePayPredecryptData {
+ application_primary_account_number: Some(application_primary_account_number),
+ application_expiration_month: Some(
+ decrypted_data
+ .application_expiration_month
+ .clone()
+ .expose()
+ .into(),
+ ),
+ application_expiration_year: Some(
+ decrypted_data
+ .application_expiration_year
+ .clone()
+ .expose()
+ .into(),
+ ),
+ payment_data: Some(payments_grpc::ApplePayCryptogramData {
+ online_payment_cryptogram: Some(
+ decrypted_data
+ .payment_data
+ .online_payment_cryptogram
+ .clone()
+ .expose()
+ .into(),
+ ),
+ eci_indicator: decrypted_data.payment_data.eci_indicator.clone(),
+ }),
+ }))
+ }
+ }
+ }
+}
+
+impl transformers::ForeignTryFrom<&common_types::payments::GpayTokenizationData>
+ for payments_grpc::google_wallet::tokenization_data::TokenizationData
+{
+ type Error = error_stack::Report<UnifiedConnectorServiceError>;
+
+ fn foreign_try_from(
+ tokenization_data: &common_types::payments::GpayTokenizationData,
+ ) -> Result<Self, Self::Error> {
+ match tokenization_data {
+ common_types::payments::GpayTokenizationData::Encrypted(encrypted_data) => Ok(
+ Self::EncryptedData(payments_grpc::GpayEncryptedTokenizationData {
+ token_type: encrypted_data.token_type.clone(),
+ token: encrypted_data.token.clone(),
+ }),
+ ),
+ common_types::payments::GpayTokenizationData::Decrypted(decrypted_data) => {
+ let application_primary_account_number = CardNumber::from_str(
+ &decrypted_data
+ .application_primary_account_number
+ .get_card_no(),
+ )
+ .change_context(
+ UnifiedConnectorServiceError::RequestEncodingFailedWithReason(
+ "Failed to parse card number".to_string(),
+ ),
+ )?;
+ Ok(Self::DecryptedData(payments_grpc::GPayPredecryptData {
+ card_exp_month: Some(decrypted_data.card_exp_month.clone().expose().into()),
+ card_exp_year: Some(decrypted_data.card_exp_year.clone().expose().into()),
+ application_primary_account_number: Some(application_primary_account_number),
+ cryptogram: decrypted_data
+ .cryptogram
+ .clone()
+ .map(|cryptogram| cryptogram.expose().into()),
+ eci_indicator: decrypted_data.eci_indicator.clone(),
+ }))
+ }
+ }
+ }
+}
+
impl transformers::ForeignTryFrom<hyperswitch_domain_models::payment_address::PaymentAddress>
for payments_grpc::PaymentAddress
{
@@ -2837,6 +2907,17 @@ impl transformers::ForeignTryFrom<&RouterData<Execute, RefundsData, RefundsRespo
.as_ref()
.map(ConnectorState::foreign_from);
+ let merchant_account_metadata = router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|val| val.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default();
+
Ok(Self {
request_ref_id,
refund_id: router_data.request.refund_id.clone(),
@@ -2878,6 +2959,7 @@ impl transformers::ForeignTryFrom<&RouterData<Execute, RefundsData, RefundsRespo
)
})?,
state,
+ merchant_account_metadata,
})
}
}
@@ -2908,6 +2990,17 @@ impl transformers::ForeignTryFrom<&RouterData<RSync, RefundsData, RefundsRespons
.as_ref()
.map(ConnectorState::foreign_from);
+ let merchant_account_metadata = router_data
+ .connector_meta_data
+ .as_ref()
+ .and_then(|val| val.peek().as_object())
+ .map(|map| {
+ map.iter()
+ .filter_map(|(k, v)| v.as_str().map(|s| (k.clone(), s.to_string())))
+ .collect::<HashMap<String, String>>()
+ })
+ .unwrap_or_default();
+
Ok(Self {
request_ref_id,
transaction_id: Some(transaction_id),
@@ -2929,6 +3022,7 @@ impl transformers::ForeignTryFrom<&RouterData<RSync, RefundsData, RefundsRespons
)
})?,
state,
+ merchant_account_metadata,
refund_metadata: router_data
.request
.refund_connector_metadata