Skip to content

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

feat(compatibility): add straight through routing and udf mapping in setup intent (#1536)

Sahkal Poddar1e87f3d6732f
diff --git a/crates/router/src/compatibility/stripe/setup_intents/types.rs b/crates/router/src/compatibility/stripe/setup_intents/types.rs
index d1d7de2364..82815ea4d0 100644
--- a/crates/router/src/compatibility/stripe/setup_intents/types.rs
+++ b/crates/router/src/compatibility/stripe/setup_intents/types.rs
@@ -125,6 +125,7 @@ impl From<Shipping> for payments::Address {
pub struct StripeSetupIntentRequest {
pub confirm: Option<bool>,
pub customer: Option<String>,
+ pub connector: Option<Vec<api_enums::RoutableConnectors>>,
pub description: Option<String>,
pub currency: Option<String>,
pub payment_method_data: Option<StripePaymentMethodData>,
@@ -165,6 +166,18 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
}
None => (None, None),
};
+ let routable_connector: Option<api_enums::RoutableConnectors> =
+ item.connector.and_then(|v| v.into_iter().next());
+
+ let routing = routable_connector
+ .map(api_types::RoutingAlgorithm::Single)
+ .map(|r| {
+ serde_json::to_value(r)
+ .into_report()
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("converting to routing failed")
+ })
+ .transpose()?;
let ip_address = item
.receipt_ipaddress
.map(|ip| std::net::IpAddr::from_str(ip.as_str()))
@@ -228,6 +241,7 @@ impl TryFrom<StripeSetupIntentRequest> for payments::PaymentsRequest {
setup_future_usage: item.setup_future_usage,
merchant_connector_details: item.merchant_connector_details,
authentication_type,
+ routing,
mandate_data: mandate_options,
browser_info: Some(
serde_json::to_value(crate::types::BrowserInformation {
@@ -360,6 +374,7 @@ pub struct StripeSetupIntentResponse {
pub object: String,
pub status: StripeSetupStatus,
pub client_secret: Option<masking::Secret<String>>,
+ pub metadata: Option<secret::SecretSerdeValue>,
#[serde(with = "common_utils::custom_serde::iso8601::option")]
pub created: Option<time::PrimitiveDateTime>,
pub customer: Option<String>,
@@ -403,6 +418,7 @@ impl From<payments::PaymentsResponse> for StripeSetupIntentResponse {
charges: payment_intent::Charges::new(),
created: resp.created,
customer: resp.customer_id,
+ metadata: resp.udf,
id: resp.payment_id,
refunds: resp
.refunds