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

Code before:
#[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 GpaySessionTokenData {
    pub gpay: GpayMetadata,
}

#[derive(Debug, Clone, serde::Serialize)]
#[serde(tag = "wallet_name")]
#[serde(rename_all = "lowercase")]
pub enum SessionToken {
    Gpay {
        allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
        transaction_info: GpayTransactionInfo,
    },
    Klarna {
        session_token: String,
        session_id: String,
    },
    Paypal {
        session_token: String,
    },
    Applepay {
        epoch_timestamp: u64,
        expires_at: u64,
        merchant_session_identifier: String,
        nonce: String,
        merchant_identifier: String,
        domain_name: String,
        display_name: String,
        signature: String,
        operational_analytics_identifier: String,
        retries: u8,
        psp_id: String,
    },
}

#[derive(Default, Debug, serde::Serialize, Clone)]
pub struct PaymentsSessionResponse {
    pub payment_id: String,
    pub client_secret: Secret<String, pii::ClientSecret>,
    pub session_token: Vec<SessionToken>,
}

#[derive(Default, Debug, serde::Deserialize, serde::Serialize, Clone)]
pub struct PaymentRetrieveBody {
    pub merchant_id: Option<String>,

Review comment (refactor):
**🟢 Suggestion - Pattern Consistency**

Good refactoring to use `flatten` to include all GpayMetadata fields. However, I notice:

1. You're using `#[serde(rename(serialize = "camelCase"))]` on `transactionInfo` 
2. But the parent `GpayMetadata` struct already has `#[serde(rename_all(serialize = "camelCase"))]`

**Question**: Is the explicit `rename` on line 811 necessary? If `transaction_info` is already being serialized with camelCase from the struct definition, this might be redundant.

**Suggested Investigation**: Test if removing this explicit rename still produces the correct camelCase output for `transactionInfo`.

Code after:
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayMerchantInfo {
    pub merchant_name: String,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayMetadata {
    pub merchant_info: GpayMerchantInfo,
    pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
}

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

#[derive(Debug, Clone, serde::Serialize)]
#[serde(tag = "wallet_name")]
#[serde(rename_all = "lowercase")]
pub enum SessionToken {
    Gpay {
        #[serde(flatten)]
        gpay_token: GpayMetadata,
        #[serde(rename(serialize = "transactionInfo"))]
        transaction_info: GpayTransactionInfo,
    },
    Klarna {
        session_token: String,
        session_id: String,
    },
    Paypal {
        session_token: String,
    },
    Applepay {
        epoch_timestamp: u64,
        expires_at: u64,
        merchant_session_identifier: String,
        nonce: String,
        merchant_identifier: String,
        domain_name: String,
        display_name: String,
        signature: String,
        operational_analytics_identifier: String,
        retries: u8,
        psp_id: String,
    },
}

#[derive(Default, Debug, serde::Serialize, Clone)]