Skip to content

Commit

Permalink
refactor(router): store network_transaction_id for off_session pa…
Browse files Browse the repository at this point in the history
…yments irrespective of the `is_connector_agnostic_mit_enabled` config (#7083)

Co-authored-by: Gnanasundari24 <[email protected]>
Co-authored-by: Pa1NarK <[email protected]>
  • Loading branch information
3 people authored Feb 6, 2025
1 parent c044fff commit f9a4713
Show file tree
Hide file tree
Showing 3 changed files with 385 additions and 25 deletions.
30 changes: 12 additions & 18 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 @@ -2068,7 +2066,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 @@ -2084,7 +2081,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 @@ -2119,20 +2115,18 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
})
.ok()
.flatten();
let network_transaction_id =
if let Some(network_transaction_id) = pm_resp_network_transaction_id {
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
}
let network_transaction_id = if payment_data.payment_intent.setup_future_usage
== Some(diesel_models::enums::FutureUsage::OffSession)
{
if pm_resp_network_transaction_id.is_some() {
pm_resp_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
11 changes: 5 additions & 6 deletions crates/router/src/core/payments/tokenization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,11 @@ 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)
{
Some(network_transaction_id)
if save_payment_method_data.request.get_setup_future_usage()
== Some(storage_enums::FutureUsage::OffSession)
{
if network_transaction_id.is_some() {
network_transaction_id
} else {
logger::info!("Skip storing network transaction id");
None
Expand Down
Loading

0 comments on commit f9a4713

Please sign in to comment.