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

Introduce WebHooks feature #62

Merged
merged 5 commits into from
Sep 13, 2017
Merged

Introduce WebHooks feature #62

merged 5 commits into from
Sep 13, 2017

Conversation

guzzilar
Copy link
Contributor

@guzzilar guzzilar commented Sep 8, 2017

1. Objective

There are some cases that we need to consider using WebHooks feature.

  • An order has been placed at WooCommerce store with only authorize a charge (not auto capture). Then later, merchant performs capture action at Omise dashboard.

    Here, we need something like callback to tell WooCommerce store that that order has been captured already at Omise dashboard, that WooCommerce store can update an order status according to that capture result.

  • Some offsite payments don't resolve users' payments at the time they (user) complete their payment process (for example, Internet Banking, sometimes has some delay on process user's transaction).

    User will be redirected back to WooCommerce store with payment status = pending causing that an order status won't be changed to processing nor completed until merchant manual change it.

    Fortunately, Omise will triggers charge.complete event only when those offsite payments have been finished (by finish, means those offsite payments complete their processes). So we can rely on this event to automatically update an order status to processing or even failed without manual check / update by merchant.

Related information:
Related issue(s): -

2. Description of change

  1. Display Webhook enpoint at the setting page.
    screencapture-127-0-0-1-wp-admin-admin-php-1504862207296

  2. Handle charge.create event.
    Basically, there is noting to handle in this event but this PR allows 3rd-party developer to hook this event handler ( omise_handled_event_charge_create, check at Omise_Event_Charge_Create class).

  3. Handle charge.capture event.
    Only 1 situation that would trigger this event, which is when merchant capture an authorized charge (credit card payment method).

  4. Handle charge.complete event.
    There are 3 cases that would trigger this event.
    4.1 Alipay payment, when buyer complete the redirection flow (either success or fail).
    4.2 Internet Banking payment, when buyer complete the redirection flow (either success or fail).
    4.3 Credit Card payment (with-without auto capture), when buyer complete the redirection flow (either success or fail).

3. Quality assurance

🔧 Environments:

  • WordPress: 3.8.1
  • WooCommerce: 3.1.2 with PHP 5.6.30.
  • WooCommerce: 2.6.14 with PHP 5.4.45.

✏️ Details:

Note. These tests are using ngrok to expose a local server to make it be able to be set into Omise's endpoint.

First, at WordPress admin, go to Omise Setting page. Then copy Webhook endpoint set into Omise dashboard.

screen shot 2560-09-11 at 4 55 51 pm copy

  1. Make sure that Webhook endpoint is accessible.
    1.1 Create a new charge with any payment methods.
    1.2 You will see message Omise: an event charge.create has been caught (webhook). appears in your order detail page.

  2. Make sure that when you perform the 'capture' action form Omise dashboard, your WooCommerce order status will be updated according to a result of that charge transaction.
    2.1 Create a new charge with Credit Card payment method (set payment action to auth only)
    2.2 If you check your order status at this step, it will be pending payment.
    2.3 Then, go to Omise dashboard. Find your recently charge transaction and do capture.
    2.4 If you come back to WooCommerce order detail page, you will see that now your order status has been changed to processing.

  3. Make sure that plugin can handle charge.complete event properly when charge with Alipay payment in case of failed charge.

  4. Make sure that plugin can handle charge.complete event properly when charge with Alipay payment in case of successful charge.

  5. Make sure that plugin can handle charge.complete event properly when charge with Internet Banking payment in case of failed charge.

  6. Make sure that plugin can handle charge.complete event properly when charge with Internet Banking payment in case of successful charge.

4. Impact of the change

No

5. Priority of change

Normal

6. Additional Notes

Note, this would prepare specifically for Webhook feature.
@guzzilar
Copy link
Contributor Author

👍

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.

1 participant