vippsas/vipps-woocommerce

Reimplement get order status with get order details

iverok opened this issue · 3 comments

Apparently /status is deprecated.

Yep, /status is deprecated and /details gives more information: https://github.com/vippsas/vipps-ecom-api/blob/master/vipps-ecom-api.md#get-payment-details

It should suffice to determine if the status at Vipps is one of initated, reserved, completed or cancelled. It should be possible to ignore refunds (cancellation by refunds) as well as captures (ie completion by full capture - probably) - these statuses can be maintained in Woo and the status at Vipps ignored.

Thus it should be enough to evaluate "transactionLogHistory" so that:

  • if there is no "operation": "INITIATE" with "operationSuccess": true then the status is "cancelled" (failed)
  • if there is an "SALE" and no "CANCEL" after this, the status is "complete"
  • if there is a "RESERVE" and no "CANCEL" after that, and the status shouldn't be "complete", it is "authorized"
  • if there is a CANCEL anywhere with success the status is "cancelled"
  • otherwise the status is "initiated".

This assumes the set of operations will stay the same, and not have added operations that can change this logic (e.g., to restart cancelled transactions).

Ready for 1.7.0.