Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use amount_captured in the timeline for captured events #7923

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions client/payment-details/timeline/map-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const isBaseFeeOnly = ( event ) => {
const formatNetString = ( event ) => {
if ( ! isFXEvent( event ) ) {
return formatExplicitCurrency(
event.amount - event.fee,
event.amount_captured - event.fee,
event.currency
);
}
Expand Down Expand Up @@ -681,7 +681,7 @@ const mapEventToTimelineItems = ( event ) => {
'A payment of %s was successfully charged.',
'woocommerce-payments'
),
event.amount,
event.amount_captured,
true
),
<CheckmarkIcon className="is-success" />,
Expand Down
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 @@ -173,7 +173,13 @@ public function compose_fee_break_down() {
public function compose_net_string(): string {
$data = $this->captured_event['transaction_details'];

$net = WC_Payments_Utils::interpret_stripe_amount( (int) $data['store_amount'] - $data['store_fee'], $data['store_currency'] );
// 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) $gross_amount - $data['store_fee'], $data['store_currency'] );

return sprintf(
/* translators: %s is a monetary amount */
Expand Down
Loading