diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index b7f41ab2965..2f875abf7be 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 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 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.rs index 5d4514afcc0..d1d7de23644 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 for payments::Address { } #[derive(Default, PartialEq, Eq, Deserialize, Clone)] - pub struct StripeSetupIntentRequest { pub confirm: Option, pub customer: Option, @@ -135,7 +135,7 @@ pub struct StripeSetupIntentRequest { pub billing_details: Option, pub statement_descriptor: Option, pub statement_descriptor_suffix: Option, - pub metadata: Option, + pub metadata: Option, pub client_secret: Option>, pub payment_method_options: Option, pub payment_method: Option, @@ -174,6 +174,13 @@ impl TryFrom 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 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,