Conversation
|
Note: this approach is providing Queue Runner and Queueable classes. This will be useful for the case of implementing Scheduling feature (in the future) as well. |
a5c4d32 to
441361f
Compare
| return; | ||
| return true; | ||
| } | ||
| } |
There was a problem hiding this comment.
Removing all the code here as this event does not need any extra step/action from Webhook (however, still keep this handler class here to support those 3rd-party developers that may need to hook this Webhook event).
| $event->resolve(); | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
I'm designing this class to be a place where we add code to be executed from queue-action hook.
i.e. it could have
public static function execute_subscription_payment( ) {
// Perform OmiseSchedule
}
mayurkathale
left a comment
There was a problem hiding this comment.
Few things in notes above.
I am still able to reproduce issue with second attempt of order payment. Tried first failed attempt with Alipay, then second successful attempt with Card payment which gives payment error note on callback page.
To make the payload data consistency on both Callback and Webhook data, this json_decode should be converting the payload data into array instead of object (as the same as OmiseCharge object).
…solved' (boolean)
…pport asynchronous code.
…it is being used to handle a capture action from Omise Dashboard.
103831b to
d57717e
Compare
|
@mayurkathale Thank you for the test and your review! |
1. Objective
In a race-condition where Omise Webhook is fired at the same time as buyer returns to the Callback URI (
return_uri). A particular WooCommerce Order object will get updated its status twice which creates a consequence of a confirmation email is being sent to the recipient twice causing a confusion in a business flow that rely on this particular email.This happens because at the moment where Omise Webhook and Callback URI are triggered asynchronously at the same time, they both retrieve WC Order object with the
pendingstatus and update it toprocessingusingWC_Order::payment_complete(), which triggers an email function to be executed twice.This pull request is providing a solution to prevent the async request from creating a race-condition, by refactoring Event Handlers to make the code support for the Queue worker system in case if the race-condition happened.
Related information:
Related issue(s): T22125 (internal ticket)
2. Description of change
3. Quality assurance
🔧 Environments:
✏️ Details:
4. Impact of the change
There is a limitation of concurrent that
Action Schedulerlibrary can handle.Please check the following document as reference: https://actionscheduler.org/perf
Also
However, it shall not effect to its capability to handle the queue. Just for some high-volume transaction per minute website, it may take some seconds or minutes until all the queue get executed.
As stated in WP-Cron: https://developer.wordpress.org/plugins/cron/#what-is-wp-cron
5. Priority of change
Immediate.
6. Additional Notes
Just to clarify the relationship between 3 names.
However, there is one point that we should understand of WP-Cron behaviour, to understand how the WC_Queue work.
As stated in WP-Cron document: https://developer.wordpress.org/plugins/cron/#what-is-wp-cron
The WP-Cron is only working when "any" of page get loaded. It's not time-based as a typical system scheduler.
Meaning that, even though we set some schedule to be executed after "5" mins, but if there is no one open "any" page of the WordPress website, then that schedule won't be triggered.