Skip to content

Commit

Permalink
Commentary
Browse files Browse the repository at this point in the history
  • Loading branch information
Iver Odin Kvello committed Sep 21, 2018
1 parent cde26ea commit 4b5097c
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions WC_Gateway_Vipps.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ public function maybe_refund_payment($orderid) {
protected function maybe_complete_payment($order) {
if ('vipps' != $order->get_payment_method()) return false;
if ($order->needs_processing()) return false; // No auto-capture for orders needing processing
$captured = $order->get_meta('_vipps_captured');
$captured = $order->get_meta('_vipps_captured'); // IOK FIXME this could in theory be a partial capture; but this method should really only be called by 'pending' status orders.
if ($captured) {
// IOK 2019-09-21 already captured, so just run 'payment complete'
$order->payment_complete();
Expand Down Expand Up @@ -732,7 +732,7 @@ public function callback_check_order_status($order) {
if ($oldstatus != $newstatus) {
switch ($newstatus) {
case 'on-hold':
// Orders not needing processing can be autocaptured, so try to do so now. IOK 2019-09-21
// Orders not needing processing can be autocaptured, so try to do so now. This will reduce stock and mark the order 'completed' IOK 2019-09-21
$autocapture = $this->maybe_complete_payment($order);
if (!$autocapture) {
wc_reduce_stock_levels($order->get_id());
Expand Down Expand Up @@ -945,6 +945,7 @@ public function handle_callback($result) {
$order->update_meta_data('_vipps_status',$vippsstatus);

if ($vippsstatus == 'RESERVED' || $vippsstatus == 'RESERVE') { // Apparenlty, the API uses *both* ! IOK 2018-05-03
// Orders not needing processing can be autocaptured, so try to do so now. This will reduce stock and mark the order 'completed' IOK 2019-09-21
$autocapture = $this->maybe_complete_payment($order);
if (!$autocapture) {
wc_reduce_stock_levels($order->get_id());
Expand Down

0 comments on commit 4b5097c

Please sign in to comment.