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(router): Add is_split_payment field to payments response (v2) (#10140)

Anurag Thakurcf6e5a10bb48
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 13f30b4407..5088cf866d 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -20340,7 +20340,8 @@
"amount",
"created",
"attempt_count",
- "return_url"
+ "return_url",
+ "is_split_payment"
],
"properties": {
"id": {
@@ -20538,6 +20539,10 @@
"description": "Date time at which payment was updated",
"example": "2022-09-10T10:11:12Z",
"nullable": true
+ },
+ "is_split_payment": {
+ "type": "boolean",
+ "description": "Indicates if the payment amount is split across multiple payment methods"
}
}
},
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index a1588bbfc4..6dd9a0afa4 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -7152,6 +7152,9 @@ pub struct PaymentsListResponseItem {
#[schema(example = "2022-09-10T10:11:12Z")]
#[serde(default, with = "common_utils::custom_serde::iso8601::option")]
pub modified_at: Option<PrimitiveDateTime>,
+
+ /// Indicates if the payment amount is split across multiple payment methods
+ pub is_split_payment: bool,
}
// Serialize is implemented because, this will be serialized in the api events.
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index c1cbdfbb31..c3dcbd77d4 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -851,6 +851,11 @@ impl PaymentIntent {
pub fn get_currency(&self) -> storage_enums::Currency {
self.amount_details.currency
}
+
+ pub fn is_split_payment(&self) -> bool {
+ self.split_txns_enabled == common_enums::SplitTxnsEnabled::Enable
+ && self.active_attempt_id_type == common_enums::ActiveAttemptIDType::AttemptsGroupID
+ }
}
#[cfg(feature = "v1")]
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 3cc2e95217..bdc0f56ad6 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -4103,6 +4103,7 @@ impl ForeignFrom<(storage::PaymentIntent, Option<storage::PaymentAttempt>)>
for api_models::payments::PaymentsListResponseItem
{
fn foreign_from((pi, pa): (storage::PaymentIntent, Option<storage::PaymentAttempt>)) -> Self {
+ let is_split_payment = pi.is_split_payment();
Self {
id: pi.id,
merchant_id: pi.merchant_id,
@@ -4142,6 +4143,7 @@ impl ForeignFrom<(storage::PaymentIntent, Option<storage::PaymentAttempt>)>
allowed_payment_method_types: pi.allowed_payment_method_types,
authorization_count: pi.authorization_count,
modified_at: pa.as_ref().map(|p| p.modified_at),
+ is_split_payment,
}
}
}