feat(network_tokenization): Use NT credentials from domain tables#11614
Open
Sarthak1799 wants to merge 17 commits intomainfrom
Open
feat(network_tokenization): Use NT credentials from domain tables#11614Sarthak1799 wants to merge 17 commits intomainfrom
Sarthak1799 wants to merge 17 commits intomainfrom
Conversation
prasunna09
reviewed
Mar 26, 2026
Comment on lines
342
to
344
| let webhook_source_verification_key = secret_management_client | ||
| .get_secret(network_tokenization.webhook_source_verification_key.clone()) | ||
| .await?; |
Contributor
There was a problem hiding this comment.
this can also be optional, and add the webhook_source_verification_key with merchant specific network token creds
| pub public_key: Secret<String>, | ||
| pub private_key: Secret<String>, | ||
| pub key_id: String, | ||
| pub token_service_api_key: Option<Secret<String>>, |
Contributor
There was a problem hiding this comment.
this keys can be removed from config
| last_used_at: Some(common_utils::date_time::now()), | ||
| connector_mandate_details: None, | ||
| network_tokenization_data: None, // setting this to None as write path will be introduced in a later PR | ||
| network_tokenization_data: network_tokenization_data.map(Into::into), |
Contributor
There was a problem hiding this comment.
use From::from instead of Into, for traversing
| .and_then(|initiator| initiator.to_created_by()) | ||
| .map(|last_modified_by| last_modified_by.to_string()), | ||
| network_tokenization_data: None, // setting this to None as write path will be introduced in a later PR | ||
| network_tokenization_data: network_tokenization_data.map(Into::into), |
| last_used_at: None, | ||
| connector_mandate_details: connector_mandate_details_value.map(Box::new), | ||
| network_tokenization_data: None, // setting this to None as write path will be introduced in a later PR | ||
| network_tokenization_data: network_tokenization_data.map(Into::into), |
| .and_then(|decrypted_val| { | ||
| serde_json::from_value::<domain::PaymentMethodsData>(decrypted_val) | ||
| .map_err(|_| { | ||
| errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured |
| network_token_payment_method_data: nt_card_data.to_owned(), | ||
| }; | ||
|
|
||
| let mut map = HashMap::new(); |
Contributor
There was a problem hiding this comment.
please use proper naming
Comment on lines
+2156
to
+2164
| let encrypted_network_tokenization_data = create_encrypted_data( | ||
| &key_manager_state, | ||
| platform.get_provider().get_key_store(), | ||
| network_token_data_domain.clone(), | ||
| ) | ||
| .await | ||
| .change_context(errors::ApiErrorResponse::InternalServerError) | ||
| .attach_printable("Unable to encrypt payment method data") | ||
| .ok(); |
Contributor
There was a problem hiding this comment.
please verify if it is possible to store without encryption
| serde_json::from_value::<domain::PaymentMethodNetworkTokenizationDataDomainType>( | ||
| decrypted_val, | ||
| ) | ||
| .map_err(|_| errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured) |
Contributor
There was a problem hiding this comment.
please use proper error
| serde_json::from_value::<domain::PaymentMethodNetworkTokenizationDataDomainType>( | ||
| decrypted_val, | ||
| ) | ||
| .map_err(|_| errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Type of Change
Description
This pull request introduces support for storing and managing network tokenization credentials for merchant accounts and business profiles. The changes span API models, OpenAPI specification, and database models to enable secure handling of credentials required for network tokenization providers. The most important changes are summarized below:
API Model and OpenAPI Specification Updates
NetworkTokeizationProviderCredentialsandInternalNetworkTokenizationCredentialsto both the Rust API models (crates/api_models/src/admin.rs) and the OpenAPI spec (api-reference/v1/openapi_spec_v1.json), defining the structure for network tokenization credentials, including API key, public/private keys, and key ID. [1] [2] [3]MerchantAccountCreate,MerchantAccountUpdate,MerchantAccountResponse,ProfileCreate,ProfileUpdate, andProfileResponsestructs to include an optionalnetwork_tokenization_credentialsfield, allowing these credentials to be set and retrieved via the API. [1] [2] [3] [4] [5] [6]Database Model Changes
network_tokenization_credentialsfield (of typeEncryption) to theMerchantAccount,MerchantAccountNew,MerchantAccountSetter,MerchantAccountUpdateInternal,Profile,ProfileNew, andProfileUpdateInternalstructs in the Diesel models, enabling storage of these credentials in the database. [1] [2] [3] [4] [5] [6] [7] [8] [9]These changes collectively enable secure configuration and management of network tokenization provider credentials for merchants and business profiles throughout the system.
Additional Changes
Motivation and Context
How did you test it?
Response -
DB -

Platform merchant
Response -
Checklist
cargo +nightly fmt --allcargo clippy