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 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 toprocessing
norcompleted
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 toprocessing
or evenfailed
without manual check / update by merchant.Related information:
Related issue(s): -
2. Description of change
Display Webhook enpoint at the setting page.

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 atOmise_Event_Charge_Create
class).Handle
charge.capture
event.Only 1 situation that would trigger this event, which is when merchant capture an authorized charge (credit card payment method).
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:
✏️ Details:
First, at WordPress admin, go to Omise Setting page. Then copy Webhook endpoint set into Omise dashboard.
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.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
toauth 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
.Make sure that plugin can handle
charge.complete
event properly when charge with Alipay payment in case of failed charge.Make sure that plugin can handle
charge.complete
event properly when charge with Alipay payment in case of successful charge.Make sure that plugin can handle
charge.complete
event properly when charge with Internet Banking payment in case of failed charge.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
charge.reverse
,refund.create
).More information, please check https://www.omise.co/api-webhooks.