-
Notifications
You must be signed in to change notification settings - Fork 69
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
Avoid WooPay duplicate charges when order cannot be completely processed #7968
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Significance: patch | ||
Type: fix | ||
Comment: Fix WooPay duplicate charges. | ||
|
||
|
||
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -102,9 +102,13 @@ public function check_payment_intent_attached_to_order_succeeded( WC_Order $orde | |||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
$intent_meta_order_id_raw = $intent->get_metadata()['order_id'] ?? ''; | ||||||||||||||||||||||||||||||||
$intent_meta_order_id = is_numeric( $intent_meta_order_id_raw ) ? intval( $intent_meta_order_id_raw ) : 0; | ||||||||||||||||||||||||||||||||
if ( $intent_meta_order_id !== $order->get_id() ) { | ||||||||||||||||||||||||||||||||
$intent_meta_order_id_raw = $intent->get_metadata()['order_id'] ?? ''; | ||||||||||||||||||||||||||||||||
$intent_meta_order_id = is_numeric( $intent_meta_order_id_raw ) ? intval( $intent_meta_order_id_raw ) : 0; | ||||||||||||||||||||||||||||||||
$intent_meta_order_number_raw = $intent->get_metadata()['order_number'] ?? ''; | ||||||||||||||||||||||||||||||||
$intent_meta_order_number = is_numeric( $intent_meta_order_number_raw ) ? intval( $intent_meta_order_number_raw ) : 0; | ||||||||||||||||||||||||||||||||
$paid_on_woopay = filter_var( $intent->get_metadata()['paid_on_woopay'] ?? false, FILTER_VALIDATE_BOOLEAN ); | ||||||||||||||||||||||||||||||||
$is_woopay_order = $order->get_id() === $intent_meta_order_number; | ||||||||||||||||||||||||||||||||
if ( ! ( $paid_on_woopay && $is_woopay_order ) && $intent_meta_order_id !== $order->get_id() ) { | ||||||||||||||||||||||||||||||||
Comment on lines
+105
to
+111
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: No changes are necessary but what do you think about renaming the variables as follows:
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this renaming is beneficial because depending on the context we're analyzing the intent order ID may belong to WooPay order instead of the merchant's, and that may cause confusion. I only named |
||||||||||||||||||||||||||||||||
return; | ||||||||||||||||||||||||||||||||
} | ||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove the additional empty line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file is automatically generated and will be removed in the release process, so that's fine 🙂