Skip to content

feat(network_tokenization): Use NT credentials from domain tables#11614

Open
Sarthak1799 wants to merge 17 commits intomainfrom
nt-creds-application-dev
Open

feat(network_tokenization): Use NT credentials from domain tables#11614
Sarthak1799 wants to merge 17 commits intomainfrom
nt-creds-application-dev

Conversation

@Sarthak1799
Copy link
Contributor

@Sarthak1799 Sarthak1799 commented Mar 25, 2026

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

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

  • Added new types NetworkTokeizationProviderCredentials and InternalNetworkTokenizationCredentials to 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]
  • Extended the MerchantAccountCreate, MerchantAccountUpdate, MerchantAccountResponse, ProfileCreate, ProfileUpdate, and ProfileResponse structs to include an optional network_tokenization_credentials field, allowing these credentials to be set and retrieved via the API. [1] [2] [3] [4] [5] [6]
  • Updated the OpenAPI spec to include the new credentials field in relevant schemas, ensuring API documentation and validation support for the new property. [1] [2] [3] [4] [5]

Database Model Changes

  • Added an optional network_tokenization_credentials field (of type Encryption) to the MerchantAccount, MerchantAccountNew, MerchantAccountSetter, MerchantAccountUpdateInternal, Profile, ProfileNew, and ProfileUpdateInternal structs in the Diesel models, enabling storage of these credentials in the database. [1] [2] [3] [4] [5] [6] [7] [8] [9]
  • Updated conversion and update logic to handle the new field in model transformations and patch operations. [1] [2] [3] [4] [5] [6] [7]

These changes collectively enable secure configuration and management of network tokenization provider credentials for merchants and business profiles throughout the system.

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

Motivation and Context

How did you test it?

  1. Create a merchant account with NT credentials
  2. Enable network_tokenization for profile
  3. Create a Payment (new customer)-
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_p0fOwFCE7RaNkOmmuZCjWlOaSgDhmsiRxyuD9NZjul9seCsizLaH6vrviFT52zV6' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "profile_id": "pro_s7iIAe0TjGBSM0M3nQKd",
    "amount_to_capture": 100,
    "customer_id": "stripeCust119",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "Hello",
            "last_name": "World"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS"
}
'
  1. payment confirm -
curl --location 'http://localhost:8080/payments/pay_V8Pdi3RrnL8NyMXSFoEP/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_p0fOwFCE7RaNkOmmuZCjWlOaSgDhmsiRxyuD9NZjul9seCsizLaH6vrviFT52zV6' \
--data '{
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "05",
            "card_exp_year": "31",
            "card_holder_name": "Hello World",
            "card_cvc": "170",
            "card_network": "Mastercard"
        }
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "127.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    "setup_future_usage": "on_session",  
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}
'

Response -

{
   "payment_id":"pay_V8Pdi3RrnL8NyMXSFoEP",
   "merchant_id":"merchant_1774432350",
   "status":"succeeded",
   "amount":100,
   "net_amount":100,
   "shipping_cost":null,
   "amount_capturable":0,
   "amount_received":100,
   "processor_merchant_id":"merchant_1774432350",
   "initiator":null,
   "sdk_authorization":"cHJvZmlsZV9pZD1wcm9fczdpSUFlMFRqR0JTTTBNM25RS2QscHVibGlzaGFibGVfa2V5PXBrX2Rldl9kZTlhMmVkZWIyMGU0NDQ0YWY3OGIwZDU2Y2VjYmU1MSxjbGllbnRfc2VjcmV0PXBheV9WOFBkaTNScm5MOE55TVhTRm9FUF9zZWNyZXRfajRBcUVCb1lHZGdWUkVKbHpYVDYsY3VzdG9tZXJfaWQ9c3RyaXBlQ3VzdDExOQ==",
   "connector":"cybersource",
   "state_metadata":null,
   "client_secret":"pay_V8Pdi3RrnL8NyMXSFoEP_secret_j4AqEBoYGdgVREJlzXT6",
   "created":"2026-03-25T10:23:08.428Z",
   "modified_at":"2026-03-25T10:23:22.676Z",
   "currency":"USD",
   "customer_id":"stripeCust119",
   "customer":{
      "id":"stripeCust119",
      "name":"John Doe",
      "email":"guest@example.com",
      "phone":"999999999",
      "phone_country_code":"+65",
      "customer_document_details":null
   },
   "description":"Its my first payment request",
   "refunds":null,
   "disputes":null,
   "mandate_id":null,
   "mandate_data":null,
   "setup_future_usage":"on_session",
   "off_session":null,
   "capture_on":null,
   "capture_method":"automatic",
   "payment_method":"card",
   "payment_method_data":{
      "card":{
         "last4":"1290",
         "card_type":null,
         "card_network":null,
         "card_issuer":null,
         "card_issuing_country":null,
         "card_isin":"552260",
         "card_extended_bin":null,
         "card_exp_month":"05",
         "card_exp_year":"31",
         "card_holder_name":"Hello World",
         "payment_checks":{
            "avs_response":{
               "code":"Y",
               "codeRaw":"Y"
            },
            "card_verification":null
         },
         "authentication_data":null,
         "auth_code":null
      },
      "billing":null
   },
   "payment_token":"token_JIfUiLupYMd994QomwQc",
   "shipping":{
      "address":{
         "city":"San Fransico",
         "country":"US",
         "line1":"1467",
         "line2":"Harrison Street",
         "line3":"Harrison Street",
         "zip":"94122",
         "state":"California",
         "first_name":"joseph",
         "last_name":"Doe",
         "origin_zip":null
      },
      "phone":{
         "number":"8056594427",
         "country_code":"+91"
      },
      "email":null
   },
   "billing":{
      "address":{
         "city":"San Fransico",
         "country":"US",
         "line1":"1467",
         "line2":"Harrison Street",
         "line3":"Harrison Street",
         "zip":"94122",
         "state":"California",
         "first_name":"Hello",
         "last_name":"World",
         "origin_zip":null
      },
      "phone":{
         "number":"8056594427",
         "country_code":"+91"
      },
      "email":null
   },
   "order_details":null,
   "email":"guest@example.com",
   "name":"John Doe",
   "phone":"999999999",
   "return_url":"https://google.com/",
   "authentication_type":"no_three_ds",
   "statement_descriptor_name":"joseph",
   "statement_descriptor_suffix":"JS",
   "next_action":null,
   "cancellation_reason":null,
   "error_code":null,
   "error_message":null,
   "unified_code":null,
   "unified_message":null,
   "error_details":null,
   "payment_experience":null,
   "payment_method_type":"credit",
   "connector_label":null,
   "business_country":null,
   "business_label":"default",
   "business_sub_label":null,
   "allowed_payment_method_types":null,
   "manual_retry_allowed":null,
   "connector_transaction_id":"7744342023816730904806",
   "frm_message":null,
   "metadata":{
      "udf1":"value1",
      "login_date":"2019-09-10T10:11:12Z",
      "new_customer":"true"
   },
   "connector_metadata":null,
   "connector_response_metadata":null,
   "feature_metadata":{
      "redirect_response":null,
      "search_tags":null,
      "apple_pay_recurring_details":null,
      "pix_additional_details":null,
      "boleto_additional_details":null
   },
   "reference_id":"pay_V8Pdi3RrnL8NyMXSFoEP_1",
   "payment_link":null,
   "profile_id":"pro_s7iIAe0TjGBSM0M3nQKd",
   "surcharge_details":null,
   "attempt_count":1,
   "merchant_decision":null,
   "merchant_connector_id":"mca_PuKc8d4W1Cw0lASb351L",
   "incremental_authorization_allowed":false,
   "authorization_count":null,
   "incremental_authorizations":null,
   "external_authentication_details":null,
   "external_3ds_authentication_attempted":false,
   "expires_on":"2026-03-25T10:38:08.428Z",
   "fingerprint":null,
   "browser_info":{
      "os_type":null,
      "referer":null,
      "language":null,
      "time_zone":null,
      "ip_address":"::1",
      "os_version":null,
      "user_agent":null,
      "color_depth":null,
      "device_model":null,
      "java_enabled":null,
      "screen_width":null,
      "accept_header":null,
      "screen_height":null,
      "accept_language":"en",
      "java_script_enabled":null
   },
   "payment_channel":null,
   "payment_method_id":"pm_A6RcQXebPHlRMUeIAdVM",
   "network_transaction_id":"0602MCC603474",
   "payment_method_status":"active",
   "updated":"2026-03-25T10:23:22.676Z",
   "split_payments":null,
   "frm_metadata":null,
   "extended_authorization_applied":null,
   "extended_authorization_last_applied_at":null,
   "request_extended_authorization":null,
   "capture_before":null,
   "merchant_order_reference_id":null,
   "order_tax_amount":null,
   "connector_mandate_id":null,
   "card_discovery":"manual",
   "force_3ds_challenge":false,
   "force_3ds_challenge_trigger":false,
   "issuer_error_code":null,
   "issuer_error_message":null,
   "is_iframe_redirection_enabled":null,
   "whole_connector_response":null,
   "enable_partial_authorization":null,
   "enable_overcapture":null,
   "is_overcapture_enabled":null,
   "network_details":null,
   "is_stored_credential":null,
   "mit_category":null,
   "billing_descriptor":null,
   "tokenization":null,
   "partner_merchant_identifier_details":null,
   "payment_method_tokenization_details":{
      "payment_method_id":"pm_A6RcQXebPHlRMUeIAdVM",
      "payment_method_status":"active",
      "psp_tokenization":false,
      "network_tokenization":true,
      "network_transaction_id":null,
      "is_eligible_for_mit_payment":false
   },
   "installment_options":null,
   "installment_data":null
}

DB -
image

  1. Create a payment (saved payment_method)
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_p0fOwFCE7RaNkOmmuZCjWlOaSgDhmsiRxyuD9NZjul9seCsizLaH6vrviFT52zV6' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "profile_id": "pro_s7iIAe0TjGBSM0M3nQKd",
    "amount_to_capture": 100,
    "customer_id": "stripeCust119",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "Hello",
            "last_name": "World"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
  
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS"
}
'

Platform merchant

  1. Create a Platform merchant
  2. Create a connected merchant
  3. Create a payment
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_DyyyR58otJYmzPXhKsDtyA0sHg74d6xPZDw78GzV7QKezhSBn5f9RtRZANHn56I1' \
--data-raw '{
    "amount": 100,
    "currency": "USD",
    "confirm": false,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "profile_id": "pro_dwX0LMex5mSUgERvboyp",
    "amount_to_capture": 100,
    "customer_id": "cus_krQU5kjHpzF5TSVEtFx7",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "Hello",
            "last_name": "World"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS"
}
'
  1. Confirm the payment -
curl --location 'http://localhost:8080/payments/pay_NnzeQ7Fs8bbVsKsm2jT8/confirm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_DyyyR58otJYmzPXhKsDtyA0sHg74d6xPZDw78GzV7QKezhSBn5f9RtRZANHn56I1' \
--data '{
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "5522604002511290",
            "card_exp_month": "05",
            "card_exp_year": "31",
            "card_holder_name": "Hello World",
            "card_cvc": "170",
            "card_network": "Mastercard"
        }
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "127.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    "setup_future_usage": "on_session",

    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    }
}
'

Response -

{
   "payment_id":"pay_NnzeQ7Fs8bbVsKsm2jT8",
   "merchant_id":"merchant_1774514046",
   "status":"succeeded",
   "amount":100,
   "net_amount":100,
   "shipping_cost":null,
   "amount_capturable":0,
   "amount_received":100,
   "processor_merchant_id":"merchant_1774514088",
   "initiator":"connected",
   "sdk_authorization":"cHJvZmlsZV9pZD1wcm9fZHdYMExNZXg1bVNVZ0VSdmJveXAscHVibGlzaGFibGVfa2V5PXBrX2Rldl9kODk4MWE2MGQ5MmI0ODI0OTU4YTgxYmRmYjNkMGRjYSxjbGllbnRfc2VjcmV0PXBheV9ObnplUTdGczhiYlZzS3NtMmpUOF9zZWNyZXRfeGdiektuNDlXbjNNSE9PeHVBTkIsY3VzdG9tZXJfaWQ9Y3VzX2tyUVU1a2pIcHpGNVRTVkV0Rng3",
   "connector":"cybersource",
   "state_metadata":null,
   "client_secret":"pay_NnzeQ7Fs8bbVsKsm2jT8_secret_xgbzKn49Wn3MHOOxuANB",
   "created":"2026-03-26T08:48:11.157Z",
   "modified_at":"2026-03-26T08:48:41.754Z",
   "currency":"USD",
   "customer_id":"cus_krQU5kjHpzF5TSVEtFx7",
   "customer":{
      "id":"cus_krQU5kjHpzF5TSVEtFx7",
      "name":"John Doe",
      "email":"guest@example.com",
      "phone":"999999999",
      "phone_country_code":"+65",
      "customer_document_details":null
   },
   "description":"Its my first payment request",
   "refunds":null,
   "disputes":null,
   "mandate_id":null,
   "mandate_data":null,
   "setup_future_usage":"on_session",
   "off_session":null,
   "capture_on":null,
   "capture_method":"automatic",
   "payment_method":"card",
   "payment_method_data":{
      "card":{
         "last4":"1290",
         "card_type":null,
         "card_network":null,
         "card_issuer":null,
         "card_issuing_country":null,
         "card_isin":"552260",
         "card_extended_bin":null,
         "card_exp_month":"05",
         "card_exp_year":"31",
         "card_holder_name":"Hello World",
         "payment_checks":{
            "avs_response":{
               "code":"Y",
               "codeRaw":"Y"
            },
            "card_verification":null
         },
         "authentication_data":null,
         "auth_code":null
      },
      "billing":null
   },
   "payment_token":"token_bXR95kDZFv7yAdg8jV10",
   "shipping":{
      "address":{
         "city":"San Fransico",
         "country":"US",
         "line1":"1467",
         "line2":"Harrison Street",
         "line3":"Harrison Street",
         "zip":"94122",
         "state":"California",
         "first_name":"joseph",
         "last_name":"Doe",
         "origin_zip":null
      },
      "phone":{
         "number":"8056594427",
         "country_code":"+91"
      },
      "email":null
   },
   "billing":{
      "address":{
         "city":"San Fransico",
         "country":"US",
         "line1":"1467",
         "line2":"Harrison Street",
         "line3":"Harrison Street",
         "zip":"94122",
         "state":"California",
         "first_name":"Hello",
         "last_name":"World",
         "origin_zip":null
      },
      "phone":{
         "number":"8056594427",
         "country_code":"+91"
      },
      "email":null
   },
   "order_details":null,
   "email":"guest@example.com",
   "name":"John Doe",
   "phone":"999999999",
   "return_url":"https://google.com/",
   "authentication_type":"no_three_ds",
   "statement_descriptor_name":"joseph",
   "statement_descriptor_suffix":"JS",
   "next_action":null,
   "cancellation_reason":null,
   "error_code":null,
   "error_message":null,
   "unified_code":null,
   "unified_message":null,
   "error_details":null,
   "payment_experience":null,
   "payment_method_type":"credit",
   "connector_label":null,
   "business_country":null,
   "business_label":"default",
   "business_sub_label":null,
   "allowed_payment_method_types":null,
   "manual_retry_allowed":null,
   "connector_transaction_id":"7745149213516358904807",
   "frm_message":null,
   "metadata":{
      "udf1":"value1",
      "login_date":"2019-09-10T10:11:12Z",
      "new_customer":"true"
   },
   "connector_metadata":null,
   "connector_response_metadata":null,
   "feature_metadata":{
      "redirect_response":null,
      "search_tags":null,
      "apple_pay_recurring_details":null,
      "pix_additional_details":null,
      "boleto_additional_details":null
   },
   "reference_id":"pay_NnzeQ7Fs8bbVsKsm2jT8_1",
   "payment_link":null,
   "profile_id":"pro_dwX0LMex5mSUgERvboyp",
   "surcharge_details":null,
   "attempt_count":1,
   "merchant_decision":null,
   "merchant_connector_id":"mca_5POlOzBiXYdPRWPYpTKe",
   "incremental_authorization_allowed":false,
   "authorization_count":null,
   "incremental_authorizations":null,
   "external_authentication_details":null,
   "external_3ds_authentication_attempted":false,
   "expires_on":"2026-03-26T09:03:11.157Z",
   "fingerprint":null,
   "browser_info":{
      "os_type":null,
      "referer":null,
      "language":null,
      "time_zone":null,
      "ip_address":"::1",
      "os_version":null,
      "user_agent":null,
      "color_depth":null,
      "device_model":null,
      "java_enabled":null,
      "screen_width":null,
      "accept_header":null,
      "screen_height":null,
      "accept_language":"en",
      "java_script_enabled":null
   },
   "payment_channel":null,
   "payment_method_id":"pm_4NVdLriYeG42ZluRCtE3",
   "network_transaction_id":"0602MCC603474",
   "payment_method_status":"active",
   "updated":"2026-03-26T08:48:41.754Z",
   "split_payments":null,
   "frm_metadata":null,
   "extended_authorization_applied":null,
   "extended_authorization_last_applied_at":null,
   "request_extended_authorization":null,
   "capture_before":null,
   "merchant_order_reference_id":null,
   "order_tax_amount":null,
   "connector_mandate_id":null,
   "card_discovery":"manual",
   "force_3ds_challenge":false,
   "force_3ds_challenge_trigger":false,
   "issuer_error_code":null,
   "issuer_error_message":null,
   "is_iframe_redirection_enabled":null,
   "whole_connector_response":null,
   "enable_partial_authorization":null,
   "enable_overcapture":null,
   "is_overcapture_enabled":null,
   "network_details":null,
   "is_stored_credential":null,
   "mit_category":null,
   "billing_descriptor":null,
   "tokenization":null,
   "partner_merchant_identifier_details":null,
   "payment_method_tokenization_details":{
      "payment_method_id":"pm_4NVdLriYeG42ZluRCtE3",
      "payment_method_status":"active",
      "psp_tokenization":false,
      "network_tokenization":true,
      "network_transaction_id":null,
      "is_eligible_for_mit_payment":false
   },
   "installment_options":null,
   "installment_data":null
}

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed the submitted code
  • I added unit tests for my changes where possible

@Sarthak1799 Sarthak1799 self-assigned this Mar 25, 2026
@Sarthak1799 Sarthak1799 requested review from a team as code owners March 25, 2026 11:08
@hyperswitch-bot hyperswitch-bot bot added M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Mar 25, 2026
@hyperswitch-bot hyperswitch-bot bot removed M-database-changes Metadata: This PR involves database schema changes M-api-contract-changes Metadata: This PR involves API contract changes labels Mar 25, 2026
@Sarthak1799 Sarthak1799 added the A-payment-methods Area: Payment Methods label Mar 25, 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?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

.and_then(|decrypted_val| {
serde_json::from_value::<domain::PaymentMethodsData>(decrypted_val)
.map_err(|_| {
errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

populate proper error

network_token_payment_method_data: nt_card_data.to_owned(),
};

let mut map = HashMap::new();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please verify if it is possible to store without encryption

serde_json::from_value::<domain::PaymentMethodNetworkTokenizationDataDomainType>(
decrypted_val,
)
.map_err(|_| errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please use proper error

serde_json::from_value::<domain::PaymentMethodNetworkTokenizationDataDomainType>(
decrypted_val,
)
.map_err(|_| errors::NetworkTokenizationError::NetworkTokenizationServiceNotConfigured)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-payment-methods Area: Payment Methods

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants