Repository: juspay/hyperswitch
File: crates/api_models/src/payments.rs (Rust)

Code before:

#[derive(
    Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
)]
#[serde(rename_all = "lowercase")]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct GpayShippingAddressParameters {
    /// Is shipping phone number required
    #[smithy(value_type = "bool")]
    pub phone_number_required: bool,
}

#[derive(
    Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
)]
#[serde(rename_all = "lowercase")]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct KlarnaSessionTokenResponse {
    /// The session token for Klarna
    #[smithy(value_type = "String")]
    pub session_token: String,
    /// The identifier for the session
    #[smithy(value_type = "String")]
    pub session_id: String,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
#[serde(rename_all = "snake_case")]
pub enum PaypalFlow {
    Checkout,
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct PaypalTransactionInfo {
    /// Paypal flow type
    #[schema(value_type = PaypalFlow, example = "checkout")]
    pub flow: PaypalFlow,
    /// Currency code
    #[schema(value_type = Currency, example = "USD")]
    pub currency_code: api_enums::Currency,
    /// Total price
    #[schema(value_type = String, example = "38.02")]
    pub total_price: StringMajorUnit,
}

#[derive(
    Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel,
)]
#[serde(rename_all = "lowercase")]
#[smithy(namespace = "com.hyperswitch.smithy.types")]
pub struct PaypalSessionTokenResponse {

Review comment (bug):
the change was required , instead of serde rename="google_pay" we are directly using google_pay or else accessing the wrapper fields will look like metadata.data.data which seems aesthetically bad. In previous review i considered GooglePayWallet to be present in MCA.metadata but it was wrong. it should be `GpaySessionTokenData`

Code after:
    /// The name of the merchant that needs to be displayed on Gpay PopUp
    #[smithy(value_type = "String")]
    pub merchant_name: String,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpayMetaData {
    pub merchant_info: GpayMerchantInfo,
    pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GooglePayDetailsWrapper {
    #[serde(flatten)]
    pub data: Option<GpayMetaData>,
    support_predecrypted_token: Option<bool>,
}
impl GooglePayDetailsWrapper {
    pub fn is_predecrypted_token_supported(&self) -> bool {
        self.support_predecrypted_token.unwrap_or(false)
    }
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct GpaySessionTokenData {
    pub google_pay: GooglePayDetailsWrapper,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PazeSessionTokenData {
    #[serde(rename = "paze")]
    pub data: PazeMetadata,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
pub struct PazeMetadata {
    pub client_id: String,
    pub client_name: String,
    pub client_profile_id: String,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum SamsungPayCombinedMetadata {
    // This is to support the Samsung Pay decryption flow with application credentials,
    // where the private key, certificates, or any other information required for decryption
    // will be obtained from the application configuration.
    ApplicationCredentials(SamsungPayApplicationCredentials),
    MerchantCredentials(SamsungPayMerchantCredentials),
}