Skip to content

Commit

Permalink
Merge pull request #53 from paynl/PLUG-97
Browse files Browse the repository at this point in the history
Redirect to checkout when no payment is linked to order
  • Loading branch information
max-geraci authored Mar 4, 2020
2 parents fb31d02 + 2808794 commit 468469c
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions Controller/Checkout/Redirect.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,20 +81,21 @@ public function execute()
if(empty($order)){
throw new Error('No order found in session, please try again');
}
$payment = $order->getPayment();

if(empty($payment)){
throw new Error('No payment linked to order, please select a payment method');
}
# Restore the quote
$quote = $this->quoteRepository->get($order->getQuoteId());
$quote->setIsActive(true)->setReservedOrderId(null);
$this->checkoutSession->replaceQuote($quote);
$this->quoteRepository->save($quote);

$payment = $order->getPayment();

$method = $payment->getMethod();
// restore the quote
$quote = $this->quoteRepository->get($order->getQuoteId());
$quote->setIsActive(true)->setReservedOrderId(null);
$this->checkoutSession->replaceQuote($quote);
$this->quoteRepository->save($quote);
if (empty($payment)) {
$this->_redirect('checkout/cart');
return;
}

$methodInstance = $this->paymentHelper->getMethodInstance($method);
$methodInstance = $this->paymentHelper->getMethodInstance($payment->getMethod());
if ($methodInstance instanceof \Paynl\Payment\Model\Paymentmethod\Paymentmethod) {
$this->_logger->notice('PAY.: Start new payment for order ' . $order->getId());
$redirectUrl = $methodInstance->startTransaction($order);
Expand Down

0 comments on commit 468469c

Please sign in to comment.