Skip to content

Commit

Permalink
VIPPS-280: Publication 1.3.10
Browse files Browse the repository at this point in the history
  • Loading branch information
ed007m authored Jan 30, 2020
1 parent 6f2deef commit 1fde156
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 89 deletions.
65 changes: 1 addition & 64 deletions Model/OrderPlace.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,14 +185,7 @@ public function execute(CartInterface $quote, Transaction $transaction)

if ($order) {
$this->updateVippsQuote($quote);
$paymentAction = $this->config->getValue('payment_action');
switch ($paymentAction) {
case PaymentAction::ACTION_AUTHORIZE_CAPTURE:
$this->capture($order, $transaction);
break;
default:
$this->authorize($order, $transaction);
}
$this->notify($order);
}

return $order;
Expand Down Expand Up @@ -330,36 +323,6 @@ private function updateVippsQuote(CartInterface $cart)
}
}

/**
* Capture
*
* @param OrderInterface $order
* @param Transaction $transaction
*
* @throws LocalizedException
*/
private function capture(OrderInterface $order, Transaction $transaction)
{
if ($order->getState() !== Order::STATE_NEW) {
return;
}

// preconditions
$totalDue = $order->getTotalDue();
$baseTotalDue = $order->getBaseTotalDue();

/** @var Payment $payment */
$payment = $order->getPayment();
$payment->setAmountAuthorized($totalDue);
$payment->setBaseAmountAuthorized($baseTotalDue);

// do capture
$this->processor->capture($payment, null);
$this->orderRepository->save($order);

$this->notify($order);
}

/**
* Send order conformation email if not sent
*
Expand All @@ -372,32 +335,6 @@ private function notify($order)
}
}

/**
* Authorize action
*
* @param OrderInterface $order
* @param Transaction $transaction
*/
private function authorize(OrderInterface $order, Transaction $transaction)
{
if ($order->getState() !== Order::STATE_NEW) {
return;
}

// preconditions
$totalDue = $order->getTotalDue();
$baseTotalDue = $order->getBaseTotalDue();
$payment = $order->getPayment();

// do authorize
$this->processor->authorize($payment, false, $baseTotalDue);
// base amount will be set inside
$payment->setAmountAuthorized($totalDue);
$this->orderRepository->save($order);

$this->notify($order);
}

/**
* @param $lockName
*
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "magento2-module",
"description": "Vipps Payment Method",
"license": "proprietary",
"version": "1.3.8",
"version": "1.3.10",
"require": {
"magento/framework": "102.0.*",
"magento/module-sales": "102.0.*",
Expand Down
Loading

0 comments on commit 1fde156

Please sign in to comment.