mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
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:
@ -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;
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
},
|
||||
),
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user