feat(core): [Network Tokenization] pre network tokenization#6873
feat(core): [Network Tokenization] pre network tokenization#6873likhinbopanna merged 3 commits intomainfrom
Conversation
276d588 to
5c13cc8
Compare
a5845b1 to
3f9c0ba
Compare
16e0f52 to
dcc8625
Compare
prasunna09
left a comment
There was a problem hiding this comment.
also when constructing router data, if pre-tokenization enabled, we need to pass network token data as payment method data. Could you point me to that change?
crates/router/src/core/payments.rs
Outdated
There was a problem hiding this comment.
can this validation for pre-network tokenization move to a a function?
crates/router/src/core/payments.rs
Outdated
There was a problem hiding this comment.
why are we ignoring this token_ref? this should be set in payment method info right?
crates/router/src/core/payments.rs
Outdated
There was a problem hiding this comment.
do no filter out. check only if the connector decided by routing is in the network tokenization supported connectors. this is because routing should always be prioritized over any feature. please remove this.
crates/router/src/core/payments.rs
Outdated
There was a problem hiding this comment.
since this is same logic, can you write this to a common function?
4c8d6a4 to
7563104
Compare
crates/api_models/src/admin.rs
Outdated
|
|
||
| /// Indicates if network tokenization before first payment is enabled or not | ||
| #[serde(default)] | ||
| pub is_tokenize_before_payment_enabled: bool, |
There was a problem hiding this comment.
is_tokenize_before_payment_enabled is bit ambiguous when 'before payment' is mentioned in variable name.
is_pre_network_tokenization_enabled can be used ig. We can add clear doc comment
crates/router/src/core/payments.rs
Outdated
|
|
||
| let is_nt_supported_connector = ntid_supported_connectors.contains(&connector_data.connector_name); | ||
|
|
||
| println!("{:?}<<>>10",is_nt_supported_connector); |
crates/router/src/core/payments.rs
Outdated
| println!("{:?}<<>>10",is_nt_supported_connector); | ||
|
|
||
| if is_pre_tokenization_enabled && is_nt_supported_connector { | ||
| println!("{:?}<<>>14",is_nt_supported_connector); |
crates/router/src/core/payments.rs
Outdated
| if is_pre_tokenization_enabled && is_nt_supported_connector { | ||
| println!("{:?}<<>>14",is_nt_supported_connector); | ||
| save_card_and_network_token_data(state, &mut payment_data).await; | ||
| println!("{:?}<<>>15",payment_data.get_payment_method_data()); |
crates/router/src/core/payments.rs
Outdated
| network_token_data: token_data.clone(), | ||
| ref_id: token_ref | ||
| }; | ||
| println!("{:?}<<>>17", network_token_data_for_vault); |
crates/router/src/core/payments.rs
Outdated
| #[derive(Default, Clone, serde::Serialize, Debug)] | ||
| pub struct NetworkTokenDataForVault { | ||
| pub network_token_data: hyperswitch_domain_models::payment_method_data::NetworkTokenData, | ||
| pub ref_id: String, |
There was a problem hiding this comment.
this is network_token_req_ref id right?
Can you rename it?
crates/router/src/core/payments.rs
Outdated
|
|
||
| if is_pre_tokenization_enabled && is_nt_supported_connector { | ||
| println!("{:?}<<>>14",is_nt_supported_connector); | ||
| save_card_and_network_token_data(state, &mut payment_data).await; |
There was a problem hiding this comment.
Can you modify save_card_and_network_token_data fn name? because, the fn is trying to pre tokenize and update payment data.payment method data. but not saving card flow.
crates/router/src/core/payments.rs
Outdated
| } | ||
|
|
||
| #[derive(Default, Clone, serde::Serialize, Debug)] | ||
| pub struct CardDataForVault { |
There was a problem hiding this comment.
seems like this struct has never been used. if this is not needed, can you remove this?
crates/router/src/core/payments.rs
Outdated
| .await.ok(); | ||
| match pre_tokenization_response { | ||
| Some((Some(token_response), Some(token_ref))) => { | ||
| let token_data = domain::NetworkTokenData { |
There was a problem hiding this comment.
can this be moved to a From implementation?
| Some(token_response), | ||
| network_token_requestor_ref_id.clone(), | ||
| )), | ||
| _ => Ok((None, None)), |
There was a problem hiding this comment.
incase fetch cryptogram fails we need to delete the network token generated right?
you return Ok((None, None)) in this failure case.
in save_card_and_network_token_data fn, it is written that if pre_payment_tokenization is None, then vault operation is set to SaveCardData(api::Card). but we need to return network token requestor ref id right? so that we can use this id to delete network token at token requestor in post update tracker
d3d4ecf to
90da476
Compare
4b62178 to
6bb59b2
Compare
a699724 to
9311c2c
Compare
a73f164 to
57396fb
Compare
57396fb to
4cfa5db
Compare
crates/api_models/src/admin.rs
Outdated
|
|
||
| /// Indicates if pre network tokenization is enabled or not | ||
| #[schema(default = false, example = false)] | ||
| pub is_pre_network_tokenization_enabled: Option<bool>, |
There was a problem hiding this comment.
Can be removed from all v2 structs
4cfa5db to
038d6f1
Compare
| @@ -0,0 +1,2 @@ | |||
| -- Your SQL goes here | |||
| ALTER TABLE business_profile DROP COLUMN IF EXISTS is_pre_network_tokenization_enabled; No newline at end of file | |||
There was a problem hiding this comment.
why we are removing here? the feature should be available in v2 also
| @@ -0,0 +1,2 @@ | |||
| -- Your SQL goes here | |||
| ALTER TABLE business_profile ADD COLUMN IF NOT EXISTS is_pre_network_tokenization_enabled BOOLEAN NOT NULL DEFAULT FALSE; No newline at end of file | |||
There was a problem hiding this comment.
Remove default and handle the default logic in code, basically when its null, change it to default in code
crates/router/src/core/payments.rs
Outdated
| #[cfg(feature = "v1")] | ||
| pub async fn set_payment_method_data_for_pre_network_tokenization<F, D>( | ||
| state: &SessionState, | ||
| payment_data: &mut D, |
There was a problem hiding this comment.
Write logic in a way so that mutation is not required in this function, basically do things and return output, so that only in one place mutation is handled
3d03326
a75adef to
3d03326
Compare
3d03326 to
4c2d1b4
Compare
4c2d1b4 to
a0b5e24
Compare
Type of Change
Description
Introduced a new field in business_profile (is_pre_network_tokenization_enabled).
Based on that field the card will be tokenized before first payment.
If the payment get succeeded the card and network token data will be stored in the locker afterwards.
Additional Changes
Motivation and Context
How did you test it?
Connector Create(Cybersource):
Payments Create:
Response:
Logs:
Raw Connector Request:
Checklist
cargo +nightly fmt --allcargo clippy