Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 5, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions api-reference/v1/openapi_spec_v1.json
Original file line number Diff line number Diff line change
Expand Up @@ -23372,6 +23372,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": [
{
Expand Down Expand Up @@ -24715,6 +24720,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": [
{
Expand Down
3 changes: 3 additions & 0 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5174,6 +5174,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>,
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9739,6 +9739,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()
}
Expand Down
4 changes: 4 additions & 0 deletions crates/router/src/core/payments/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2965,6 +2965,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),
Expand Down Expand Up @@ -3280,6 +3283,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,
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions crates/router/tests/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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![]));
Expand Down Expand Up @@ -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![],
));
Expand Down
2 changes: 2 additions & 0 deletions crates/router/tests/payments2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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![],
));
Expand Down
Loading