-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(core): [Network Tokenization] pre network tokenization #6873
base: main
Are you sure you want to change the base?
Conversation
276d588
to
5c13cc8
Compare
a5845b1
to
3f9c0ba
Compare
16e0f52
to
dcc8625
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
if is_pre_tokenization_enabled && is_nt_supported_connector_available { | ||
let pre_tokenization_response = tokenization::pre_payment_tokenization( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can this validation for pre-network tokenization move to a a function?
crates/router/src/core/payments.rs
Outdated
.await?; | ||
let pm_data = payment_data.get_payment_method_data(); | ||
match pre_tokenization_response { | ||
(Some(token_response), Some(_token_ref)) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why are we ignoring this token_ref
? this should be set in payment method info right?
crates/router/src/core/payments.rs
Outdated
let filtered_nt_supported_connectors = | ||
get_filtered_nt_supported_connectors(&state, [connector.clone()].to_vec()); | ||
|
||
let is_nt_supported_connector_available = | ||
filtered_nt_supported_connectors.first().is_some(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
match pre_tokenization_response { | ||
(Some(token_response), Some(_token_ref)) => { | ||
let token_data = domain::NetworkTokenData { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove the loggers.
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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here ^
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()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove this too^
crates/router/src/core/payments.rs
Outdated
network_token_data: token_data.clone(), | ||
ref_id: token_ref | ||
}; | ||
println!("{:?}<<>>17", network_token_data_for_vault); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove logger here^
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
} | ||
|
||
#[derive(Default, Clone, serde::Serialize, Debug)] | ||
pub struct CardDataForVault { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
e5f5590
to
17f5577
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?
Checklist
cargo +nightly fmt --all
cargo clippy