/** * Place order (for orders with zero balances) * * @return void */ public function placeTask() { // Get the current active trancsaction $cart = new CartModelCurrentCart(); $transaction = $cart->liftTransaction(); //print_r($transaction); die; if (!$transaction) { $redirect_url = Route::url('index.php?option=' . 'com_cart'); App::redirect($redirect_url); } // get security token (Parameter 0) $token = Request::getVar('p0'); if (!$token || !$cart->verifyToken($token)) { die('Error processing your order. Bad security token.'); } // Check if the order total is 0 if ($transaction->info->tiTotal != 0) { die('Cannot process transaction. Order total is not zero.'); } // Check if the transaction's status is pending if ($transaction->info->tStatus != 'pending') { die('Cannot process transaction. Transaction status is invalid.'); } //print_r($transaction); die; if ($this->completeOrder($transaction)) { // Get the transaction ID variable name to pull from URL $params = Component::params(Request::getVar('option')); // Get payment provider $paymentGatewayProivder = $params->get('paymentProvider'); include_once JPATH_COMPONENT . DS . 'lib' . DS . 'payment' . DS . 'PaymentDispatcher.php'; $verificationVar = PaymentDispatcher::getTransactionIdVerificationVarName($paymentGatewayProivder); // redirect to thank you page $redirect_url = Route::url('index.php?option=' . 'com_cart') . '/order/complete/' . '?' . $verificationVar . '=' . $token . '-' . $transaction->info->tId; App::redirect($redirect_url); } }
/** * 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() { require_once PATH_CORE . DS . 'components' . DS . 'com_cart' . DS . 'models' . DS . 'CurrentCart.php'; $cart = new CartModelCurrentCart(); $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(); if ($nextStep != 'summary') { $cart->redirect($nextStep); } // Final step here before payment CartModelCart::updateTransactionStatus('awaiting payment', $transaction->info->tId); // Generate payment code $params = Component::params(Request::getVar('option')); $paymentGatewayProivder = $params->get('paymentProvider'); include_once JPATH_COMPONENT . 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(); }