Skip to content
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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ImSagnik007
Copy link
Contributor

Type of Change

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

Description

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?

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

@ImSagnik007 ImSagnik007 self-assigned this Dec 18, 2024
@ImSagnik007 ImSagnik007 requested review from a team as code owners December 18, 2024 06:19
Copy link

semanticdiff-com bot commented Dec 18, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payment_methods/network_tokenization.rs  80% smaller
  crates/router/src/core/payments/tokenization.rs  20% smaller
  api-reference-v2/openapi_spec.json  19% smaller
  api-reference/openapi_spec.json  19% smaller
  crates/router/src/core/payments.rs  13% smaller
  crates/api_models/src/admin.rs  0% smaller
  crates/diesel_models/src/business_profile.rs  0% smaller
  crates/diesel_models/src/schema.rs  0% smaller
  crates/hyperswitch_domain_models/src/business_profile.rs  0% smaller
  crates/router/src/core/admin.rs  0% smaller
  crates/router/src/core/payments/operations/payment_approve.rs  0% smaller
  crates/router/src/core/payments/operations/payment_cancel.rs  0% smaller
  crates/router/src/core/payments/operations/payment_capture.rs  0% smaller
  crates/router/src/core/payments/operations/payment_complete_authorize.rs  0% smaller
  crates/router/src/core/payments/operations/payment_confirm.rs  0% smaller
  crates/router/src/core/payments/operations/payment_create.rs  0% smaller
  crates/router/src/core/payments/operations/payment_post_session_tokens.rs  0% smaller
  crates/router/src/core/payments/operations/payment_reject.rs  0% smaller
  crates/router/src/core/payments/operations/payment_response.rs  0% smaller
  crates/router/src/core/payments/operations/payment_session.rs  0% smaller
  crates/router/src/core/payments/operations/payment_start.rs  0% smaller
  crates/router/src/core/payments/operations/payment_status.rs  0% smaller
  crates/router/src/core/payments/operations/payment_update.rs  0% smaller
  crates/router/src/core/payments/operations/payments_incremental_authorization.rs  0% smaller
  crates/router/src/core/payments/operations/tax_calculation.rs  0% smaller
  crates/router/src/types/api/admin.rs  0% smaller
  migrations/2024-12-02-113838_add_is_tokenize_before_payment_enabled_in_business_profile/down.sql Unsupported file format
  migrations/2024-12-02-113838_add_is_tokenize_before_payment_enabled_in_business_profile/up.sql Unsupported file format

@ImSagnik007 ImSagnik007 linked an issue Dec 18, 2024 that may be closed by this pull request
2 tasks
@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Dec 18, 2024
@ImSagnik007 ImSagnik007 force-pushed the pre_network_tokenization branch from 276d588 to 5c13cc8 Compare December 23, 2024 06:06
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 23, 2024
@ImSagnik007 ImSagnik007 force-pushed the pre_network_tokenization branch from a5845b1 to 3f9c0ba Compare December 23, 2024 08:49
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 23, 2024
@ImSagnik007 ImSagnik007 changed the title Pre network tokenization feat(core): [Network Tokenization] pre network tokenization Dec 23, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 23, 2024
@ImSagnik007 ImSagnik007 force-pushed the pre_network_tokenization branch from 16e0f52 to dcc8625 Compare December 25, 2024 06:13
@hyperswitch-bot hyperswitch-bot bot removed the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 25, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 25, 2024
Copy link
Contributor

@prasunna09 prasunna09 left a 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?

Comment on lines +473 to +474
if is_pre_tokenization_enabled && is_nt_supported_connector_available {
let pre_tokenization_response = tokenization::pre_payment_tokenization(
Copy link
Contributor

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?

.await?;
let pm_data = payment_data.get_payment_method_data();
match pre_tokenization_response {
(Some(token_response), Some(_token_ref)) => {
Copy link
Contributor

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?

Comment on lines +467 to +471
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();
Copy link
Contributor

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.

Comment on lines +627 to +629
match pre_tokenization_response {
(Some(token_response), Some(_token_ref)) => {
let token_data = domain::NetworkTokenData {
Copy link
Contributor

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] [Network Tokenization]: Tokenize before payment
2 participants