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
feat(router): add support for Samsung pay app tokens flow (#6257)
Shankar Singh Cf6b0b98e0a6c
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.jsonindex 3f57faaf1d..0d06e2230b 100644--- a/api-reference-v2/openapi_spec.json+++ b/api-reference-v2/openapi_spec.json@@ -19018,6 +19018,61 @@"FORMAT_TOTAL_ESTIMATED_AMOUNT"]},+ "SamsungPayAppWalletData": {+ "type": "object",+ "required": [+ "3_d_s",+ "payment_card_brand",+ "payment_currency_type",+ "payment_last4_fpan"+ ],+ "properties": {+ "3_d_s": {+ "$ref": "#/components/schemas/SamsungPayTokenData"+ },+ "payment_card_brand": {+ "$ref": "#/components/schemas/SamsungPayCardBrand"+ },+ "payment_currency_type": {+ "type": "string",+ "description": "Currency type of the payment"+ },+ "payment_last4_dpan": {+ "type": "string",+ "description": "Last 4 digits of the device specific card number",+ "nullable": true+ },+ "payment_last4_fpan": {+ "type": "string",+ "description": "Last 4 digits of the card number"+ },+ "merchant_ref": {+ "type": "string",+ "description": "Merchant reference id that was passed in the session call request",+ "nullable": true+ },+ "method": {+ "type": "string",+ "description": "Specifies authentication method used",+ "nullable": true+ },+ "recurring_payment": {+ "type": "boolean",+ "description": "Value if credential is enabled for recurring payment",+ "nullable": true+ }+ }+ },+ "SamsungPayCardBrand": {+ "type": "string",+ "enum": [+ "visa",+ "mastercard",+ "amex",+ "discover",+ "unknown"+ ]+ },"SamsungPayMerchantPaymentInformation": {"type": "object","required": [@@ -19110,6 +19165,27 @@}},"SamsungPayWalletCredentials": {+ "oneOf": [+ {+ "$ref": "#/components/schemas/SamsungPayWebWalletData"+ },+ {+ "$ref": "#/components/schemas/SamsungPayAppWalletData"+ }+ ]+ },+ "SamsungPayWalletData": {+ "type": "object",+ "required": [+ "payment_credential"+ ],+ "properties": {+ "payment_credential": {+ "$ref": "#/components/schemas/SamsungPayWalletCredentials"+ }+ }+ },+ "SamsungPayWebWalletData": {"type": "object","required": ["card_brand",@@ -19128,8 +19204,7 @@"nullable": true},"card_brand": {- "type": "string",- "description": "Brand of the payment card"+ "$ref": "#/components/schemas/SamsungPayCardBrand"},"card_last4digits": {"type": "string",@@ -19140,17 +19215,6 @@}}},- "SamsungPayWalletData": {- "type": "object",- "required": [- "payment_credential"- ],- "properties": {- "payment_credential": {- "$ref": "#/components/schemas/SamsungPayWalletCredentials"- }- }- },"SdkInformation": {"type": "object","description": "SDK Information if request is from SDK",diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex 4b10cf3299..d01a51f6d5 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -22780,6 +22780,61 @@"FORMAT_TOTAL_ESTIMATED_AMOUNT"]},+ "SamsungPayAppWalletData": {+ "type": "object",+ "required": [+ "3_d_s",+ "payment_card_brand",+ "payment_currency_type",+ "payment_last4_fpan"+ ],+ "properties": {+ "3_d_s": {+ "$ref": "#/components/schemas/SamsungPayTokenData"+ },+ "payment_card_brand": {+ "$ref": "#/components/schemas/SamsungPayCardBrand"+ },+ "payment_currency_type": {+ "type": "string",+ "description": "Currency type of the payment"+ },+ "payment_last4_dpan": {+ "type": "string",+ "description": "Last 4 digits of the device specific card number",+ "nullable": true+ },+ "payment_last4_fpan": {+ "type": "string",+ "description": "Last 4 digits of the card number"+ },+ "merchant_ref": {+ "type": "string",+ "description": "Merchant reference id that was passed in the session call request",+ "nullable": true+ },+ "method": {+ "type": "string",+ "description": "Specifies authentication method used",+ "nullable": true+ },+ "recurring_payment": {+ "type": "boolean",+ "description": "Value if credential is enabled for recurring payment",+ "nullable": true+ }+ }+ },+ "SamsungPayCardBrand": {+ "type": "string",+ "enum": [+ "visa",+ "mastercard",+ "amex",+ "discover",+ "unknown"+ ]+ },"SamsungPayMerchantPaymentInformation": {"type": "object","required": [@@ -22872,6 +22927,27 @@}},"SamsungPayWalletCredentials": {+ "oneOf": [+ {+ "$ref": "#/components/schemas/SamsungPayWebWalletData"+ },+ {+ "$ref": "#/components/schemas/SamsungPayAppWalletData"+ }+ ]+ },+ "SamsungPayWalletData": {+ "type": "object",+ "required": [+ "payment_credential"+ ],+ "properties": {+ "payment_credential": {+ "$ref": "#/components/schemas/SamsungPayWalletCredentials"+ }+ }+ },+ "SamsungPayWebWalletData": {"type": "object","required": ["card_brand",@@ -22890,8 +22966,7 @@"nullable": true},"card_brand": {- "type": "string",- "description": "Brand of the payment card"+ "$ref": "#/components/schemas/SamsungPayCardBrand"},"card_last4digits": {"type": "string",@@ -22902,17 +22977,6 @@}}},- "SamsungPayWalletData": {- "type": "object",- "required": [- "payment_credential"- ],- "properties": {- "payment_credential": {- "$ref": "#/components/schemas/SamsungPayWalletCredentials"- }- }- },"SdkInformation": {"type": "object","description": "SDK Information if request is from SDK",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex c7c998cc2b..87152c5c17 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -2925,15 +2925,56 @@ pub struct SamsungPayWalletData {pub payment_credential: SamsungPayWalletCredentials,}+#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]+#[serde(rename_all = "snake_case", untagged)]+pub enum SamsungPayWalletCredentials {+ SamsungPayWalletDataForWeb(SamsungPayWebWalletData),+ SamsungPayWalletDataForApp(SamsungPayAppWalletData),+}++impl From<SamsungPayCardBrand> for common_enums::SamsungPayCardBrand {+ fn from(samsung_pay_card_brand: SamsungPayCardBrand) -> Self {+ match samsung_pay_card_brand {+ SamsungPayCardBrand::Visa => Self::Visa,+ SamsungPayCardBrand::MasterCard => Self::MasterCard,+ SamsungPayCardBrand::Amex => Self::Amex,+ SamsungPayCardBrand::Discover => Self::Discover,+ SamsungPayCardBrand::Unknown => Self::Unknown,+ }+ }+}++#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]+#[serde(rename_all = "snake_case")]+pub struct SamsungPayAppWalletData {+ /// Samsung Pay token data+ #[serde(rename = "3_d_s")]+ pub token_data: SamsungPayTokenData,+ /// Brand of the payment card+ pub payment_card_brand: SamsungPayCardBrand,+ /// Currency type of the payment+ pub payment_currency_type: String,+ /// Last 4 digits of the device specific card number+ pub payment_last4_dpan: Option<String>,+ /// Last 4 digits of the card number+ pub payment_last4_fpan: String,+ /// Merchant reference id that was passed in the session call request+ pub merchant_ref: Option<String>,+ /// Specifies authentication method used+ pub method: Option<String>,+ /// Value if credential is enabled for recurring payment+ pub recurring_payment: Option<bool>,+}+#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]#[serde(rename_all = "snake_case")]-pub struct SamsungPayWalletCredentials {+pub struct SamsungPayWebWalletData {/// Specifies authentication method usedpub method: Option<String>,/// Value if credential is enabled for recurring paymentpub recurring_payment: Option<bool>,/// Brand of the payment card- pub card_brand: String,+ pub card_brand: SamsungPayCardBrand,/// Last 4 digits of the card number#[serde(rename = "card_last4digits")]pub card_last_four_digits: String,@@ -2955,6 +2996,21 @@ pub struct SamsungPayTokenData {pub data: Secret<String>,}+#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]+#[serde(rename_all = "lowercase")]+pub enum SamsungPayCardBrand {+ #[serde(alias = "VI")]+ Visa,+ #[serde(alias = "MC")]+ MasterCard,+ #[serde(alias = "AX")]+ Amex,+ #[serde(alias = "DC")]+ Discover,+ #[serde(other)]+ Unknown,+}+#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]#[serde(rename_all = "snake_case")]pub enum OpenBankingData {diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rsindex 5ab05c9a68..4601a818fb 100644--- a/crates/common_enums/src/enums.rs+++ b/crates/common_enums/src/enums.rs@@ -1509,6 +1509,16 @@ pub enum PaymentExperience {DisplayWaitScreen,}+#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display)]+#[serde(rename_all = "lowercase")]+pub enum SamsungPayCardBrand {+ Visa,+ MasterCard,+ Amex,+ Discover,+ Unknown,+}+/// Indicates the sub type of payment method. Eg: 'google_pay' & 'apple_pay' for wallets.#[derive(Clone,diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rsindex 5c4979ab49..e5f5fad990 100644--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs@@ -214,7 +214,8 @@ pub struct SamsungPayWalletData {pub struct SamsungPayWalletCredentials {pub method: Option<String>,pub recurring_payment: Option<bool>,- pub card_brand: String,+ pub card_brand: common_enums::SamsungPayCardBrand,+ pub dpan_last_four_digits: Option<String>,#[serde(rename = "card_last4digits")]pub card_last_four_digits: String,#[serde(rename = "3_d_s")]@@ -826,6 +827,16 @@ impl From<api_models::payments::ApplePayWalletData> for ApplePayWalletData {}}+impl From<api_models::payments::SamsungPayTokenData> for SamsungPayTokenData {+ fn from(samsung_pay_token_data: api_models::payments::SamsungPayTokenData) -> Self {+ Self {+ three_ds_type: samsung_pay_token_data.three_ds_type,+ version: samsung_pay_token_data.version,+ data: samsung_pay_token_data.data,+ }+ }+}+impl From<api_models::payments::PazeWalletData> for PazeWalletData {fn from(value: api_models::payments::PazeWalletData) -> Self {Self {@@ -836,16 +847,29 @@ impl From<api_models::payments::PazeWalletData> for PazeWalletData {impl From<Box<api_models::payments::SamsungPayWalletData>> for SamsungPayWalletData {fn from(value: Box<api_models::payments::SamsungPayWalletData>) -> Self {- Self {- payment_credential: SamsungPayWalletCredentials {- method: value.payment_credential.method,- recurring_payment: value.payment_credential.recurring_payment,- card_brand: value.payment_credential.card_brand,- card_last_four_digits: value.payment_credential.card_last_four_digits,- token_data: SamsungPayTokenData {- three_ds_type: value.payment_credential.token_data.three_ds_type,- version: value.payment_credential.token_data.version,- data: value.payment_credential.token_data.data,+ match value.payment_credential {+ api_models::payments::SamsungPayWalletCredentials::SamsungPayWalletDataForApp(+ samsung_pay_app_wallet_data,+ ) => Self {+ payment_credential: SamsungPayWalletCredentials {+ method: samsung_pay_app_wallet_data.method,+ recurring_payment: samsung_pay_app_wallet_data.recurring_payment,+ card_brand: samsung_pay_app_wallet_data.payment_card_brand.into(),+ dpan_last_four_digits: samsung_pay_app_wallet_data.payment_last4_dpan,+ card_last_four_digits: samsung_pay_app_wallet_data.payment_last4_fpan,+ token_data: samsung_pay_app_wallet_data.token_data.into(),+ },+ },+ api_models::payments::SamsungPayWalletCredentials::SamsungPayWalletDataForWeb(+ samsung_pay_web_wallet_data,+ ) => Self {+ payment_credential: SamsungPayWalletCredentials {+ method: samsung_pay_web_wallet_data.method,+ recurring_payment: samsung_pay_web_wallet_data.recurring_payment,+ card_brand: samsung_pay_web_wallet_data.card_brand.into(),+ dpan_last_four_digits: None,+ card_last_four_digits: samsung_pay_web_wallet_data.card_last_four_digits,+ token_data: samsung_pay_web_wallet_data.token_data.into(),},},}diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 27564569c3..c28eb29159 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -424,6 +424,9 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::GooglePayPaymentMethodInfo,api_models::payments::ApplePayWalletData,api_models::payments::SamsungPayWalletCredentials,+ api_models::payments::SamsungPayWebWalletData,+ api_models::payments::SamsungPayAppWalletData,+ api_models::payments::SamsungPayCardBrand,api_models::payments::SamsungPayTokenData,api_models::payments::ApplepayPaymentMethod,api_models::payments::PaymentsCancelRequest,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex deca42f17e..bf95fbe743 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -366,6 +366,9 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::SamsungPayAmountFormat,api_models::payments::SamsungPayProtocolType,api_models::payments::SamsungPayWalletCredentials,+ api_models::payments::SamsungPayWebWalletData,+ api_models::payments::SamsungPayAppWalletData,+ api_models::payments::SamsungPayCardBrand,api_models::payments::SamsungPayTokenData,api_models::payments::PaymentsCancelRequest,api_models::payments::PaymentListConstraints,diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/router/src/connector/cybersource/transformers.rsindex 4db35abec8..da76825861 100644--- a/crates/router/src/connector/cybersource/transformers.rs+++ b/crates/router/src/connector/cybersource/transformers.rs@@ -1749,7 +1749,7 @@ impllet processing_information = ProcessingInformation::try_from((item,Some(PaymentSolution::SamsungPay),- Some(samsung_pay_data.payment_credential.card_brand),+ Some(samsung_pay_data.payment_credential.card_brand.to_string()),))?;let client_reference_information = ClientReferenceInformation::from(item);let merchant_defined_information = item