Skip to content
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

Manual Sync, handling more cases: 'expired', 'refunded', 'reversed'. #183

Merged
merged 3 commits into from
Aug 10, 2020

Conversation

guzzilar
Copy link
Contributor

@guzzilar guzzilar commented Aug 1, 2020

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: 864eb4e

This 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: 864eb4e)

3. Quality assurance

🔧 Environments:

  • WooCommerce: v4.3.0
  • WordPress: v5.4.2
  • PHP version: 7.3.3

✏️ 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: 864eb4e#diff-b2a67ad6a97418df7dddcefcfc2a5319R352-R360

pending

Successful

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.

Reference: 864eb4e#diff-b2a67ad6a97418df7dddcefcfc2a5319R328-R338

successful

Manual Capture

Manual capture will give the same result as Successful case above.
capture

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: 864eb4e#diff-b2a67ad6a97418df7dddcefcfc2a5319R340-R350

failed

Refunded

Reference: 864eb4e?branch=864eb4e2069e855f1ccd2fd219e12c49c7deb238&diff=split#diff-b2a67ad6a97418df7dddcefcfc2a5319R317-R326

refund

refund-2

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: 864eb4e#diff-b2a67ad6a97418df7dddcefcfc2a5319R371-R378

reversed

Expired

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.

$charge['status'] = self::STATUS_EXPIRED;

The case of expired is similar to reversed. However, the order note's message is different.
Reference: 864eb4e#diff-b2a67ad6a97418df7dddcefcfc2a5319R362-R369

4. Impact of the change

None

5. Priority of change

Normal

6. Additional Notes

…Also adding those missing 'manual sync' action (Installment, PayNow).
@guzzilar
Copy link
Contributor Author

guzzilar commented Aug 3, 2020

I have just pushed a new commit f8cbb50

This is to re-locate the order-note message for a better understanding flow.

refunded-3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants