Skip to content

Commit f3c0a9b

Browse files
refactor(core): propagate network_transaction_id in response of payment (#8829)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
1 parent 312c733 commit f3c0a9b

File tree

7 files changed

+23
-0
lines changed

7 files changed

+23
-0
lines changed

api-reference/v1/openapi_spec_v1.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23578,6 +23578,11 @@
2357823578
"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.",
2357923579
"nullable": true
2358023580
},
23581+
"network_transaction_id": {
23582+
"type": "string",
23583+
"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.",
23584+
"nullable": true
23585+
},
2358123586
"payment_method_status": {
2358223587
"allOf": [
2358323588
{
@@ -24958,6 +24963,11 @@
2495824963
"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.",
2495924964
"nullable": true
2496024965
},
24966+
"network_transaction_id": {
24967+
"type": "string",
24968+
"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.",
24969+
"nullable": true
24970+
},
2496124971
"payment_method_status": {
2496224972
"allOf": [
2496324973
{

crates/api_models/src/payments.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5207,6 +5207,9 @@ pub struct PaymentsResponse {
52075207
/// 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.
52085208
pub payment_method_id: Option<String>,
52095209

5210+
/// 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.
5211+
pub network_transaction_id: Option<String>,
5212+
52105213
/// Payment Method Status, refers to the status of the payment method used for this payment.
52115214
#[schema(value_type = Option<PaymentMethodStatus>)]
52125215
pub payment_method_status: Option<common_enums::PaymentMethodStatus>,

crates/router/src/core/payments.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9806,6 +9806,7 @@ impl<F: Clone> OperationSessionGetters<F> for PaymentData<F> {
98069806
fn get_merchant_connector_id_in_attempt(&self) -> Option<id_type::MerchantConnectorAccountId> {
98079807
self.payment_attempt.merchant_connector_id.clone()
98089808
}
9809+
98099810
fn get_creds_identifier(&self) -> Option<&str> {
98109811
self.creds_identifier.as_deref()
98119812
}

crates/router/src/core/payments/transformers.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3061,6 +3061,9 @@ where
30613061
fingerprint: payment_intent.fingerprint_id,
30623062
browser_info: payment_attempt.browser_info,
30633063
payment_method_id: payment_attempt.payment_method_id,
3064+
network_transaction_id: payment_data
3065+
.get_payment_method_info()
3066+
.and_then(|info| info.network_transaction_id.clone()),
30643067
payment_method_status: payment_data
30653068
.get_payment_method_info()
30663069
.map(|info| info.status),
@@ -3376,6 +3379,7 @@ impl ForeignFrom<(storage::PaymentIntent, storage::PaymentAttempt)> for api::Pay
33763379
issuer_error_message: pa.issuer_error_message,
33773380
is_iframe_redirection_enabled:pi.is_iframe_redirection_enabled,
33783381
payment_channel: pi.payment_channel,
3382+
network_transaction_id: None,
33793383
}
33803384
}
33813385
}

crates/router/src/db/events.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1401,6 +1401,7 @@ mod tests {
14011401
is_iframe_redirection_enabled: None,
14021402
whole_connector_response: None,
14031403
payment_channel: None,
1404+
network_transaction_id: None,
14041405
};
14051406
let content =
14061407
api_webhooks::OutgoingWebhookContent::PaymentDetails(Box::new(expected_response));

crates/router/tests/payments.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ async fn payments_create_core() {
466466
is_iframe_redirection_enabled: None,
467467
whole_connector_response: None,
468468
payment_channel: None,
469+
network_transaction_id: None,
469470
};
470471
let expected_response =
471472
services::ApplicationResponse::JsonWithHeaders((expected_response, vec![]));
@@ -745,6 +746,7 @@ async fn payments_create_core_adyen_no_redirect() {
745746
is_iframe_redirection_enabled: None,
746747
whole_connector_response: None,
747748
payment_channel: None,
749+
network_transaction_id: None,
748750
},
749751
vec![],
750752
));

crates/router/tests/payments2.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ async fn payments_create_core() {
228228
is_iframe_redirection_enabled: None,
229229
whole_connector_response: None,
230230
payment_channel: None,
231+
network_transaction_id: None,
231232
};
232233

233234
let expected_response =
@@ -515,6 +516,7 @@ async fn payments_create_core_adyen_no_redirect() {
515516
is_iframe_redirection_enabled: None,
516517
whole_connector_response: None,
517518
payment_channel: None,
519+
network_transaction_id: None,
518520
},
519521
vec![],
520522
));

0 commit comments

Comments
 (0)