Skip to content

Commit 6bb92dd

Browse files
authored
Ensure payment has captured before setting order's payment as complete (#2224)
Before, even if Stripe had not captured the payment, the plugin would set the order's payment as complete. Now, we ensure that the payment has been captured by Stripe, before setting the order's payment status as complete.
1 parent db31518 commit 6bb92dd

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

includes/class-wc-stripe-webhook-handler.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,14 @@ public function process_webhook_charge_succeeded( $notification ) {
439439
return;
440440
}
441441

442+
// When the plugin's "Issue an authorization on checkout, and capture later"
443+
// setting is enabled, Stripe API still sends a "charge.succeeded" webhook but
444+
// the payment has not been captured, yet. This ensures that the payment has been
445+
// captured, before completing the payment.
446+
if ( ! $notification->data->object->captured ) {
447+
return;
448+
}
449+
442450
// Store other data such as fees
443451
$order->set_transaction_id( $notification->data->object->id );
444452

0 commit comments

Comments
 (0)