There are some cases that the manual-sync feature at the moment cannot handle (expired, refunded, reversed).
This pull request is providing am improvement of this feature.
Related information:
Related issue(s): T18954 (internal ticket), T22392 (internal ticket), T22486 (internal ticket)
From this change, the manual-sync feature will be supporting for 6 different cases as the following:
successful, failed, pending, refunded, expired, reversed.
In this section, we will be testing all the 6 cases.
To prepare for the test, you may make sure that the Webhook endpoint has not been set to Omise Account in order to test for the manual sync.
Pending
The pending case will happen only when the charge.status = pending.
The plugin will "only" add an order note saying that payment is still in progress.
If charge.status = successful and charge.funding_amount != charge.refunded_amount, then the plugin will add a new order note saying that the payment is successful. Also update the Order status to processing if it hasn't already.
To test expired transaction, you may modify the charge.status result at the core code to simulate the response from Omise Charge API.
At includes/gateway/class-omise-payment.php::sync_payment() Line: 314.
You may add the following code above the switch condition.
1. Objective
There are some cases that the manual-sync feature at the moment cannot handle (expired, refunded, reversed). This pull request is providing am improvement of this feature.
Related information: Related issue(s): T18954 (internal ticket), T22392 (internal ticket), T22486 (internal ticket)
2. Description of change
Note, the change has been accidentally rebased and merged to the
master
branch within the prior pull request: #182, "Cleaning up code style & indentation", commit: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238This pull request is to write a test to cover all possible cases, and to re-review (if possible) the change. (Please check the core-actual change from this commit: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238)
3. Quality assurance
🔧 Environments:
✏️ Details:
From this change, the manual-sync feature will be supporting for 6 different cases as the following:
successful
,failed
,pending
,refunded
,expired
,reversed
.In this section, we will be testing all the 6 cases. To prepare for the test, you may make sure that the Webhook endpoint has not been set to Omise Account in order to test for the manual sync.
Pending
The pending case will happen only when the
charge.status
=pending
. The plugin will "only" add an order note saying that payment is still in progress.Reference: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238#diff-b2a67ad6a97418df7dddcefcfc2a5319R352-R360
Successful
If
charge.status
=successful
andcharge.funding_amount
!=charge.refunded_amount
, then the plugin will add a new order note saying that the payment is successful. Also update the Order status toprocessing
if it hasn't already.Reference: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238#diff-b2a67ad6a97418df7dddcefcfc2a5319R328-R338
Manual Capture
Manual capture will give the same result as Successful case above.
Failed
The plugin will add a new order note to inform that the payment is failed. As well, if not already then the plugin will update Order status to
failed
.Reference: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238#diff-b2a67ad6a97418df7dddcefcfc2a5319R340-R350
Refunded
Reference: https://github.com/omise/omise-woocommerce/commit/864eb4e2069e855f1ccd2fd219e12c49c7deb238?branch=864eb4e2069e855f1ccd2fd219e12c49c7deb238&diff=split#diff-b2a67ad6a97418df7dddcefcfc2a5319R317-R326
Reversed
In case of reversed-charge, the plugin will add a new order note to inform so, and if not already, then Order status will be marked as
cancelled
. Reference: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238#diff-b2a67ad6a97418df7dddcefcfc2a5319R371-R378Expired
To test expired transaction, you may modify the charge.status result at the core code to simulate the response from Omise Charge API. At
includes/gateway/class-omise-payment.php::sync_payment()
Line: 314. You may add the following code above theswitch
condition.The case of expired is similar to
reversed
. However, the order note's message is different. Reference: https://github.com/omise/omise-woocommerce/pull/182/commits/864eb4e2069e855f1ccd2fd219e12c49c7deb238#diff-b2a67ad6a97418df7dddcefcfc2a5319R362-R3694. Impact of the change
None
5. Priority of change
Normal
6. Additional Notes