Skip to content
New issue

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

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

Already on GitHub? # to your account

feat(core): Add support for card network tokenization #5599

Merged
merged 80 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
80 commits
Select commit Hold shift + click to select a range
0b1e232
insert required fields in merchant account, payment method table
prasunna09 Jul 24, 2024
a64d5c1
add support for network tokenization
prasunna09 Jul 29, 2024
038f541
move from api_models to domain_models
prasunna09 Jul 31, 2024
85061f2
fix clippy
prasunna09 Aug 1, 2024
55eaaae
fix formatting
prasunna09 Aug 1, 2024
7b4a415
Merge main
prasunna09 Aug 3, 2024
210575a
merge add-network-token-data-in-domain-models branch into this branch
prasunna09 Aug 3, 2024
b4c55d2
add network tokenization support for cybersource
prasunna09 Aug 4, 2024
d230f97
fix cit repeat
prasunna09 Aug 5, 2024
3d4707f
add token_payment_method_data in pm table, add delete api for token d…
prasunna09 Aug 12, 2024
1b2329b
merge main
prasunna09 Aug 13, 2024
b7f9735
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Aug 13, 2024
27ddfe6
fix clippy errors
prasunna09 Aug 13, 2024
d00e866
Merge branch 'add-card-network-tokenization' of github.com:juspay/hyp…
prasunna09 Aug 13, 2024
95dd43d
chore: run formatter
hyperswitch-bot[bot] Aug 13, 2024
bd9e6da
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Aug 13, 2024
079cc3d
code refactoring
prasunna09 Aug 13, 2024
3543839
code refactoring
prasunna09 Aug 13, 2024
500fd86
code refactoring
prasunna09 Aug 16, 2024
069ced9
code refactoring
prasunna09 Aug 18, 2024
e23f2c7
tokenize the card when the card network is in the list of network_tok…
prasunna09 Aug 18, 2024
ac2c2e7
Merge main
prasunna09 Aug 18, 2024
5f64f6e
Merge Main
prasunna09 Aug 20, 2024
0a3d45e
chore: run formatter
hyperswitch-bot[bot] Aug 20, 2024
ab5db97
add support for token status check
prasunna09 Aug 20, 2024
482eea7
resolve conflicts
prasunna09 Aug 20, 2024
2df9150
chore: run formatter
hyperswitch-bot[bot] Aug 20, 2024
3b7e2cc
add check_token_status_url in dev toml
prasunna09 Aug 20, 2024
ec62e2e
Merge branch 'add-card-network-tokenization' of github.com:juspay/hyp…
prasunna09 Aug 20, 2024
1f46ecb
resolve pr comments - rename the variable name
prasunna09 Aug 20, 2024
2e7a9fd
chore: run formatter
hyperswitch-bot[bot] Aug 20, 2024
20331b0
fix NT + NTI flow for mandates
prasunna09 Aug 22, 2024
e953c7b
branch rebase
prasunna09 Aug 22, 2024
34bac1b
chore: run formatter
hyperswitch-bot[bot] Aug 22, 2024
39de00b
resolve pr comments
prasunna09 Aug 23, 2024
6605c41
branch rebase
prasunna09 Aug 23, 2024
5bafdd7
fix formatting
prasunna09 Aug 23, 2024
4cb720b
remove unnecessary comments
prasunna09 Aug 23, 2024
b553c3d
code refactoring
prasunna09 Aug 27, 2024
3a15643
remove logging
prasunna09 Aug 27, 2024
238cf80
code refactoring
prasunna09 Aug 27, 2024
d690b9d
fix formatting
prasunna09 Aug 27, 2024
51f17cf
fix clippy warnings
prasunna09 Aug 27, 2024
f287f73
resolve pr comments
prasunna09 Aug 28, 2024
10c26a2
code refactoring
prasunna09 Aug 28, 2024
d05e727
merge main
prasunna09 Aug 28, 2024
4d6e5cf
chore: run formatter
hyperswitch-bot[bot] Aug 28, 2024
c39e34f
resolve pr comments
prasunna09 Aug 28, 2024
e6e7051
Merge branch 'add-card-network-tokenization' of github.com:juspay/hyp…
prasunna09 Aug 28, 2024
5b77ecc
fix ci check for schema.rs and resolve pr comments
prasunna09 Aug 29, 2024
d329609
chore: run formatter
hyperswitch-bot[bot] Aug 29, 2024
4acd4b5
add loggers for req and response
prasunna09 Aug 29, 2024
d11ad55
Merge branch 'add-card-network-tokenization' of github.com:juspay/hyp…
prasunna09 Aug 29, 2024
7505437
Merge main
prasunna09 Sep 2, 2024
93bbd53
chore: run formatter
hyperswitch-bot[bot] Sep 2, 2024
4c5368f
move the is_network_tokenization_enabled field from merchant_account …
prasunna09 Sep 2, 2024
8698710
Merge branch 'add-card-network-tokenization' of github.com:juspay/hyp…
prasunna09 Sep 2, 2024
0fde02d
fix formatting
prasunna09 Sep 2, 2024
2217b27
fix clippy
prasunna09 Sep 2, 2024
d3ffc79
code refactoring
prasunna09 Sep 3, 2024
3520578
remove unnecessary logs
prasunna09 Sep 3, 2024
f8b4287
resolve pr comments
prasunna09 Sep 5, 2024
d64f869
resolve pr comments
prasunna09 Sep 9, 2024
8c9671c
Merge main
prasunna09 Sep 10, 2024
f4e58b1
chore: run formatter
hyperswitch-bot[bot] Sep 10, 2024
461e878
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Sep 10, 2024
a4c8f1f
resolve pr comments
prasunna09 Sep 11, 2024
74bc511
resolve pr comments
prasunna09 Sep 11, 2024
21a8721
merge main
prasunna09 Sep 11, 2024
60fb2d6
code refactoring
prasunna09 Sep 11, 2024
9a67d49
fix spell check
prasunna09 Sep 11, 2024
732fdd0
resolve pr commits
prasunna09 Sep 12, 2024
2516514
add alias amex to american express card network
prasunna09 Sep 12, 2024
5d64fc4
fix clippy_v2
prasunna09 Sep 15, 2024
8377697
Merge main
prasunna09 Sep 15, 2024
a3fd0da
chore: run formatter
hyperswitch-bot[bot] Sep 15, 2024
86dd665
docs(openapi): re-generate OpenAPI specification
hyperswitch-bot[bot] Sep 15, 2024
1ee4b3d
fix clippy_v2
prasunna09 Sep 15, 2024
cb345ce
Merge branch 'add-card-network-tokenization' of github.com:juspay/hyp…
prasunna09 Sep 15, 2024
f3268af
merge main
prasunna09 Sep 16, 2024
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
13 changes: 12 additions & 1 deletion api-reference-v2/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -4166,6 +4166,10 @@
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
},
"is_network_tokenization_enabled": {
"type": "boolean",
"description": "Indicates if is_network_tokenization_enabled is enabled or not.\nIf set to `true` is_network_tokenization_enabled will be checked."
}
},
"additionalProperties": false
Expand All @@ -4178,7 +4182,8 @@
"profile_name",
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post",
"is_tax_connector_enabled"
"is_tax_connector_enabled",
"is_network_tokenization_enabled"
],
"properties": {
"merchant_id": {
Expand Down Expand Up @@ -4348,6 +4353,12 @@
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
},
"is_network_tokenization_enabled": {
"type": "boolean",
"description": "Indicates if is_network_tokenization_enabled is enabled or not.\nIf set to `true` is_network_tokenization_enabled will be checked.",
"default": false,
"example": false
}
}
},
Expand Down
13 changes: 12 additions & 1 deletion api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -7959,6 +7959,10 @@
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
},
"is_network_tokenization_enabled": {
"type": "boolean",
"description": "Indicates if is_network_tokenization_enabled is enabled or not.\nIf set to `true` is_network_tokenization_enabled will be checked."
}
},
"additionalProperties": false
Expand All @@ -7971,7 +7975,8 @@
"profile_name",
"enable_payment_response_hash",
"redirect_to_merchant_with_http_post",
"is_tax_connector_enabled"
"is_tax_connector_enabled",
"is_network_tokenization_enabled"
],
"properties": {
"merchant_id": {
Expand Down Expand Up @@ -8150,6 +8155,12 @@
"is_tax_connector_enabled": {
"type": "boolean",
"description": "Indicates if tax_calculator connector is enabled or not.\nIf set to `true` tax_connector_id will be checked."
},
"is_network_tokenization_enabled": {
"type": "boolean",
"description": "Indicates if is_network_tokenization_enabled is enabled or not.\nIf set to `true` is_network_tokenization_enabled will be checked.",
"default": false,
"example": false
}
}
},
Expand Down
16 changes: 16 additions & 0 deletions config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -730,3 +730,19 @@ connector_list = ""

[recipient_emails]
recon = "test@example.com"

[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard" # Supported card networks for network tokenization

[network_tokenization_service] # Network Tokenization Service Configuration
generate_token_url= "" # base url to generate token
fetch_token_url= "" # base url to fetch token
token_service_api_key= "" # api key for token service
public_key= "" # public key to encrypt data for token service
private_key= "" # private key to decrypt response payload from token service
key_id= "" # key id to encrypt data for token service
delete_token_url= "" # base url to delete token from token service
check_token_status_url= "" # base url to check token status from token service

[network_tokenization_supported_connectors]
connector_list = "cybersource" # Supported connectors for network tokenization
10 changes: 10 additions & 0 deletions config/deployments/env_specific.toml
Original file line number Diff line number Diff line change
Expand Up @@ -302,3 +302,13 @@ encryption_key = "user_auth_table_encryption_key" # Encryption key used for encr

[recipient_emails]
recon = "recon@example.com"

[network_tokenization_service] # Network Tokenization Service Configuration
generate_token_url= "" # base url to generate token
fetch_token_url= "" # base url to fetch token
token_service_api_key= "" # api key for token service
public_key= "" # public key to encrypt data for token service
private_key= "" # private key to decrypt response payload from token service
key_id= "" # key id to encrypt data for token service
delete_token_url= "" # base url to delete token from token service
check_token_status_url= "" # base url to check token status from token service
8 changes: 7 additions & 1 deletion config/deployments/integration_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -373,4 +373,10 @@ keys = "accept-language,user-agent"
sdk_eligible_payment_methods = "card"

[locker_based_open_banking_connectors]
connector_list = ""
connector_list = ""

[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"

[network_tokenization_supported_connectors]
connector_list = "cybersource"
8 changes: 7 additions & 1 deletion config/deployments/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -386,4 +386,10 @@ keys = "accept-language,user-agent"
sdk_eligible_payment_methods = "card"

[locker_based_open_banking_connectors]
connector_list = ""
connector_list = ""

[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"

[network_tokenization_supported_connectors]
connector_list = "cybersource"
8 changes: 7 additions & 1 deletion config/deployments/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -390,4 +390,10 @@ keys = "accept-language,user-agent"
sdk_eligible_payment_methods = "card"

[locker_based_open_banking_connectors]
connector_list = ""
connector_list = ""

[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"

[network_tokenization_supported_connectors]
connector_list = "cybersource"
6 changes: 6 additions & 0 deletions config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -734,3 +734,9 @@ connector_list = ""

[recipient_emails]
recon = "recon@example.com"

[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"

[network_tokenization_supported_connectors]
connector_list = "cybersource"
16 changes: 16 additions & 0 deletions config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -593,3 +593,19 @@ connector_list = ""

[recipient_emails]
recon = "recon@example.com"

[network_tokenization_supported_card_networks]
card_networks = "Visa, AmericanExpress, Mastercard"

[network_tokenization_service]
generate_token_url= ""
fetch_token_url= ""
token_service_api_key= ""
public_key= ""
private_key= ""
key_id= ""
delete_token_url= ""
check_token_status_url= ""

[network_tokenization_supported_connectors]
connector_list = "cybersource"
26 changes: 26 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1917,6 +1917,11 @@ pub struct BusinessProfileCreate {
/// If set to `true` tax_connector_id will be checked.
#[serde(default)]
pub is_tax_connector_enabled: bool,

/// Indicates if is_network_tokenization_enabled is enabled or not.
prasunna09 marked this conversation as resolved.
Show resolved Hide resolved
/// If set to `true` is_network_tokenization_enabled will be checked.
#[serde(default)]
pub is_network_tokenization_enabled: bool,
}

#[nutype::nutype(
Expand Down Expand Up @@ -2021,6 +2026,11 @@ pub struct BusinessProfileCreate {
/// If set to `true` tax_connector_id will be checked.
#[serde(default)]
pub is_tax_connector_enabled: bool,

/// Indicates if is_network_tokenization_enabled is enabled or not.
/// If set to `true` is_network_tokenization_enabled will be checked.
#[serde(default)]
pub is_network_tokenization_enabled: bool,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -2138,6 +2148,11 @@ pub struct BusinessProfileResponse {
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: bool,

/// Indicates if is_network_tokenization_enabled is enabled or not.
/// If set to `true` is_network_tokenization_enabled will be checked.
#[schema(default = false, example = false)]
pub is_network_tokenization_enabled: bool,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -2246,6 +2261,11 @@ pub struct BusinessProfileResponse {
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: bool,

/// Indicates if is_network_tokenization_enabled is enabled or not.
/// If set to `true` is_network_tokenization_enabled will be checked.
#[schema(default = false, example = false)]
pub is_network_tokenization_enabled: bool,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -2359,6 +2379,9 @@ pub struct BusinessProfileUpdate {
/// Indicates if dynamic routing is enabled or not.
#[serde(default)]
pub dynamic_routing_algorithm: Option<serde_json::Value>,

/// Indicates if is_network_tokenization_enabled is enabled or not.
pub is_network_tokenization_enabled: Option<bool>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -2459,6 +2482,9 @@ pub struct BusinessProfileUpdate {
/// Indicates if tax_calculator connector is enabled or not.
/// If set to `true` tax_connector_id will be checked.
pub is_tax_connector_enabled: Option<bool>,

/// Indicates if is_network_tokenization_enabled is enabled or not.
pub is_network_tokenization_enabled: Option<bool>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
Expand Down
10 changes: 9 additions & 1 deletion crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,15 @@ pub struct MandateIds {
#[derive(Eq, PartialEq, Debug, serde::Deserialize, serde::Serialize, Clone)]
pub enum MandateReferenceId {
ConnectorMandateId(ConnectorMandateReferenceId), // mandate_id send by connector
NetworkMandateId(String), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns
NetworkMandateId(String), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with card data
NetworkTokenWithNTI(NetworkTokenWithNTIRef), // network_txns_id send by Issuer to connector, Used for PG agnostic mandate txns along with network token data
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
pub struct NetworkTokenWithNTIRef {
pub network_transaction_id: String,
pub token_exp_month: Option<Secret<String>>,
pub token_exp_year: Option<Secret<String>>,
}

#[derive(Debug, serde::Deserialize, serde::Serialize, Clone, Eq, PartialEq)]
Expand Down
11 changes: 11 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1781,16 +1781,27 @@ pub enum MandateStatus {
)]
#[router_derive::diesel_enum(storage_type = "text")]
pub enum CardNetwork {
#[serde(alias = "VISA")]
prasunna09 marked this conversation as resolved.
Show resolved Hide resolved
Visa,
#[serde(alias = "MASTERCARD")]
Mastercard,
#[serde(alias = "AMERICANEXPRESS")]
#[serde(alias = "AMEX")]
AmericanExpress,
JCB,
#[serde(alias = "DINERSCLUB")]
DinersClub,
#[serde(alias = "DISCOVER")]
Discover,
#[serde(alias = "CARTESBANCAIRES")]
CartesBancaires,
#[serde(alias = "UNIONPAY")]
UnionPay,
#[serde(alias = "INTERAC")]
Interac,
#[serde(alias = "RUPAY")]
RuPay,
#[serde(alias = "MAESTRO")]
Maestro,
}

Expand Down
13 changes: 13 additions & 0 deletions crates/diesel_models/src/business_profile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct BusinessProfile {
pub is_tax_connector_enabled: Option<bool>,
pub version: common_enums::ApiVersion,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: bool,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -94,6 +95,7 @@ pub struct BusinessProfileNew {
pub tax_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
pub is_tax_connector_enabled: Option<bool>,
pub version: common_enums::ApiVersion,
pub is_network_tokenization_enabled: bool,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -131,6 +133,7 @@ pub struct BusinessProfileUpdateInternal {
pub tax_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
pub is_tax_connector_enabled: Option<bool>,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: Option<bool>,
}

#[cfg(feature = "v1")]
Expand Down Expand Up @@ -167,6 +170,7 @@ impl BusinessProfileUpdateInternal {
tax_connector_id,
is_tax_connector_enabled,
dynamic_routing_algorithm,
is_network_tokenization_enabled,
} = self;
BusinessProfile {
profile_id: source.profile_id,
Expand Down Expand Up @@ -222,6 +226,8 @@ impl BusinessProfileUpdateInternal {
version: source.version,
dynamic_routing_algorithm: dynamic_routing_algorithm
.or(source.dynamic_routing_algorithm),
is_network_tokenization_enabled: is_network_tokenization_enabled
.unwrap_or(source.is_network_tokenization_enabled),
}
}
}
Expand Down Expand Up @@ -272,6 +278,7 @@ pub struct BusinessProfile {
pub id: common_utils::id_type::ProfileId,
pub version: common_enums::ApiVersion,
pub dynamic_routing_algorithm: Option<serde_json::Value>,
pub is_network_tokenization_enabled: bool,
}

impl BusinessProfile {
Expand Down Expand Up @@ -326,6 +333,7 @@ pub struct BusinessProfileNew {
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub id: common_utils::id_type::ProfileId,
pub version: common_enums::ApiVersion,
pub is_network_tokenization_enabled: bool,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -364,6 +372,7 @@ pub struct BusinessProfileUpdateInternal {
pub frm_routing_algorithm_id: Option<String>,
pub payout_routing_algorithm_id: Option<common_utils::id_type::RoutingId>,
pub default_fallback_routing: Option<pii::SecretSerdeValue>,
pub is_network_tokenization_enabled: Option<bool>,
}

#[cfg(feature = "v2")]
Expand Down Expand Up @@ -401,6 +410,7 @@ impl BusinessProfileUpdateInternal {
frm_routing_algorithm_id,
payout_routing_algorithm_id,
default_fallback_routing,
is_network_tokenization_enabled,
} = self;
BusinessProfile {
id: source.id,
Expand Down Expand Up @@ -459,6 +469,8 @@ impl BusinessProfileUpdateInternal {
default_fallback_routing: default_fallback_routing.or(source.default_fallback_routing),
version: source.version,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: is_network_tokenization_enabled
.unwrap_or(source.is_network_tokenization_enabled),
}
}
}
Expand Down Expand Up @@ -510,6 +522,7 @@ impl From<BusinessProfileNew> for BusinessProfile {
default_fallback_routing: new.default_fallback_routing,
version: new.version,
dynamic_routing_algorithm: None,
is_network_tokenization_enabled: new.is_network_tokenization_enabled,
}
}
}
Expand Down
Loading
Loading