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

fix(samsung_pay): populate `payment_method_data` in the payment response (#7095)

Shankar Singh C04a5e3823671
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index 236c0af3a3..b315800b08 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -21493,8 +21493,7 @@
"type": "object",
"required": [
"last4",
- "card_network",
- "type"
+ "card_network"
],
"properties": {
"last4": {
@@ -21507,7 +21506,8 @@
},
"type": {
"type": "string",
- "description": "The type of payment method"
+ "description": "The type of payment method",
+ "nullable": true
}
}
},
@@ -21864,6 +21864,17 @@
"$ref": "#/components/schemas/WalletAdditionalDataForCard"
}
}
+ },
+ {
+ "type": "object",
+ "required": [
+ "samsung_pay"
+ ],
+ "properties": {
+ "samsung_pay": {
+ "$ref": "#/components/schemas/WalletAdditionalDataForCard"
+ }
+ }
}
],
"description": "Hyperswitch supports SDK integration with Apple Pay and Google Pay wallets. For other wallets, we integrate with their respective connectors, redirecting the customer to the connector for wallet payments. As a result, we don’t receive any payment method data in the confirm call for payments made through other wallets."
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 9b840f5313..0aa2c898fc 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -26102,8 +26102,7 @@
"type": "object",
"required": [
"last4",
- "card_network",
- "type"
+ "card_network"
],
"properties": {
"last4": {
@@ -26116,7 +26115,8 @@
},
"type": {
"type": "string",
- "description": "The type of payment method"
+ "description": "The type of payment method",
+ "nullable": true
}
}
},
@@ -26473,6 +26473,17 @@
"$ref": "#/components/schemas/WalletAdditionalDataForCard"
}
}
+ },
+ {
+ "type": "object",
+ "required": [
+ "samsung_pay"
+ ],
+ "properties": {
+ "samsung_pay": {
+ "$ref": "#/components/schemas/WalletAdditionalDataForCard"
+ }
+ }
}
],
"description": "Hyperswitch supports SDK integration with Apple Pay and Google Pay wallets. For other wallets, we integrate with their respective connectors, redirecting the customer to the connector for wallet payments. As a result, we don’t receive any payment method data in the confirm call for payments made through other wallets."
diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs
index 82a7abc6ef..12bb97d9b7 100644
--- a/crates/api_models/src/payment_methods.rs
+++ b/crates/api_models/src/payment_methods.rs
@@ -829,7 +829,7 @@ pub struct PaymentMethodDataWalletInfo {
pub card_network: String,
/// The type of payment method
#[serde(rename = "type")]
- pub card_type: String,
+ pub card_type: Option<String>,
}
impl From<payments::additional_info::WalletAdditionalDataForCard> for PaymentMethodDataWalletInfo {
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 2c0a09bf8f..2c8723857a 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -2601,6 +2601,7 @@ pub enum AdditionalPaymentData {
Wallet {
apple_pay: Option<ApplepayPaymentMethod>,
google_pay: Option<additional_info::WalletAdditionalDataForCard>,
+ samsung_pay: Option<additional_info::WalletAdditionalDataForCard>,
},
PayLater {
klarna_sdk: Option<KlarnaSdkPaymentMethod>,
@@ -3874,6 +3875,8 @@ pub enum WalletResponseData {
ApplePay(Box<additional_info::WalletAdditionalDataForCard>),
#[schema(value_type = WalletAdditionalDataForCard)]
GooglePay(Box<additional_info::WalletAdditionalDataForCard>),
+ #[schema(value_type = WalletAdditionalDataForCard)]
+ SamsungPay(Box<additional_info::WalletAdditionalDataForCard>),
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
@@ -5410,8 +5413,9 @@ impl From<AdditionalPaymentData> for PaymentMethodDataResponse {
AdditionalPaymentData::Wallet {
apple_pay,
google_pay,
- } => match (apple_pay, google_pay) {
- (Some(apple_pay_pm), _) => Self::Wallet(Box::new(WalletResponse {
+ samsung_pay,
+ } => match (apple_pay, google_pay, samsung_pay) {
+ (Some(apple_pay_pm), _, _) => Self::Wallet(Box::new(WalletResponse {
details: Some(WalletResponseData::ApplePay(Box::new(
additional_info::WalletAdditionalDataForCard {
last4: apple_pay_pm
@@ -5425,13 +5429,16 @@ impl From<AdditionalPaymentData> for PaymentMethodDataResponse {
.rev()
.collect::<String>(),
card_network: apple_pay_pm.network.clone(),
- card_type: apple_pay_pm.pm_type.clone(),
+ card_type: Some(apple_pay_pm.pm_type.clone()),
},
))),
})),
- (_, Some(google_pay_pm)) => Self::Wallet(Box::new(WalletResponse {
+ (_, Some(google_pay_pm), _) => Self::Wallet(Box::new(WalletResponse {
details: Some(WalletResponseData::GooglePay(Box::new(google_pay_pm))),
})),
+ (_, _, Some(samsung_pay_pm)) => Self::Wallet(Box::new(WalletResponse {
+ details: Some(WalletResponseData::SamsungPay(Box::new(samsung_pay_pm))),
+ })),
_ => Self::Wallet(Box::new(WalletResponse { details: None })),
},
AdditionalPaymentData::BankRedirect { bank_name, details } => {
diff --git a/crates/api_models/src/payments/additional_info.rs b/crates/api_models/src/payments/additional_info.rs
index 9e8c910cba..769e98214f 100644
--- a/crates/api_models/src/payments/additional_info.rs
+++ b/crates/api_models/src/payments/additional_info.rs
@@ -219,5 +219,5 @@ pub struct WalletAdditionalDataForCard {
pub card_network: String,
/// The type of payment method
#[serde(rename = "type")]
- pub card_type: String,
+ pub card_type: Option<String>,
}
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index 8c19a20ef3..dcf4696417 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -1718,7 +1718,7 @@ impl From<GooglePayWalletData> for payment_methods::PaymentMethodDataWalletInfo
Self {
last4: item.info.card_details,
card_network: item.info.card_network,
- card_type: item.pm_type,
+ card_type: Some(item.pm_type),
}
}
}
diff --git a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
index 59a703d2b3..da93a14dc9 100644
--- a/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
+++ b/crates/router/src/core/fraud_check/operation/fraud_check_pre.rs
@@ -239,7 +239,7 @@ where
connector: router_data.connector,
payment_id: router_data.payment_id.clone(),
attempt_id: router_data.attempt_id,
- request: FrmRequest::Checkout(FraudCheckCheckoutData {
+ request: FrmRequest::Checkout(Box::new(FraudCheckCheckoutData {
amount: router_data.request.amount,
order_details: router_data.request.order_details,
currency: router_data.request.currency,
@@ -247,7 +247,7 @@ where
payment_method_data: router_data.request.payment_method_data,
email: router_data.request.email,
gateway: router_data.request.gateway,
- }),
+ })),
response: FrmResponse::Checkout(router_data.response),
})
}
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 6e85db9843..3833d316be 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4671,6 +4671,7 @@ pub async fn get_additional_payment_data(
pm_type: apple_pay_wallet_data.payment_method.pm_type.clone(),
}),
google_pay: None,
+ samsung_pay: None,
}))
}
domain::WalletData::GooglePay(google_pay_pm_data) => {
@@ -4679,13 +4680,32 @@ pub async fn get_additional_payment_data(
google_pay: Some(payment_additional_types::WalletAdditionalDataForCard {
last4: google_pay_pm_data.info.card_details.clone(),
card_network: google_pay_pm_data.info.card_network.clone(),
- card_type: google_pay_pm_data.pm_type.clone(),
+ card_type: Some(google_pay_pm_data.pm_type.clone()),
+ }),
+ samsung_pay: None,
+ }))
+ }
+ domain::WalletData::SamsungPay(samsung_pay_pm_data) => {
+ Ok(Some(api_models::payments::AdditionalPaymentData::Wallet {
+ apple_pay: None,
+ google_pay: None,
+ samsung_pay: Some(payment_additional_types::WalletAdditionalDataForCard {
+ last4: samsung_pay_pm_data
+ .payment_credential
+ .card_last_four_digits
+ .clone(),
+ card_network: samsung_pay_pm_data
+ .payment_credential
+ .card_brand
+ .to_string(),
+ card_type: None,
}),
}))
}
_ => Ok(Some(api_models::payments::AdditionalPaymentData::Wallet {
apple_pay: None,
google_pay: None,
+ samsung_pay: None,
})),
},
domain::PaymentMethodData::PayLater(_) => Ok(Some(
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 2bb751d4e1..ed5c93489c 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -1178,6 +1178,14 @@ impl PaymentCreate {
Some(api_models::payments::AdditionalPaymentData::Wallet {
apple_pay: None,
google_pay: Some(wallet.into()),
+ samsung_pay: None,
+ })
+ }
+ Some(enums::PaymentMethodType::SamsungPay) => {
+ Some(api_models::payments::AdditionalPaymentData::Wallet {
+ apple_pay: None,
+ google_pay: None,
+ samsung_pay: Some(wallet.into()),
})
}
_ => None,
diff --git a/crates/router/src/types/fraud_check.rs b/crates/router/src/types/fraud_check.rs
index a861aca67d..386c8a9cd9 100644
--- a/crates/router/src/types/fraud_check.rs
+++ b/crates/router/src/types/fraud_check.rs
@@ -29,7 +29,7 @@ pub struct FrmRouterData {
#[derive(Debug, Clone)]
pub enum FrmRequest {
Sale(FraudCheckSaleData),
- Checkout(FraudCheckCheckoutData),
+ Checkout(Box<FraudCheckCheckoutData>),
Transaction(FraudCheckTransactionData),
Fulfillment(FraudCheckFulfillmentData),
RecordReturn(FraudCheckRecordReturnData),