Skip to content

Commit

Permalink
Fix fatal error by checking for valid order before processing webhook (
Browse files Browse the repository at this point in the history
…#4287)

* check for valid order before processing payment intent succeeded webhook

* Early return rather than throw exception.

p1653480117582769/1653399879.923419-slack-CGGCLBN58

Co-authored-by: Dat Hoang <htdat@users.noreply.github.com>
  • Loading branch information
FangedParakeet and htdat authored May 25, 2022
1 parent 246b0dc commit 3fb6a6d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-4286-fix-webhook-service-fatal-error
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fixes fatal error on payment intent succeeded webhook.
3 changes: 3 additions & 0 deletions includes/class-wc-payments-webhook-processing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,9 @@ private function process_webhook_payment_intent_succeeded( $event_body ) {
$charges_data = $this->read_webhook_property( $event_charges, 'data' );
$charge_id = $this->read_webhook_property( $charges_data[0], 'id' );

if ( ! $order ) {
return;
}
// update _charge_id meta if it doesn't exist - happens when maybe_process_upe_redirect fails sometimes.
if ( $charge_id && ! $order->get_meta( '_charge_id' ) ) {
$order->update_meta_data( '_charge_id', $charge_id );
Expand Down

0 comments on commit 3fb6a6d

Please sign in to comment.