revert: serialize with camelCase for gpay token (#328)

This commit is contained in:
Narayan Bhat
2023-01-11 15:25:11 +05:30
committed by GitHub
parent c50a75306e
commit 76ad42cc30
2 changed files with 2 additions and 11 deletions

View File

@ -772,21 +772,18 @@ pub struct PaymentsSessionRequest {
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayAllowedMethodsParameters { pub struct GpayAllowedMethodsParameters {
pub allowed_auth_methods: Vec<String>, pub allowed_auth_methods: Vec<String>,
pub allowed_card_networks: Vec<String>, pub allowed_card_networks: Vec<String>,
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayTokenParameters { pub struct GpayTokenParameters {
pub gateway: String, pub gateway: String,
pub gateway_merchant_id: String, pub gateway_merchant_id: String,
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayTokenizationSpecification { pub struct GpayTokenizationSpecification {
#[serde(rename = "type")] #[serde(rename = "type")]
pub token_specification_type: String, pub token_specification_type: String,
@ -794,7 +791,6 @@ pub struct GpayTokenizationSpecification {
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayAllowedPaymentMethods { pub struct GpayAllowedPaymentMethods {
#[serde(rename = "type")] #[serde(rename = "type")]
pub payment_method_type: String, pub payment_method_type: String,
@ -803,7 +799,6 @@ pub struct GpayAllowedPaymentMethods {
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayTransactionInfo { pub struct GpayTransactionInfo {
pub country_code: String, pub country_code: String,
pub currency_code: String, pub currency_code: String,
@ -812,13 +807,11 @@ pub struct GpayTransactionInfo {
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayMerchantInfo { pub struct GpayMerchantInfo {
pub merchant_name: String, pub merchant_name: String,
} }
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)] #[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(rename_all(serialize = "camelCase"))]
pub struct GpayMetadata { pub struct GpayMetadata {
pub merchant_info: GpayMerchantInfo, pub merchant_info: GpayMerchantInfo,
pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>, pub allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
@ -834,9 +827,7 @@ pub struct GpaySessionTokenData {
#[serde(rename_all = "lowercase")] #[serde(rename_all = "lowercase")]
pub enum SessionToken { pub enum SessionToken {
Gpay { Gpay {
#[serde(flatten)] allowed_payment_methods: Vec<GpayAllowedPaymentMethods>,
gpay_token: GpayMetadata,
#[serde(rename(serialize = "transactionInfo"))]
transaction_info: GpayTransactionInfo, transaction_info: GpayTransactionInfo,
}, },
Klarna { Klarna {

View File

@ -84,7 +84,7 @@ fn create_gpay_session_token(
let response_router_data = types::PaymentsSessionRouterData { let response_router_data = types::PaymentsSessionRouterData {
response: Ok(types::PaymentsResponseData::SessionResponse { response: Ok(types::PaymentsResponseData::SessionResponse {
session_token: payment_types::SessionToken::Gpay { session_token: payment_types::SessionToken::Gpay {
gpay_token: gpay_data.gpay, allowed_payment_methods: gpay_data.gpay.allowed_payment_methods,
transaction_info, transaction_info,
}, },
}), }),