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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(payment_method): add support to pass `network_transaction_id` in /v2 update payment method request (#10920)
Shankar Singh C9a4f8c68c911
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex 18052aabc6..60131275d5 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -19641,7 +19641,8 @@"id","merchant_id","customer_id",- "payment_method_type"+ "payment_method_type",+ "network_transaction_id"],"properties": {"id": {@@ -19731,6 +19732,10 @@}],"nullable": true+ },+ "network_transaction_id": {+ "type": "string",+ "description": "The network transaction ID provided by the card network during a Customer Initiated Transaction (CIT)\nwhen `setup_future_usage` is set to `off_session`."}}},@@ -20246,6 +20251,9 @@},"PaymentMethodUpdate": {"type": "object",+ "required": [+ "network_transaction_id"+ ],"properties": {"payment_method_data": {"allOf": [@@ -20262,6 +20270,10 @@}],"nullable": true+ },+ "network_transaction_id": {+ "type": "string",+ "description": "The network transaction ID provided by the card network during a Customer Initiated Transaction (CIT)\nwhen `setup_future_usage` is set to `off_session`."}},"additionalProperties": falsediff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rsindex 5e07ebdf9c..9a4aa67192 100644--- a/crates/api_models/src/payment_methods.rs+++ b/crates/api_models/src/payment_methods.rs@@ -506,6 +506,11 @@ pub struct PaymentMethodUpdate {/// The connector token details to be updated for the payment_methodpub connector_token_details: Option<ConnectorTokenDetails>,++ /// The network transaction ID provided by the card network during a Customer Initiated Transaction (CIT)+ /// when `setup_future_usage` is set to `off_session`.+ #[schema(value_type = String)]+ pub network_transaction_id: Option<masking::Secret<String>>,}#[cfg(feature = "v2")]@@ -1138,6 +1143,11 @@ pub struct PaymentMethodResponse {/// Card CVC token storage detailspub card_cvc_token_storage: Option<CardCVCTokenStorageDetails>,++ /// The network transaction ID provided by the card network during a Customer Initiated Transaction (CIT)+ /// when `setup_future_usage` is set to `off_session`.+ #[schema(value_type = String)]+ pub network_transaction_id: Option<masking::Secret<String>>,}#[cfg(feature = "v2")]diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rsindex a7a0b2adbf..a25a5365fa 100644--- a/crates/diesel_models/src/payment_method.rs+++ b/crates/diesel_models/src/payment_method.rs@@ -9,7 +9,8 @@ use common_utils::{use diesel::{AsChangeset, Identifiable, Insertable, Queryable, Selectable};use error_stack::ResultExt;#[cfg(feature = "v1")]-use masking::{ExposeInterface, Secret};+use masking::ExposeInterface;+use masking::Secret;use serde::{Deserialize, Serialize};use time::PrimitiveDateTime;@@ -80,7 +81,7 @@ pub struct PaymentMethod {pub connector_mandate_details: Option<CommonMandateReference>,pub customer_acceptance: Option<pii::SecretSerdeValue>,pub status: storage_enums::PaymentMethodStatus,- pub network_transaction_id: Option<String>,+ pub network_transaction_id: Option<Secret<String>>,pub client_secret: Option<String>,pub payment_method_billing_address: Option<Encryption>,pub updated_by: Option<String>,@@ -294,7 +295,7 @@ pub enum PaymentMethodUpdate {last_used_at: PrimitiveDateTime,},NetworkTransactionIdAndStatusUpdate {- network_transaction_id: Option<String>,+ network_transaction_id: Option<Secret<String>>,status: Option<storage_enums::PaymentMethodStatus>,last_modified_by: Option<String>,},@@ -314,6 +315,7 @@ pub enum PaymentMethodUpdate {locker_fingerprint_id: Option<String>,connector_mandate_details: Option<CommonMandateReference>,external_vault_source: Option<common_utils::id_type::MerchantConnectorAccountId>,+ network_transaction_id: Option<Secret<String>>,last_modified_by: Option<String>,},ConnectorMandateDetailsUpdate {@@ -339,7 +341,7 @@ impl PaymentMethodUpdate {pub struct PaymentMethodUpdateInternal {payment_method_data: Option<Encryption>,last_used_at: Option<PrimitiveDateTime>,- network_transaction_id: Option<String>,+ network_transaction_id: Option<Secret<String>>,status: Option<storage_enums::PaymentMethodStatus>,locker_id: Option<String>,payment_method_type_v2: Option<storage_enums::PaymentMethod>,@@ -892,11 +894,11 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {locker_fingerprint_id,connector_mandate_details,external_vault_source,+ network_transaction_id,last_modified_by,} => Self {payment_method_data,last_used_at: None,- network_transaction_id: None,status,locker_id,payment_method_type_v2,@@ -909,6 +911,7 @@ impl From<PaymentMethodUpdate> for PaymentMethodUpdateInternal {network_token_payment_method_data,locker_fingerprint_id,external_vault_source,+ network_transaction_id,last_modified_by,},PaymentMethodUpdate::ConnectorMandateDetailsUpdate {@@ -1002,7 +1005,10 @@ impl From<&PaymentMethodNew> for PaymentMethod {connector_mandate_details: payment_method_new.connector_mandate_details.clone(),customer_acceptance: payment_method_new.customer_acceptance.clone(),status: payment_method_new.status,- network_transaction_id: payment_method_new.network_transaction_id.clone(),+ network_transaction_id: payment_method_new+ .network_transaction_id+ .clone()+ .map(Secret::new),client_secret: payment_method_new.client_secret.clone(),updated_by: payment_method_new.updated_by.clone(),payment_method_billing_address: payment_method_newdiff --git a/crates/hyperswitch_domain_models/src/payment_methods.rs b/crates/hyperswitch_domain_models/src/payment_methods.rsindex a443a052c6..b4ca313f85 100644--- a/crates/hyperswitch_domain_models/src/payment_methods.rs+++ b/crates/hyperswitch_domain_models/src/payment_methods.rs@@ -20,9 +20,7 @@ use common_utils::{};pub use diesel_models::{enums as storage_enums, PaymentMethodUpdate};use error_stack::ResultExt;-#[cfg(feature = "v1")]-use masking::ExposeInterface;-use masking::{PeekInterface, Secret};+use masking::{ExposeInterface, PeekInterface, Secret};#[cfg(feature = "v1")]use router_env::logger;#[cfg(feature = "v2")]@@ -563,7 +561,7 @@ impl super::behaviour::Conversion for PaymentMethod {connector_mandate_details: self.connector_mandate_details.map(|cmd| cmd.into()),customer_acceptance: self.customer_acceptance,status: self.status,- network_transaction_id: self.network_transaction_id,+ network_transaction_id: self.network_transaction_id.map(Secret::new),client_secret: self.client_secret,payment_method_billing_address: self.payment_method_billing_address@@ -676,7 +674,9 @@ impl super::behaviour::Conversion for PaymentMethod {connector_mandate_details: storage_model.connector_mandate_details.map(From::from),customer_acceptance: storage_model.customer_acceptance,status: storage_model.status,- network_transaction_id: storage_model.network_transaction_id,+ network_transaction_id: storage_model+ .network_transaction_id+ .map(ExposeInterface::expose),client_secret: storage_model.client_secret,payment_method_billing_address,updated_by: storage_model.updated_by,diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rsindex 84f24f88a1..8b47e436a2 100644--- a/crates/router/src/core/payment_methods.rs+++ b/crates/router/src/core/payment_methods.rs@@ -1317,6 +1317,7 @@ pub async fn create_payment_method_card_core(fingerprint_id,&payment_method,None,+ None,network_tokenization_resp,Some(req.payment_method_type),Some(req.payment_method_subtype),@@ -2689,6 +2690,7 @@ pub async fn create_pm_additional_data_update(vault_fingerprint_id: Option<String>,payment_method: &domain::PaymentMethod,connector_token_details: Option<payment_methods::ConnectorTokenDetails>,+ network_transaction_id: Option<Secret<String>>,nt_data: Option<NetworkTokenPaymentMethodDetails>,payment_method_type: Option<common_enums::PaymentMethod>,payment_method_subtype: Option<common_enums::PaymentMethodType>,@@ -2739,6 +2741,7 @@ pub async fn create_pm_additional_data_update(connector_mandate_details: connector_mandate_details_update,locker_fingerprint_id: vault_fingerprint_id,external_vault_source,+ network_transaction_id,last_modified_by: None,};@@ -3570,6 +3573,7 @@ pub async fn update_payment_method_core(fingerprint_id,&payment_method,request.connector_token_details,+ request.network_transaction_id,None,None,None,diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rsindex 9a2caeb915..f5f6338c09 100644--- a/crates/router/src/core/payment_methods/transformers.rs+++ b/crates/router/src/core/payment_methods/transformers.rs@@ -629,6 +629,10 @@ pub fn generate_payment_method_response(network_token,storage_type,card_cvc_token_storage,+ network_transaction_id: payment_method+ .network_transaction_id+ .clone()+ .map(Secret::new),};Ok(resp)diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex e5b6e2c03e..edccc97be4 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -3132,6 +3132,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentConfirmData<F>, types::SetupMandateReconnector_token_details: Some(connector_token_details_for_payment_method_update,),+ network_transaction_id: None,};Box::pin(payment_methods::update_payment_method_core(diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rsindex 41ad98adf2..6f8a392889 100644--- a/crates/router/src/routes/payments.rs+++ b/crates/router/src/routes/payments.rs@@ -619,6 +619,7 @@ pub async fn payments_retrieve(allow_platform_self_operation: false,};+ // checking or validatinglet (auth_type, auth_flow) = match auth::check_internal_api_key_auth(req.headers(),&payload,