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(connect): [stripe] pass error_on_requires_action for MIT payments (#14308)
Akshaya Shankar622c8d1af86d
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex cf23c4d6f2..a87b66ae10 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -19222,6 +19222,14 @@}],"nullable": true+ },+ "stripe": {+ "allOf": [+ {+ "$ref": "#/components/schemas/StripeConnectorMetadata"+ }+ ],+ "nullable": true}}},@@ -46852,6 +46860,16 @@"destination"]},+ "StripeConnectorMetadata": {+ "type": "object",+ "properties": {+ "error_on_requires_action": {+ "type": "boolean",+ "description": "For MIT (merchant-initiated) payments: when true, Stripe fails the payment outright\ninstead of returning a `requires_action` status, since there's no customer present to\ncomplete additional authentication.",+ "nullable": true+ }+ }+ },"StripeSplitPaymentRequest": {"type": "object","description": "Fee information for Split Payments to be charged on the payment being collected for Stripe",diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 286275393b..f33f7abfb4 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -12675,6 +12675,14 @@}],"nullable": true+ },+ "stripe": {+ "allOf": [+ {+ "$ref": "#/components/schemas/StripeConnectorMetadata"+ }+ ],+ "nullable": true}}},@@ -33899,6 +33907,16 @@"destination"]},+ "StripeConnectorMetadata": {+ "type": "object",+ "properties": {+ "error_on_requires_action": {+ "type": "boolean",+ "description": "For MIT (merchant-initiated) payments: when true, Stripe fails the payment outright\ninstead of returning a `requires_action` status, since there's no customer present to\ncomplete additional authentication.",+ "nullable": true+ }+ }+ },"StripeSplitPaymentRequest": {"type": "object","description": "Fee information for Split Payments to be charged on the payment being collected for Stripe",diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 19caff36d7..df8f782923 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -10370,6 +10370,18 @@ pub struct ConnectorMetadata {pub worldpayxml: Option<WorldpayxmlData>,#[smithy(value_type = "Option<CheckoutData>")]pub checkout: Option<CheckoutData>,+ #[smithy(value_type = "Option<StripeConnectorMetadata>")]+ pub stripe: Option<StripeConnectorMetadata>,+}++#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]+#[smithy(namespace = "com.hyperswitch.smithy.types")]+pub struct StripeConnectorMetadata {+ /// For MIT (merchant-initiated) payments: when true, Stripe fails the payment outright+ /// instead of returning a `requires_action` status, since there's no customer present to+ /// complete additional authentication.+ #[smithy(value_type = "Option<bool>")]+ pub error_on_requires_action: Option<bool>,}#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema, SmithyModel)]diff --git a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rsindex 3ae51d928b..559eaf59a8 100644--- a/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs+++ b/crates/hyperswitch_connectors/src/connectors/stripe/transformers.rs@@ -261,6 +261,8 @@ pub struct PaymentIntentRequest {pub payment_method_options: Option<StripePaymentMethodOptions>, // For mandate txns using network_txns_id, needs to be validatedpub setup_future_usage: Option<enums::FutureUsage>,pub off_session: Option<bool>,+ #[serde(skip_serializing_if = "Option::is_none")]+ pub error_on_requires_action: Option<bool>,#[serde(rename = "payment_method_types[0]")]pub payment_method_types: Option<StripePaymentMethodType>,#[serde(rename = "expand[0]")]@@ -2673,6 +2675,18 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequest(None, None) => None,};+ let is_mit_payment = item.request.mandate_id.is_some()+ || matches!(+ item.request.payment_method_data,+ PaymentMethodData::MandatePayment+ );+ let error_on_requires_action = item+ .request+ .connector_intent_metadata+ .as_ref()+ .and_then(|connector_metadata| connector_metadata.stripe.as_ref())+ .and_then(|stripe_metadata| stripe_metadata.error_on_requires_action);+let is_moto = if matches!(item.request.payment_method_data,PaymentMethodData::Card { .. }@@ -2715,6 +2729,10 @@ impl TryFrom<(&PaymentsAuthorizeRouterData, MinorUnit)> for PaymentIntentRequestcustomer: item.connector_customer.clone().map(Secret::new),setup_mandate_details,off_session: item.request.off_session,+ // Only meaningful for MIT (merchant-initiated) payments: no customer is present to+ // complete additional authentication, so fail outright instead of coming back as+ // `requires_action`.+ error_on_requires_action: is_mit_payment.then_some(error_on_requires_action).flatten(),setup_future_usage: match (item.request.split_payments.as_ref(),setup_future_usage,diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rsindex 979b335976..94799d04ce 100644--- a/crates/openapi/src/openapi.rs+++ b/crates/openapi/src/openapi.rs@@ -717,6 +717,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::AmountInfo,api_models::payments::ClickToPaySessionResponse,api_models::payments::SantanderConnectorMetadataData,+ api_models::payments::StripeConnectorMetadata,api_models::payments::SantanderBoletoData,api_models::payments::PixAutomaticoMitData,api_models::payments::SantanderPixAutomaticoReceiverDetails,diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rsindex 0382e26131..53051914ca 100644--- a/crates/openapi/src/openapi_v2.rs+++ b/crates/openapi/src/openapi_v2.rs@@ -770,6 +770,7 @@ Never share your secret api keys. Keep them guarded and secure.api_models::payments::NetworkTokenData,api_models::payments::Address,api_models::payments::SantanderConnectorMetadataData,+ api_models::payments::StripeConnectorMetadata,api_models::payments::SantanderBoletoData,api_models::payments::PixAutomaticoMitData,api_models::payments::SantanderPixAutomaticoReceiverDetails,diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rsindex c4755e4a02..c4484a6981 100644--- a/crates/router/src/core/unified_connector_service/transformers.rs+++ b/crates/router/src/core/unified_connector_service/transformers.rs@@ -82,6 +82,7 @@ impl ForeignFrom<&api_models::payments::ConnectorMetadata>peachpayments: _,santander: _,worldpayxml,+ stripe: _,} = metadata;fn to_snake_case_string<T: serde::Serialize>(value: T) -> Option<String> {serde_json::to_value(value)