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(router): Add support for retries with clear pan and network token payment method data #6905

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

Conversation

prasunna09
Copy link
Contributor

Type of Change

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

Description

Add support to retry a transaction with clear PAN or Network Token

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

@prasunna09 prasunna09 added A-core Area: Core flows C-feature Category: Feature request or enhancement S-waiting-on-review Status: This PR has been implemented and needs to be reviewed labels Dec 19, 2024
@prasunna09 prasunna09 self-assigned this Dec 19, 2024
@prasunna09 prasunna09 requested review from a team as code owners December 19, 2024 21:16
Copy link

semanticdiff-com bot commented Dec 19, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/router/src/core/payments/helpers.rs  36% smaller
  api-reference-v2/openapi_spec.json  22% smaller
  api-reference/openapi_spec.json  20% smaller
  crates/router/src/core/payment_methods.rs  19% smaller
  crates/router/src/core/payments/retry.rs  17% smaller
  crates/common_utils/src/ext_traits.rs  3% smaller
  crates/router/src/core/payments/transformers.rs  1% smaller
  crates/api_models/src/admin.rs  0% smaller
  crates/api_models/src/gsm.rs  0% smaller
  crates/diesel_models/src/business_profile.rs  0% smaller
  crates/diesel_models/src/gsm.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/gsm.rs  0% smaller
  crates/router/src/core/payments.rs  0% smaller
  crates/router/src/core/payments/operations.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_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
  crates/router/src/types/transformers.rs  0% smaller
  migrations/2024-12-10-091820_add-clear-pan-possible-to-gsm/down.sql Unsupported file format
  migrations/2024-12-10-091820_add-clear-pan-possible-to-gsm/up.sql Unsupported file format
  migrations/2024-12-15-171444_add-clear-pan-retries-enabled-to-profile/down.sql Unsupported file format
  migrations/2024-12-15-171444_add-clear-pan-retries-enabled-to-profile/up.sql Unsupported file format

@hyperswitch-bot hyperswitch-bot bot added the M-database-changes Metadata: This PR involves database schema changes label Dec 19, 2024
@hyperswitch-bot hyperswitch-bot bot added the M-api-contract-changes Metadata: This PR involves API contract changes label Dec 19, 2024
{
match self {
Ok(a) => a,
Err(_) => func().await,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not be ignoring the error here

@@ -59,6 +59,7 @@ pub struct Profile {
pub max_auto_retries_enabled: Option<i16>,
pub is_click_to_pay_enabled: bool,
pub authentication_product_ids: Option<serde_json::Value>,
pub is_clear_pan_retries_enabled: Option<bool>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
pub is_clear_pan_retries_enabled: Option<bool>,
pub is_clear_pan_retries_enabled: bool,


#[derive(Clone, serde::Serialize, Debug)]
pub enum VaultData {
CardVaultData(hyperswitch_domain_models::payment_method_data::Card),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: naming consistency

pub enum VaultData {
Card(),
NetworkToken(),
CardAndNetworkToken()
}

@@ -4432,6 +4441,47 @@ where
pub tax_data: Option<TaxData>,
pub session_id: Option<String>,
pub service_details: Option<api_models::payments::CtpServiceDetails>,
pub vault_operation: Option<PaymentMethodDataAction>,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is the field called vault_operation where the struct says PaymentMethodDataAction?

@@ -1904,12 +1904,93 @@ pub async fn retrieve_card_with_permanent_token(
todo!()
}

pub enum VaultFetchAction {
FetchCardDetailsFromLocker,
FetchCardDetailsForNetworkTransactionFlowFromLocker,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit:

Suggested change
FetchCardDetailsForNetworkTransactionFlowFromLocker,
FetchCardDetailsForNetworkTransactionIdFlowFromLocker,

@@ -140,7 +142,22 @@ where
break;
}

let connector = super::get_connector_data(&mut connectors)?;
let is_network_token = matches!(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be a impl based fn on PaymentMethodData

.unwrap_or(false)
&& business_profile.is_clear_pan_retries_enabled;

let connector = if should_retry_with_pan {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add relevant code comments here

&& business_profile.is_clear_pan_retries_enabled;

let connector = if should_retry_with_pan {
original_connector_data.clone()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is clone required here?

crates/router/src/core/payments/retry.rs Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-core Area: Core flows C-feature Category: Feature request or enhancement M-api-contract-changes Metadata: This PR involves API contract changes M-database-changes Metadata: This PR involves database schema changes S-waiting-on-review Status: This PR has been implemented and needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Add support for retries with clear pan and network token payment method data
3 participants