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(compatibility): Add metadata object in both payment_intent and setup_intent request (#1519)
Sahkal Poddar6ec6272f2aca
diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rsindex b7f41ab296..2f875abf7b 100644--- a/crates/router/src/compatibility/stripe/payment_intents/types.rs+++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs@@ -14,6 +14,7 @@ use crate::{api::{admin, enums as api_enums},transformers::{ForeignFrom, ForeignTryFrom},},+ utils::OptionExt,};#[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone)]@@ -218,6 +219,13 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest {field_name: "receipt_ipaddress".to_string(),expected_format: "127.0.0.1".to_string(),})?;+ let metadata_object = item+ .metadata+ .clone()+ .parse_value("metadata")+ .change_context(errors::ApiErrorResponse::InvalidDataValue {+ field_name: "metadata mapping failed",+ })?;let request = Ok(Self {payment_id: item.id.map(payments::PaymentIdType::PaymentIntentId),amount: item.amount.map(|amount| amount.into()),@@ -255,6 +263,7 @@ impl TryFrom<StripePaymentIntentRequest> for payments::PaymentsRequest {.and_then(|pmd| pmd.billing_details.map(payments::Address::from)),statement_descriptor_name: item.statement_descriptor,statement_descriptor_suffix: item.statement_descriptor_suffix,+ metadata: metadata_object,udf: item.metadata,client_secret: item.client_secret.map(|s| s.peek().clone()),authentication_type,diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rsindex 5d4514afcc..d1d7de2364 100644--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs@@ -1,7 +1,7 @@use std::str::FromStr;use api_models::payments;-use common_utils::{date_time, ext_traits::StringExt};+use common_utils::{date_time, ext_traits::StringExt, pii as secret};use error_stack::{IntoReport, ResultExt};use router_env::logger;use serde::{Deserialize, Serialize};@@ -18,6 +18,7 @@ use crate::{api::{self as api_types, admin, enums as api_enums},transformers::{ForeignFrom, ForeignTryFrom},},+ utils::OptionExt,};#[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone)]@@ -121,7 +122,6 @@ impl From<Shipping> for payments::Address {}#[derive(Default, PartialEq, Eq, Deserialize, Clone)]-pub struct StripeSetupIntentRequest {pub confirm: Option<bool>,pub customer: Option<String>,@@ -135,7 +135,7 @@ pub struct StripeSetupIntentRequest {pub billing_details: Option<StripeBillingDetails>,pub statement_descriptor: Option<String>,pub statement_descriptor_suffix: Option<String>,- pub metadata: Option<api_models::payments::Metadata>,+ pub metadata: Option<secret::SecretSerdeValue>,pub client_secret: Option<pii::Secret<String>>,pub payment_method_options: Option<payment_intent::StripePaymentMethodOptions>,pub payment_method: Option<String>,@@ -174,6 +174,13 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {field_name: "receipt_ipaddress".to_string(),expected_format: "127.0.0.1".to_string(),})?;+ let metadata_object = item+ .metadata+ .clone()+ .parse_value("metadata")+ .change_context(errors::ApiErrorResponse::InvalidDataValue {+ field_name: "metadata mapping failed",+ })?;let request = Ok(Self {amount: Some(api_types::Amount::Zero),capture_method: None,@@ -215,7 +222,8 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {.map(|b| payments::Address::from(b.to_owned())),statement_descriptor_name: item.statement_descriptor,statement_descriptor_suffix: item.statement_descriptor_suffix,- metadata: item.metadata,+ metadata: metadata_object,+ udf: item.metadata,client_secret: item.client_secret.map(|s| s.peek().clone()),setup_future_usage: item.setup_future_usage,merchant_connector_details: item.merchant_connector_details,