fix(core): Fix net_amount on Incremental Authorization Update (#9073)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
This commit is contained in:
Anurag
2025-09-01 17:50:26 +05:30
committed by GitHub
parent 861e023f60
commit 24beaa224a
2 changed files with 7 additions and 2 deletions

View File

@ -1098,6 +1098,10 @@ impl NetAmount {
+ self.tax_on_surcharge.unwrap_or_default()
}
pub fn get_additional_amount(&self) -> MinorUnit {
self.get_total_amount() - self.get_order_amount()
}
pub fn set_order_amount(&mut self, order_amount: MinorUnit) {
self.order_amount = order_amount;
}

View File

@ -421,7 +421,8 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAu
Some(
storage::PaymentAttemptUpdate::IncrementalAuthorizationAmountUpdate {
net_amount: hyperswitch_domain_models::payments::payment_attempt::NetAmount::new(
incremental_authorization_details.total_amount,
// Internally, `NetAmount` is computed as (order_amount + additional_amount), so we subtract here to avoid double-counting.
incremental_authorization_details.total_amount - payment_data.payment_attempt.net_amount.get_additional_amount(),
None,
None,
None,
@ -432,7 +433,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAu
),
Some(
storage::PaymentIntentUpdate::IncrementalAuthorizationAmountUpdate {
amount: incremental_authorization_details.total_amount,
amount: incremental_authorization_details.total_amount - payment_data.payment_attempt.net_amount.get_additional_amount(),
},
),
)