Skip to content

Commit

Permalink
Use captured amount to calculate net deposit
Browse files Browse the repository at this point in the history
  • Loading branch information
mgascam committed Jan 31, 2024
1 parent 1d05ef5 commit 7727aa0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion includes/class-wc-payments-captured-event-note.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down

0 comments on commit 7727aa0

Please sign in to comment.