Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(core): Fix net_amount on Incremental Authorization Update (#9073)
Anurag24beaa224a08
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rsindex f5175e8410..4ebef9efb2 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs@@ -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;}diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rsindex 830186eeaa..a4ef1bdac8 100644--- a/crates/router/src/core/payments/operations/payment_response.rs+++ b/crates/router/src/core/payments/operations/payment_response.rs@@ -421,7 +421,8 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsIncrementalAuSome(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(),},),)