omise / omise-woocommerce

Omise WooCommerce Plugin
https://docs.opn.ooo/woocommerce-plugin
MIT License
47 stars 27 forks source link

Be able to create a refund when placing an order with Alipay or Installment payment method. #158

Closed guzzilar closed 4 years ago

guzzilar commented 4 years ago

1. Objective

According to Omise documents, those Alipay (online) and Installment payment methods are supporting refund via Omise API. However the plugin is still behind and doesn't provide this feature.

This pull request is to add a refund-feature support to those 2 payment methods.

References:

Related information: Related issue(s): T18953, T19969 (internal ticket)

2. Description of change

Adding refund feature to Alipay (online) and Installment payment methods.

3. Quality assurance

🔧 Environments:

✏️ Details:

1. To test refunding a charge using Alipay payment method, you will need to place an order and go through the normal WooCommerce checkout step.

1.1. At WooCommerce Order page, click "refund" button

alipay-refund-01

1.2. Enter a refund amount and click "Refund [amount] via Omise Alipay".

alipay-refund-02

1.3. Successfully refund will be shown on the "Order Notes" section, as well as displaying its refund transaction under the "items" section at WooCommerce Order page.

alipay-refund-03 Screen Shot 2563-04-08 at 19 14 03

1.4. You may as well, test for a failure case by modifying the code (as WooCommerce provides frontend-validation, the easiest way is to modify Omise code to create a refund with a false amount). At file: includes/gateway/class-omise-payment.php Line: 252, replace $amount with any invalid number, then create another refund via WooCommerce Order page.

Screen Shot 2563-04-08 at 18 24 54

There will be a alert-dialog showing **"Refund failed: ..."*** with a message (from Omise API)

alipay-refund-04

2. To test refunding a charge using Installment payment method, you will need to place an order and go through the normal WooCommerce checkout step the same Alipay. 2.1. At WooCommerce Order page, click "refund" button

installment-refund-01

2.2. Enter a refund amount and click "Refund [amount] via Omise Installment".

installment-refund-02

2.3. Successfully refund will be shown on the "Order Notes" section, as well as displaying its refund transaction under the "items" section at WooCommerce Order page. Also for a full-refund, the order status will be updated to Refunded.

installment-refund-03 Screen Shot 2563-04-08 at 19 14 11

2.4. However, Installment payment method does not support for partial-refund. If you try to create a refund with a partial amount, it will result showing alert-dialog saying: "Refund failed: charge partial refunds is not permitted for this type of charge."

installment-refund-04

4. Impact of the change

none

5. Priority of change

Normal

6. Additional Notes

none