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
fix(google_pay): allow custom fields in `GpayTokenParameters` for google pay via stripe (#1125)
Jaganf790099368ed
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex b4dcb7acc5..bf774e6b69 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -724,7 +724,7 @@ pub enum WalletData {}#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]-#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]+#[serde(rename_all = "snake_case")]pub struct GooglePayWalletData {/// The type of payment method#[serde(rename = "type")]@@ -756,7 +756,7 @@ pub struct MbWayRedirection {}#[derive(Eq, PartialEq, Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]-#[serde(rename_all(serialize = "camelCase", deserialize = "snake_case"))]+#[serde(rename_all = "snake_case")]pub struct GooglePayPaymentMethodInfo {/// The name of the card networkpub card_network: String,@@ -1464,7 +1464,15 @@ pub struct GpayTokenParameters {/// The name of the connectorpub gateway: String,/// The merchant ID registered in the connector associated- pub gateway_merchant_id: String,+ #[serde(skip_serializing_if = "Option::is_none")]+ pub gateway_merchant_id: Option<String>,+ #[serde(skip_serializing_if = "Option::is_none", rename = "stripe:version")]+ pub stripe_version: Option<String>,+ #[serde(+ skip_serializing_if = "Option::is_none",+ rename = "stripe:publishableKey"+ )]+ pub stripe_publishable_key: Option<String>,}#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]diff --git a/crates/router/src/connector/bluesnap/transformers.rs b/crates/router/src/connector/bluesnap/transformers.rsindex dd538e929a..6adbbb054d 100644--- a/crates/router/src/connector/bluesnap/transformers.rs+++ b/crates/router/src/connector/bluesnap/transformers.rs@@ -55,10 +55,10 @@ pub struct BluesnapWallet {encoded_payment_token: String,}-#[derive(Debug, Serialize, Eq, PartialEq)]+#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]pub struct BluesnapGooglePayObject {- payment_method_data: api_models::payments::GooglePayWalletData,+ payment_method_data: utils::GooglePayWalletData,}#[derive(Debug, Serialize, Eq, PartialEq)]@@ -92,7 +92,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for BluesnapPaymentsRequest {api_models::payments::WalletData::GooglePay(payment_method_data) => {let gpay_object = Encode::<BluesnapGooglePayObject>::encode_to_string_of_json(&BluesnapGooglePayObject {- payment_method_data,+ payment_method_data: utils::GooglePayWalletData::from(+ payment_method_data,+ ),},).change_context(errors::ConnectorError::RequestEncodingFailed)?;diff --git a/crates/router/src/connector/nuvei/transformers.rs b/crates/router/src/connector/nuvei/transformers.rsindex fdf79c5da4..917be01578 100644--- a/crates/router/src/connector/nuvei/transformers.rs+++ b/crates/router/src/connector/nuvei/transformers.rs@@ -429,7 +429,7 @@ impl TryFrom<payments::GooglePayWalletData> for NuveiPaymentsRequest {mobile_token: common_utils::ext_traits::Encode::<payments::GooglePayWalletData,>::encode_to_string_of_json(- &gpay_data+ &utils::GooglePayWalletData::from(gpay_data)).change_context(errors::ConnectorError::RequestEncodingFailed)?,}),diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex 278dd44a76..e5221b56e9 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -325,6 +325,47 @@ impl RefundsRequestData for types::RefundsData {}}+#[derive(Clone, Debug, serde::Serialize)]+#[serde(rename_all = "camelCase")]+pub struct GooglePayWalletData {+ #[serde(rename = "type")]+ pub pm_type: String,+ pub description: String,+ pub info: GooglePayPaymentMethodInfo,+ pub tokenization_data: GpayTokenizationData,+}++#[derive(Clone, Debug, serde::Serialize)]+#[serde(rename_all = "camelCase")]+pub struct GooglePayPaymentMethodInfo {+ pub card_network: String,+ pub card_details: String,+}++#[derive(Clone, Debug, serde::Serialize)]+pub struct GpayTokenizationData {+ #[serde(rename = "type")]+ pub token_type: String,+ pub token: String,+}++impl From<api_models::payments::GooglePayWalletData> for GooglePayWalletData {+ fn from(data: api_models::payments::GooglePayWalletData) -> Self {+ Self {+ pm_type: data.pm_type,+ description: data.description,+ info: GooglePayPaymentMethodInfo {+ card_network: data.info.card_network,+ card_details: data.info.card_details,+ },+ tokenization_data: GpayTokenizationData {+ token_type: data.tokenization_data.token_type,+ token: data.tokenization_data.token,+ },+ }+ }+}+static CARD_REGEX: Lazy<HashMap<CardIssuer, Result<Regex, regex::Error>>> = Lazy::new(|| {let mut map = HashMap::new();// Reference: https://gist.github.com/michaelkeevildown/9096cd3aac9029c4e6e05588448a8841