diff --git a/crates/router/src/compatibility/stripe/payment_intents/types.rs b/crates/router/src/compatibility/stripe/payment_intents/types.rs index 7f893d9abd..b7f41ab296 100644 --- a/crates/router/src/compatibility/stripe/payment_intents/types.rs +++ b/crates/router/src/compatibility/stripe/payment_intents/types.rs @@ -48,17 +48,25 @@ pub struct StripeCard { pub holder_name: Option>, } +#[derive(Serialize, PartialEq, Eq, Deserialize, Clone)] +#[serde(rename_all = "snake_case")] +pub enum StripeWallet { + ApplePay(payments::ApplePayWalletData), +} + #[derive(Default, Serialize, PartialEq, Eq, Deserialize, Clone)] #[serde(rename_all = "snake_case")] pub enum StripePaymentMethodType { #[default] Card, + Wallet, } impl From for api_enums::PaymentMethod { fn from(item: StripePaymentMethodType) -> Self { match item { StripePaymentMethodType::Card => Self::Card, + StripePaymentMethodType::Wallet => Self::Wallet, } } } @@ -77,6 +85,7 @@ pub struct StripePaymentMethodData { #[serde(rename_all = "snake_case")] pub enum StripePaymentMethodDetails { Card(StripeCard), + Wallet(StripeWallet), } impl From for payments::Card { @@ -93,10 +102,21 @@ impl From for payments::Card { } } +impl From for payments::WalletData { + fn from(wallet: StripeWallet) -> Self { + match wallet { + StripeWallet::ApplePay(data) => Self::ApplePay(data), + } + } +} + impl From for payments::PaymentMethodData { fn from(item: StripePaymentMethodDetails) -> Self { match item { StripePaymentMethodDetails::Card(card) => Self::Card(payments::Card::from(card)), + StripePaymentMethodDetails::Wallet(wallet) => { + Self::Wallet(payments::WalletData::from(wallet)) + } } } } @@ -143,12 +163,13 @@ pub struct StripePaymentIntentRequest { pub shipping: 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 merchant_connector_details: Option, pub mandate_id: Option, pub off_session: Option, + pub payment_method_type: Option, pub receipt_ipaddress: Option, pub user_agent: Option, } @@ -234,7 +255,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: item.metadata, + udf: item.metadata, client_secret: item.client_secret.map(|s| s.peek().clone()), authentication_type, mandate_data: mandate_options, @@ -242,6 +263,7 @@ impl TryFrom for payments::PaymentsRequest { setup_future_usage: item.setup_future_usage, mandate_id: item.mandate_id, off_session: item.off_session, + payment_method_type: item.payment_method_type, routing, browser_info: Some( serde_json::to_value(crate::types::BrowserInformation { @@ -415,7 +437,7 @@ impl From for StripePaymentIntentResponse { statement_descriptor_suffix: resp.statement_descriptor_suffix, next_action: into_stripe_next_action(resp.next_action, resp.return_url), cancellation_reason: resp.cancellation_reason, - metadata: resp.metadata, + metadata: resp.udf, charges: Charges::new(), last_payment_error: resp.error_code.map(|code| LastPaymentError { charge: None,