/** * Confirm step of the checkout. Should be a pass-through page for JS-enabled browsers, requires a form submission to the payment gateway * * @return void */ public function confirmTask() { $cart = new CurrentCart(); $transaction = $cart->liftTransaction(); if (!$transaction) { $cart->redirect('home'); } // Get security token $transaction->token = $cart->getToken(); // Check if there are any steps missing. Redirect if needed $nextStep = $cart->getNextCheckoutStep()->step; if ($nextStep != 'summary') { $cart->redirect($nextStep); } // Final step here before payment Cart::updateTransactionStatus('awaiting payment', $transaction->info->tId); // Generate payment code $params = Component::params(Request::getVar('option')); $paymentGatewayProivder = $params->get('paymentProvider'); require_once dirname(dirname(__DIR__)) . DS . 'lib' . DS . 'payment' . DS . 'PaymentDispatcher.php'; $paymentDispatcher = new \PaymentDispatcher($paymentGatewayProivder); $pay = $paymentDispatcher->getPaymentProvider(); $pay->setTransactionDetails($transaction); $error = false; try { $paymentCode = $pay->getPaymentCode(); $this->view->paymentCode = $paymentCode; } catch (\Exception $e) { $error = $e->getMessage(); } if (!empty($error)) { $this->view->setError($error); } $this->view->display(); }