From 7727aa0c179808f4a2cdbe0cee6ddd273a61ef98 Mon Sep 17 00:00:00 2001 From: Miguel Gasca Date: Wed, 31 Jan 2024 10:00:17 +0100 Subject: [PATCH] Use captured amount to calculate net deposit --- includes/class-wc-payments-captured-event-note.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/includes/class-wc-payments-captured-event-note.php b/includes/class-wc-payments-captured-event-note.php index 19da9fbca50..0d8c9613896 100644 --- a/includes/class-wc-payments-captured-event-note.php +++ b/includes/class-wc-payments-captured-event-note.php @@ -172,8 +172,14 @@ public function compose_fee_break_down() { */ public function compose_net_string(): string { $data = $this->captured_event['transaction_details']; + + // Determine the gross amount: Use captured amount if it exists (for partial captures), + // otherwise default to 'store_amount'. This handles cases where the captured amount + // may differ from the initially authorized amount. + $gross_amount = isset( $data['customer_amount_captured'] ) ? $data['customer_amount_captured'] : $data['store_amount']; + // TODO: check here for the net deposit of the order note. - $net = WC_Payments_Utils::interpret_stripe_amount( (int) $data['store_amount'] - $data['store_fee'], $data['store_currency'] ); + $net = WC_Payments_Utils::interpret_stripe_amount( (int) $gross_amount - $data['store_fee'], $data['store_currency'] ); return sprintf( /* translators: %s is a monetary amount */