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(authentication): added fields to 3ds exemption manager for migration of 3ds decision manager (#13238)

Sahkal Poddar29326c1752da
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index d59dee681b..3912ec61d6 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -28689,6 +28689,14 @@
},
"currency": {
"$ref": "#/components/schemas/Currency"
+ },
+ "business_country": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/Country"
+ }
+ ],
+ "nullable": true
}
}
},
@@ -43804,6 +43812,10 @@
}
],
"nullable": true
+ },
+ "metadata": {
+ "description": "Optional metadata about the payment.",
+ "nullable": true
}
},
"additionalProperties": false
diff --git a/crates/api_models/src/three_ds_decision_rule.rs b/crates/api_models/src/three_ds_decision_rule.rs
index 658c03bd63..124986b8eb 100644
--- a/crates/api_models/src/three_ds_decision_rule.rs
+++ b/crates/api_models/src/three_ds_decision_rule.rs
@@ -12,6 +12,9 @@ pub struct PaymentData {
/// The currency of the payment.
#[schema(value_type = Currency)]
pub currency: common_enums::Currency,
+ /// The business country of the payment.
+ #[schema(value_type = Option<Country>)]
+ pub business_country: Option<common_enums::Country>,
}
/// Represents metadata about the payment method used in the 3DS decision rule.
@@ -73,6 +76,8 @@ pub struct ThreeDsDecisionRuleExecuteRequest {
pub issuer: Option<IssuerData>,
/// Optional data about the acquirer.
pub acquirer: Option<AcquirerData>,
+ /// Optional metadata about the payment.
+ pub metadata: Option<serde_json::Value>,
}
/// Represents the response from executing a 3DS decision rule.
diff --git a/crates/common_types/src/three_ds_decision_rule_engine.rs b/crates/common_types/src/three_ds_decision_rule_engine.rs
index 08888d7256..45f6b0b6fe 100644
--- a/crates/common_types/src/three_ds_decision_rule_engine.rs
+++ b/crates/common_types/src/three_ds_decision_rule_engine.rs
@@ -76,5 +76,7 @@ impl EuclidDirFilter for ThreeDSDecisionRule {
DirKeyKind::AcquirerCountry,
DirKeyKind::AcquirerFraudRate,
DirKeyKind::CardDiscovery,
+ DirKeyKind::BusinessCountry,
+ DirKeyKind::MetaData,
];
}
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index e9d979a9be..593b1dfd75 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1672,6 +1672,10 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
.inspect_err(|err| logger::error!("{:?}", err))
.ok()
.unwrap_or_default(),
+ business_country: payment_data
+ .payment_intent
+ .business_country
+ .map(common_enums::Country::from_alpha2),
},
payment_method: Some(
api_models::three_ds_decision_rule::PaymentMethodMetaData {
@@ -1714,6 +1718,7 @@ impl<F: Clone + Send + Sync> Domain<F, api::PaymentsRequest, PaymentData<F>> for
fraud_rate: acquirer.acquirer_fraud_rate,
}
}),
+ metadata: payment_data.payment_intent.metadata.clone(),
},
)
.await
diff --git a/crates/router/src/core/three_ds_decision_rule/utils.rs b/crates/router/src/core/three_ds_decision_rule/utils.rs
index 79fe8fbfc4..f3901ba046 100644
--- a/crates/router/src/core/three_ds_decision_rule/utils.rs
+++ b/crates/router/src/core/three_ds_decision_rule/utils.rs
@@ -46,7 +46,7 @@ impl ForeignFrom<api_threedsecure::PaymentData> for dsl_inputs::PaymentInput {
transaction_initiator: None,
authentication_type: None,
capture_method: None,
- business_country: None,
+ business_country: request_payment_data.business_country,
billing_country: None,
business_label: None,
setup_future_usage: None,
@@ -105,7 +105,34 @@ impl ForeignFrom<api_threedsecure::AcquirerData> for dsl_inputs::AcquirerDataInp
impl ForeignFrom<api_threedsecure::ThreeDsDecisionRuleExecuteRequest> for dsl_inputs::BackendInput {
fn foreign_from(request: api_threedsecure::ThreeDsDecisionRuleExecuteRequest) -> Self {
Self {
- metadata: None,
+ metadata: request.metadata.and_then(|meta| {
+ // Extract metadata from "routing_parameters" namespace if nested (during standard transaction confirmations flow),
+ // or fall back to parsing the raw root metadata value if flat (during standalone test execution API calls).
+ meta.get("routing_parameters")
+ .cloned()
+ .and_then(|params| {
+ serde_json::from_value::<rustc_hash::FxHashMap<String, String>>(params)
+ .map_err(|err| {
+ router_env::logger::error!(
+ "Error deserializing routing_parameters from metadata: {:?}",
+ err
+ );
+ err
+ })
+ .ok()
+ })
+ .or_else(|| {
+ serde_json::from_value::<rustc_hash::FxHashMap<String, String>>(meta)
+ .map_err(|err| {
+ router_env::logger::error!(
+ "Error deserializing flat metadata: {:?}",
+ err
+ );
+ err
+ })
+ .ok()
+ })
+ }),
payment: dsl_inputs::PaymentInput::foreign_from(request.payment),
payment_method: dsl_inputs::PaymentMethodInput::foreign_from(request.payment_method),
mandate: dsl_inputs::MandateData {