Conversation
…ical with an order transaction id.
jacstn
reviewed
Sep 12, 2019
jacstn
approved these changes
Sep 12, 2019
This was referenced Sep 12, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
1. Objective
There is one edge case where multiple Omise Charge ID could be assigned to a one single WooCommerce Order object.
As a report from merchant of this behaviour that has happened with Internet Banking and Credit Card payment methods where their buyer places order with Internet Banking then leave the bank page and complete the payment with another, Credit Card payment method late on.
The problem of the above case is that, Omise Webhook will be triggered 2 times for these 2 charges to the particular WooCommerce Order object and the WooCommerce order status may be set incorrectly. i.e. Credit Card
charge.completeevent may comes first withstatus: successfulstatus then, Internet Bankingcharge.completeevent comes after withstatus: failure, time_outstatus.Related information:
Related issue(s): #100, #103
2. Description of change
Add a condition block to check if order's transaction id is the same as charge object in the event's payload.
3. Quality assurance
🔧 Environments:
v3.7.0.v5.2.2.v5.6.40,v7.3.3.✏️ Details:
There are 2 possible ways to test this pull request.
Place order with Internet Banking then leave the bank page and place the order again with Credit Card payment method, then wait for Internet Banking time out Webhook.
At this line https://github.com/omise/omise-woocommerce/pull/131/files#diff-5d50c8e849d8c8ff8c4b6c55f50cd317R56
Modify code to make sure that Omise-WooCommerce will not process any further if WooCommerce Order's transaction id is not the same as Webhook Charge.Complete event's payload.
You may add some random string to make this
if ( $order->get_transaction_id() !== $data->id ) { ... }condition to be false.i.e.
4. Impact of the change
No
5. Priority of change
High
6. Additional Notes
No