-
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): add bulk tokenization flows #7066
base: main
Are you sure you want to change the base?
Conversation
Changed Files
|
…okenize-endpoints
…okenize-endpoints
…okenize-endpoints
}?; | ||
|
||
// Ensure card is not tokenized already | ||
if payment_method |
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.
use when instead
.await | ||
} | ||
|
||
pub async fn validate_payment_method_id( |
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.
There is fetch also happening inside this function, so for validation the function name can be validate_payment_method and accept a payment method and have a separate function to fetch the object. Or have fetch_and_validate_payment_method
) -> RouterResult<domain::PaymentMethod> { | ||
// Form encrypted network token data (tokenized card) | ||
let network_token_data = network_token_details.0; | ||
let token_data = api::PaymentMethodsData::Card(api::CardDetailsPaymentMethod { |
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.
creating encrypted_data
of card from domain::card
is repeated in multiple places, have a single function accepts domain::card and send encrypted data as output.
{ | ||
Ok(tokenization_response) => Ok(tokenization_response), | ||
Err(err) => { | ||
// TODO: revert this |
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.
Fix the TODO
}), | ||
// Customer not found | ||
None => { | ||
if customer_details.name.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.
Avoid if else, instead do a inversion method. validate and throw error first then do the process. Have a separate function to create customer. And call the customer creation function here.
api, | ||
domain::{ | ||
self, | ||
bulk_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.
bulk_tokenization::{ | |
bulk_tokenization |
}, | ||
}, | ||
}, | ||
utils::Encryptable, |
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.
utils::Encryptable, | |
utils, |
add_card_to_hs_locker, create_encrypted_data, create_payment_method, tokenize_card_flow, | ||
}, | ||
network_tokenization, | ||
transformers::{StoreCardReq, StoreCardRespPayload, StoreLockerReq}, |
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.
transformers::{StoreCardReq, StoreCardRespPayload, StoreLockerReq}, | |
transformers, |
Type of Change
Description
This PR introduces below changes
More details around the flow is present in #6971
Additional Changes
Motivation and Context
This helps merchants to tokenize their customer's payment methods with the card networks. A new payment method entry is created for every card which can be used to perform txns using the network tokens.
How did you test it?
1. Tokenize using raw card details
cURL
Response
2. Tokenize using existing payment method entry
cURL
Response
3. Bulk tokenize
cURL
Response
Checklist
cargo +nightly fmt --all
cargo clippy