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
feat(router): Add payment_type to Get Intent response (v2) (#9066)
Anurag Thakur26930a47e905
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 2d9164f8cb..bfa65cddc9 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -19157,7 +19157,8 @@"payment_link_enabled","request_incremental_authorization","expires_on",- "request_external_three_ds_authentication"+ "request_external_three_ds_authentication",+ "payment_type"],"properties": {"id": {@@ -19318,6 +19319,9 @@},"request_external_three_ds_authentication": {"$ref": "#/components/schemas/External3dsAuthenticationRequest"+ },+ "payment_type": {+ "$ref": "#/components/schemas/PaymentType"}},"additionalProperties": falsediff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 5660819cea..fefbbed0f0 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -654,6 +654,10 @@ pub struct PaymentsIntentResponse {/// Whether to perform external authentication (if applicable)#[schema(value_type = External3dsAuthenticationRequest)]pub request_external_three_ds_authentication: common_enums::External3dsAuthenticationRequest,++ /// The type of the payment that differentiates between normal and various types of mandate payments+ #[schema(value_type = PaymentType)]+ pub payment_type: api_enums::PaymentType,}#[cfg(feature = "v2")]diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex 22fa8e4ccd..574a4a7702 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -2148,6 +2148,24 @@ where) -> RouterResponse<Self> {let payment_intent = payment_data.get_payment_intent();let client_secret = payment_data.get_client_secret();++ let is_cit_transaction = payment_intent.setup_future_usage.is_off_session();++ let mandate_type = if payment_intent.customer_present+ == common_enums::PresenceOfCustomerDuringPayment::Absent+ {+ Some(api::MandateTransactionType::RecurringMandateTransaction)+ } else if is_cit_transaction {+ Some(api::MandateTransactionType::NewMandateTransaction)+ } else {+ None+ };++ let payment_type = helpers::infer_payment_type(+ payment_intent.amount_details.order_amount.into(),+ mandate_type.as_ref(),+ );+Ok(services::ApplicationResponse::JsonWithHeaders((Self {id: payment_intent.id.clone(),@@ -2201,6 +2219,7 @@ wherefrm_metadata: payment_intent.frm_metadata.clone(),request_external_three_ds_authentication: payment_intent.request_external_three_ds_authentication,+ payment_type,},vec![],)))