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(mandate): add network_transaction_link_id support to mandate table (#12323)

Ayush Anandd2804f2d368c
diff --git a/crates/diesel_models/src/mandate.rs b/crates/diesel_models/src/mandate.rs
index d36d6a5b5b..cd61c98a1f 100644
--- a/crates/diesel_models/src/mandate.rs
+++ b/crates/diesel_models/src/mandate.rs
@@ -37,6 +37,7 @@ pub struct Mandate {
pub updated_by: Option<String>,
// This is the extended version of customer user agent that can store string upto 2048 characters unlike customer user agent that can store 255 characters at max
pub customer_user_agent_extended: Option<String>,
+ pub network_transaction_link_id: Option<String>,
}
#[derive(
@@ -76,6 +77,7 @@ pub struct MandateNew {
pub merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
pub updated_by: Option<String>,
pub customer_user_agent_extended: Option<String>,
+ pub network_transaction_link_id: Option<String>,
}
impl Mandate {
@@ -255,6 +257,7 @@ impl From<&MandateNew> for Mandate {
updated_by: mandate_new.updated_by.clone(),
// Using customer_user_agent as a fallback
customer_user_agent_extended: mandate_new.get_customer_user_agent_extended(),
+ network_transaction_link_id: mandate_new.network_transaction_link_id.clone(),
}
}
}
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 20ad12f8f6..9b97205d7e 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -942,6 +942,8 @@ diesel::table! {
updated_by -> Nullable<Varchar>,
#[max_length = 2048]
customer_user_agent_extended -> Nullable<Varchar>,
+ #[max_length = 255]
+ network_transaction_link_id -> Nullable<Varchar>,
}
}
diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rs
index 613ba28d9f..8e72d3ab9a 100644
--- a/crates/diesel_models/src/schema_v2.rs
+++ b/crates/diesel_models/src/schema_v2.rs
@@ -954,6 +954,8 @@ diesel::table! {
updated_by -> Nullable<Varchar>,
#[max_length = 2048]
customer_user_agent_extended -> Nullable<Varchar>,
+ #[max_length = 255]
+ network_transaction_link_id -> Nullable<Varchar>,
}
}
diff --git a/crates/router/src/core/mandate.rs b/crates/router/src/core/mandate.rs
index 89bad7ad9e..4ed0f81809 100644
--- a/crates/router/src/core/mandate.rs
+++ b/crates/router/src/core/mandate.rs
@@ -343,13 +343,18 @@ where
let Some(_mandate_details) = resp.request.get_setup_mandate_details() else {
return Ok(None);
};
- let (mandate_reference, network_txn_id) = match &response {
+ let (mandate_reference, network_txn_id, network_txn_link_id) = match &response {
types::PaymentsResponseData::TransactionResponse {
mandate_reference,
network_txn_id,
+ network_txn_link_id,
..
- } => (mandate_reference.clone(), network_txn_id.clone()),
- _ => (Box::new(None), None),
+ } => (
+ mandate_reference.clone(),
+ network_txn_id.clone(),
+ network_txn_link_id.clone(),
+ ),
+ _ => (Box::new(None), None, None),
};
let mandate_ids = (*mandate_reference)
@@ -370,6 +375,7 @@ where
pm_id.get_required_value("payment_method_id")?,
mandate_ids,
network_txn_id,
+ network_txn_link_id,
get_insensitive_payment_method_data_if_exists(resp),
*mandate_reference,
merchant_connector_id,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 88261e0fc6..5c072c24bb 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -4307,6 +4307,7 @@ pub fn generate_mandate(
payment_method_id: String,
connector_mandate_id: Option<pii::SecretSerdeValue>,
network_txn_id: Option<String>,
+ network_txn_link_id: Option<String>,
payment_method_data_option: Option<domain::payments::PaymentMethodData>,
mandate_reference: Option<MandateReference>,
merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
@@ -4331,6 +4332,7 @@ pub fn generate_mandate(
.set_mandate_status(storage_enums::MandateStatus::Active)
.set_connector_mandate_ids(connector_mandate_id)
.set_network_transaction_id(network_txn_id)
+ .set_network_transaction_link_id(network_txn_link_id)
.set_customer_ip_address(
customer_acceptance
.get_ip_address()
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index f20eac0beb..9820dcc59d 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -456,7 +456,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
api_models::payments::MandateReferenceId::NetworkMandateId(
api_models::payments::NetworkMandateIdRef {
network_transaction_id: network_tx_id,
- transaction_link_id: None,
+ transaction_link_id: mandate_obj.network_transaction_link_id,
},
),
),
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index e2c8072d29..015bbcb270 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -346,7 +346,7 @@ impl<F: Send + Clone + Sync> GetTracker<F, PaymentData<F>, api::PaymentsRequest>
api_models::payments::MandateReferenceId::NetworkMandateId(
api_models::payments::NetworkMandateIdRef {
network_transaction_id: network_tx_id,
- transaction_link_id: None,
+ transaction_link_id: mandate_obj.network_transaction_link_id,
},
),
),
diff --git a/crates/router/src/db/mandate.rs b/crates/router/src/db/mandate.rs
index caae9dec68..9915b781f8 100644
--- a/crates/router/src/db/mandate.rs
+++ b/crates/router/src/db/mandate.rs
@@ -691,6 +691,7 @@ impl MandateInterface for MockDb {
merchant_connector_id: mandate_new.merchant_connector_id,
updated_by: mandate_new.updated_by,
customer_user_agent_extended,
+ network_transaction_link_id: mandate_new.network_transaction_link_id,
};
mandates.push(mandate.clone());
Ok(mandate)
diff --git a/migrations/2026-05-18-074548_add_tlid_to_mandate/down.sql b/migrations/2026-05-18-074548_add_tlid_to_mandate/down.sql
new file mode 100644
index 0000000000..b11e2b75fe
--- /dev/null
+++ b/migrations/2026-05-18-074548_add_tlid_to_mandate/down.sql
@@ -0,0 +1 @@
+ALTER TABLE mandate DROP COLUMN IF EXISTS network_transaction_link_id;
diff --git a/migrations/2026-05-18-074548_add_tlid_to_mandate/up.sql b/migrations/2026-05-18-074548_add_tlid_to_mandate/up.sql
new file mode 100644
index 0000000000..8c87542516
--- /dev/null
+++ b/migrations/2026-05-18-074548_add_tlid_to_mandate/up.sql
@@ -0,0 +1,2 @@
+ALTER TABLE mandate
+ ADD COLUMN IF NOT EXISTS network_transaction_link_id VARCHAR(255);