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

refactor(router): store network_transaction_id for off_session payments irrespective of the is_connector_agnostic_mit_enabled config #7083

Merged
merged 21 commits into from
Feb 6, 2025
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
f5374bb
store network_transaction_id for every off_session payment
ShankarSinghC Jan 16, 2025
cfda1c6
Merge branch 'main' of https://github.com/juspay/hyperswitch into nti…
ShankarSinghC Jan 16, 2025
33c5fb5
Merge branch 'main' of https://github.com/juspay/hyperswitch into nti…
ShankarSinghC Jan 21, 2025
cb1810c
Merge branch 'main' of https://github.com/juspay/hyperswitch into nti…
ShankarSinghC Jan 22, 2025
14b20da
Merge branch 'main' into ntid/store-id-everytime
ShankarSinghC Jan 22, 2025
1054766
address pr comments
ShankarSinghC Jan 22, 2025
dea748b
Merge branch 'ntid/store-id-everytime' of https://github.com/juspay/h…
ShankarSinghC Jan 22, 2025
54c7426
Merge branch 'main' into ntid/store-id-everytime
ShankarSinghC Jan 22, 2025
3c696e8
Merge branch 'main' into ntid/store-id-everytime
ShankarSinghC Jan 27, 2025
4288793
Merge branch 'main' into ntid/store-id-everytime
ShankarSinghC Jan 31, 2025
4c28953
Merge branch 'main' into ntid/store-id-everytime
Gnanasundari24 Feb 3, 2025
205eaba
Merge branch 'main' of https://github.com/juspay/hyperswitch into nti…
ShankarSinghC Feb 4, 2025
7d26642
update cypress test for NTID flow
ShankarSinghC Feb 4, 2025
529b534
Merge branch 'ntid/store-id-everytime' of https://github.com/juspay/h…
ShankarSinghC Feb 4, 2025
24104b8
Merge branch 'main' into ntid/store-id-everytime
Gnanasundari24 Feb 4, 2025
80ba7c2
Update cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnostic…
ShankarSinghC Feb 4, 2025
eb01efd
Update cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnostic…
ShankarSinghC Feb 4, 2025
10f95b2
Update cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnostic…
ShankarSinghC Feb 4, 2025
a6cb9ff
Update cypress-tests/cypress/e2e/spec/Payment/00024-ConnectorAgnostic…
ShankarSinghC Feb 4, 2025
bc1389e
Merge branch 'main' into ntid/store-id-everytime
ShankarSinghC Feb 4, 2025
cb061f2
Merge branch 'main' into ntid/store-id-everytime
ShankarSinghC Feb 5, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 11 additions & 17 deletions crates/router/src/core/payments/operations/payment_response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
payment_data: &mut PaymentData<F>,
business_profile: &domain::Profile,
_business_profile: &domain::Profile,
) -> CustomResult<(), errors::ApiErrorResponse>
where
F: 'b + Clone + Send + Sync,
Expand Down Expand Up @@ -617,7 +617,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for
resp.status,
resp.response.clone(),
merchant_account.storage_scheme,
business_profile.is_connector_agnostic_mit_enabled,
)
.await?;
Ok(())
Expand Down Expand Up @@ -1201,7 +1200,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
merchant_account: &domain::MerchantAccount,
key_store: &domain::MerchantKeyStore,
payment_data: &mut PaymentData<F>,
business_profile: &domain::Profile,
_business_profile: &domain::Profile,
) -> CustomResult<(), errors::ApiErrorResponse>
where
F: 'b + Clone + Send + Sync,
Expand Down Expand Up @@ -1241,7 +1240,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
resp.status,
resp.response.clone(),
merchant_account.storage_scheme,
business_profile.is_connector_agnostic_mit_enabled,
)
.await?;
Ok(())
Expand Down Expand Up @@ -2079,7 +2077,6 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
attempt_status: common_enums::AttemptStatus,
payment_response: Result<types::PaymentsResponseData, ErrorResponse>,
storage_scheme: enums::MerchantStorageScheme,
is_connector_agnostic_mit_enabled: Option<bool>,
) -> RouterResult<()> {
todo!()
}
Expand All @@ -2095,7 +2092,6 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
attempt_status: common_enums::AttemptStatus,
payment_response: Result<types::PaymentsResponseData, ErrorResponse>,
storage_scheme: enums::MerchantStorageScheme,
is_connector_agnostic_mit_enabled: Option<bool>,
) -> RouterResult<()> {
// If the payment_method is deleted then ignore the error related to retrieving payment method
// This should be handled when the payment method is soft deleted
Expand Down Expand Up @@ -2130,20 +2126,18 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
})
.ok()
.flatten();
let network_transaction_id =
let network_transaction_id = if payment_data.payment_intent.setup_future_usage
== Some(diesel_models::enums::FutureUsage::OffSession)
{
if let Some(network_transaction_id) = pm_resp_network_transaction_id {
Copy link
Member

Choose a reason for hiding this comment

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

what is the purpose of this if let? Just for logger this can be achieved via an if statement as well

if is_connector_agnostic_mit_enabled == Some(true)
&& payment_data.payment_intent.setup_future_usage
== Some(diesel_models::enums::FutureUsage::OffSession)
{
Some(network_transaction_id)
} else {
logger::info!("Skip storing network transaction id");
None
}
Some(network_transaction_id)
} else {
logger::info!("Skip storing network transaction id");
None
};
}
} else {
None
};

let pm_update = if payment_method.status != common_enums::PaymentMethodStatus::Active
&& payment_method.status != attempt_status.into()
Expand Down
9 changes: 4 additions & 5 deletions crates/router/src/core/payments/tokenization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,10 @@ where
};

let network_transaction_id =
if let Some(network_transaction_id) = network_transaction_id {
if business_profile.is_connector_agnostic_mit_enabled == Some(true)
&& save_payment_method_data.request.get_setup_future_usage()
== Some(storage_enums::FutureUsage::OffSession)
{
if save_payment_method_data.request.get_setup_future_usage()
== Some(storage_enums::FutureUsage::OffSession)
{
if let Some(network_transaction_id) = network_transaction_id {
Some(network_transaction_id)
} else {
logger::info!("Skip storing network transaction id");
Expand Down
Loading