Skip to content

Commit

Permalink
Update _charge_id in metadata (#4131)
Browse files Browse the repository at this point in the history
* If _charge_id does not exist, update it. This happens on some sites
where maybe_process_upe_redirect does not run, but payment has completed
correctly.

Co-authored-by: Jessy P <jessy.pappachan@automattic.com>
  • Loading branch information
jessy-p and Jessy P authored Apr 14, 2022
1 parent a6fdf3b commit eb591d2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-3857-update-charge-id
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

update _charge_id metadata to fix Refund button
5 changes: 5 additions & 0 deletions includes/class-wc-payments-webhook-processing-service.php
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,11 @@ 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' );

// 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 );
}

$this->order_service->mark_payment_completed( $order, $intent_id, $intent_status, $charge_id );

// Send the customer a card reader receipt if it's an in person payment type.
Expand Down

0 comments on commit eb591d2

Please sign in to comment.