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

refactor(core): propagate network_transaction_id in response of payment (#8829)

Sakil Mostakf3c0a9bfb05a
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index f5a1a9b1ab..1050ee95cb 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -23578,6 +23578,11 @@
"description": "A unique identifier for the payment method used in this payment. If the payment method was saved or tokenized, this ID can be used to reference it for future transactions or recurring payments.",
"nullable": true
},
+ "network_transaction_id": {
+ "type": "string",
+ "description": "The network transaction ID is a unique identifier for the transaction as recognized by the payment network (e.g., Visa, Mastercard), this ID can be used to reference it for future transactions or recurring payments.",
+ "nullable": true
+ },
"payment_method_status": {
"allOf": [
{
@@ -24958,6 +24963,11 @@
"description": "A unique identifier for the payment method used in this payment. If the payment method was saved or tokenized, this ID can be used to reference it for future transactions or recurring payments.",
"nullable": true
},
+ "network_transaction_id": {
+ "type": "string",
+ "description": "The network transaction ID is a unique identifier for the transaction as recognized by the payment network (e.g., Visa, Mastercard), this ID can be used to reference it for future transactions or recurring payments.",
+ "nullable": true
+ },
"payment_method_status": {
"allOf": [
{
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 794aebe84d..93fdf699d5 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -5207,6 +5207,9 @@ pub struct PaymentsResponse {
/// A unique identifier for the payment method used in this payment. If the payment method was saved or tokenized, this ID can be used to reference it for future transactions or recurring payments.
pub payment_method_id: Option<String>,
+ /// The network transaction ID is a unique identifier for the transaction as recognized by the payment network (e.g., Visa, Mastercard), this ID can be used to reference it for future transactions or recurring payments.
+ pub network_transaction_id: Option<String>,
+
/// Payment Method Status, refers to the status of the payment method used for this payment.
#[schema(value_type = Option<PaymentMethodStatus>)]
pub payment_method_status: Option<common_enums::PaymentMethodStatus>,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 5567a27aac..96e86b3f7a 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -9806,6 +9806,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
self.payment_attempt.merchant_connector_id.clone()
}
+
fn get_creds_identifier(&self) -> Option<&str> {
self.creds_identifier.as_deref()
}
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 14fefae953..3bf588f143 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -3061,6 +3061,9 @@ where
fingerprint: payment_intent.fingerprint_id,
browser_info: payment_attempt.browser_info,
payment_method_id: payment_attempt.payment_method_id,
+ network_transaction_id: payment_data
+ .get_payment_method_info()
+ .and_then(|info| info.network_transaction_id.clone()),
payment_method_status: payment_data
.get_payment_method_info()
.map(|info| info.status),
@@ -3376,6 +3379,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
issuer_error_message: pa.issuer_error_message,
is_iframe_redirection_enabled:pi.is_iframe_redirection_enabled,
payment_channel: pi.payment_channel,
+ network_transaction_id: None,
}
}
}
diff --git a/crates/router/src/db/events.rs b/crates/router/src/db/events.rs
index df3293714f..1482aeb7cd 100644
--- a/crates/router/src/db/events.rs
+++ b/crates/router/src/db/events.rs
@@ -1401,6 +1401,7 @@ mod tests {
is_iframe_redirection_enabled: None,
whole_connector_response: None,
payment_channel: None,
+ network_transaction_id: None,
};
let content =
api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response));
diff --git a/crates/router/tests/payments.rs b/crates/router/tests/payments.rs
index 32299c100b..d2ab33ce85 100644
--- a/crates/router/tests/payments.rs
+++ b/crates/router/tests/payments.rs
@@ -466,6 +466,7 @@ async fn payments_create_core() {
is_iframe_redirection_enabled: None,
whole_connector_response: None,
payment_channel: None,
+ network_transaction_id: None,
};
let expected_response =
services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));
@@ -745,6 +746,7 @@ async fn payments_create_core_adyen_no_redirect() {
is_iframe_redirection_enabled: None,
whole_connector_response: None,
payment_channel: None,
+ network_transaction_id: None,
},
vec![],
));
diff --git a/crates/router/tests/payments2.rs b/crates/router/tests/payments2.rs
index 92e1ca505a..ab8c8f426a 100644
--- a/crates/router/tests/payments2.rs
+++ b/crates/router/tests/payments2.rs
@@ -228,6 +228,7 @@ async fn payments_create_core() {
is_iframe_redirection_enabled: None,
whole_connector_response: None,
payment_channel: None,
+ network_transaction_id: None,
};
let expected_response =
@@ -515,6 +516,7 @@ async fn payments_create_core_adyen_no_redirect() {
is_iframe_redirection_enabled: None,
whole_connector_response: None,
payment_channel: None,
+ network_transaction_id: None,
},
vec![],
));