mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 19:46:48 +08:00
feat(router): add support for Samsung Pay payment method (#5955)
This commit is contained in:
@ -745,6 +745,10 @@ pub struct MerchantConnectorCreate {
|
||||
/// In case the merchant needs to store any additional sensitive data
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -882,6 +886,10 @@ pub struct MerchantConnectorCreate {
|
||||
/// In case the merchant needs to store any additional sensitive data
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -1102,6 +1110,10 @@ pub struct MerchantConnectorResponse {
|
||||
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -1221,6 +1233,10 @@ pub struct MerchantConnectorResponse {
|
||||
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -1327,6 +1343,10 @@ pub struct MerchantConnectorListResponse {
|
||||
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
@ -1417,6 +1437,10 @@ pub struct MerchantConnectorListResponse {
|
||||
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
@ -1512,6 +1536,28 @@ pub struct MerchantConnectorUpdate {
|
||||
/// In case the merchant needs to store any additional sensitive data
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
#[schema(value_type = Option<ConnectorWalletDetails>)]
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
|
||||
#[serde(deny_unknown_fields)]
|
||||
|
||||
pub struct ConnectorWalletDetails {
|
||||
/// This field contains the Apple Pay certificates and credentials for iOS and Web Apple Pay flow
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[schema(value_type = Option<Object>)]
|
||||
pub apple_pay_combined: Option<pii::SecretSerdeValue>,
|
||||
/// This field is for our legacy Apple Pay flow that contains the Apple Pay certificates and credentials for only iOS Apple Pay flow
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[schema(value_type = Option<Object>)]
|
||||
pub apple_pay: Option<pii::SecretSerdeValue>,
|
||||
/// This field contains the Samsung Pay certificates and credentials
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
#[schema(value_type = Option<Object>)]
|
||||
pub samsung_pay: Option<pii::SecretSerdeValue>,
|
||||
}
|
||||
|
||||
/// Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc."
|
||||
@ -1597,6 +1643,9 @@ pub struct MerchantConnectorUpdate {
|
||||
/// In case the merchant needs to store any additional sensitive data
|
||||
#[schema(value_type = Option<AdditionalMerchantData>)]
|
||||
pub additional_merchant_data: Option<AdditionalMerchantData>,
|
||||
|
||||
/// The connector_wallets_details is used to store wallet details such as certificates and wallet credentials
|
||||
pub connector_wallets_details: Option<ConnectorWalletDetails>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
|
||||
@ -2637,9 +2637,37 @@ impl GetAddressFromPaymentMethodData for WalletData {
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct SamsungPayWalletData {
|
||||
/// The encrypted payment token from Samsung
|
||||
pub payment_credential: SamsungPayWalletCredentials,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct SamsungPayWalletCredentials {
|
||||
/// Specifies authentication method used
|
||||
pub method: Option<String>,
|
||||
/// Value if credential is enabled for recurring payment
|
||||
pub recurring_payment: Option<bool>,
|
||||
/// Brand of the payment card
|
||||
pub card_brand: String,
|
||||
/// Last 4 digits of the card number
|
||||
#[serde(rename = "card_last4digits")]
|
||||
pub card_last_four_digits: String,
|
||||
/// Samsung Pay token data
|
||||
#[serde(rename = "3_d_s")]
|
||||
pub token_data: SamsungPayTokenData,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
pub struct SamsungPayTokenData {
|
||||
/// 3DS type used by Samsung Pay
|
||||
#[serde(rename = "type")]
|
||||
pub three_ds_type: Option<String>,
|
||||
/// 3DS version used by Samsung Pay
|
||||
pub version: String,
|
||||
/// Samsung Pay encrypted payment credential data
|
||||
#[schema(value_type = String)]
|
||||
pub token: Secret<String>,
|
||||
pub data: Secret<String>,
|
||||
}
|
||||
|
||||
#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
|
||||
@ -4624,6 +4652,20 @@ pub struct GpaySessionTokenData {
|
||||
pub data: GpayMetaData,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct SamsungPaySessionTokenData {
|
||||
#[serde(rename = "samsung_pay")]
|
||||
pub data: SamsungPayMetadata,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct SamsungPayMetadata {
|
||||
pub service_id: String,
|
||||
pub merchant_display_name: String,
|
||||
pub merchant_business_country: api_enums::CountryAlpha2,
|
||||
pub allowed_brands: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
|
||||
pub struct PaypalSdkMetaData {
|
||||
pub client_id: String,
|
||||
@ -4789,6 +4831,8 @@ pub struct SessionTokenForSimplifiedApplePay {
|
||||
pub enum SessionToken {
|
||||
/// The session response structure for Google Pay
|
||||
GooglePay(Box<GpaySessionTokenResponse>),
|
||||
/// The session response structure for Samsung Pay
|
||||
SamsungPay(Box<SamsungPaySessionTokenResponse>),
|
||||
/// The session response structure for Klarna
|
||||
Klarna(Box<KlarnaSessionTokenResponse>),
|
||||
/// The session response structure for PayPal
|
||||
@ -4846,6 +4890,68 @@ pub struct GooglePaySessionResponse {
|
||||
pub secrets: Option<SecretInfoToInitiateSdk>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct SamsungPaySessionTokenResponse {
|
||||
/// Samsung Pay API version
|
||||
pub version: String,
|
||||
/// Samsung Pay service ID to which session call needs to be made
|
||||
pub service_id: String,
|
||||
/// Order number of the transaction
|
||||
pub order_number: String,
|
||||
/// Field containing merchant information
|
||||
#[serde(rename = "merchant")]
|
||||
pub merchant_payment_information: SamsungPayMerchantPaymentInformation,
|
||||
/// Field containing the payment amount
|
||||
pub amount: SamsungPayAmountDetails,
|
||||
/// Payment protocol type
|
||||
pub protocol: SamsungPayProtocolType,
|
||||
/// List of supported card brands
|
||||
pub allowed_brands: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum SamsungPayProtocolType {
|
||||
Protocol3ds,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct SamsungPayMerchantPaymentInformation {
|
||||
/// Merchant name, this will be displayed on the Samsung Pay screen
|
||||
pub name: String,
|
||||
/// Merchant domain that process payments
|
||||
pub url: String,
|
||||
/// Merchant country code
|
||||
#[schema(value_type = CountryAlpha2, example = "US")]
|
||||
pub country_code: api_enums::CountryAlpha2,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct SamsungPayAmountDetails {
|
||||
#[serde(rename = "option")]
|
||||
/// Amount format to be displayed
|
||||
pub amount_format: SamsungPayAmountFormat,
|
||||
/// The currency code
|
||||
#[schema(value_type = Currency, example = "USD")]
|
||||
pub currency_code: api_enums::Currency,
|
||||
/// The total amount of the transaction
|
||||
#[serde(rename = "total")]
|
||||
#[schema(value_type = String, example = "38.02")]
|
||||
pub total_amount: StringMajorUnit,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum SamsungPayAmountFormat {
|
||||
/// Display the total amount only
|
||||
FormatTotalPriceOnly,
|
||||
/// Display "Total (Estimated amount)" and total amount
|
||||
FormatTotalEstimatedAmount,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, ToSchema)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
pub struct GpayShippingAddressParameters {
|
||||
|
||||
Reference in New Issue
Block a user