public function updatePayment() { $txn_id = $_GET['txn']; $transaction = new TransactionModel(); $transaction->loadByPK($txn_id); $result = (bool) $_GET['r']; if ($result) { $transaction->payment_status = 'requested'; $transaction->save(); return ['success' => true, 'changed' => true, 'transaction' => $transaction]; } else { return ['success' => false, 'changed' => true, 'transaction' => $transaction]; } }
public function checkout() { Ajde_Model::register($this); // Get existing transaction $transaction = new TransactionModel(); $session = new Ajde_Session('AC.Shop'); $session->has('currentTransaction') && $transaction->loadByPK($session->get('currentTransaction')); $cart = new CartModel(); $cart->loadCurrent(); $this->getView()->assign('cart', $cart); $this->getView()->assign('user', $this->getLoggedInUser()); $this->getView()->assign('transaction', $transaction); return $this->render(); }
public function markPaidJson() { $id = Ajde::app()->getRequest()->getPostParam('id', false); $transaction = new TransactionModel(); if (!is_array($id)) { $id = [$id]; } $c = 0; foreach ($id as $elm) { $transaction->loadByPK($elm); if ($transaction->payment_status !== 'completed') { $transaction->paid(); $c++; } } return ['success' => true, 'message' => Ajde_Component_String::makePlural($c, 'transaction') . ' marked as paid']; }
public function complete() { $cart = new CartModel(); $cart->loadCurrent(); $cart->emptyItems(); // Get existing transaction $transaction = new TransactionModel(); $session = new Ajde_Session('AC.Shop'); if ($session->has('currentTransaction')) { $transaction->loadByPK($session->get('currentTransaction')); } $session->destroy(); $this->getView()->assign('transaction', $transaction); return $this->render(); }
public function checkout() { // Get existing transaction $transaction = new TransactionModel(); $session = new Ajde_Session('AC.Shop'); $session->has('currentTransaction') && $transaction->loadByPK($session->get('currentTransaction')); $cart = new CartModel(); $cart->loadCurrent(); // Can we skip this step? if (!$transaction->hasLoaded() && !config('shop.offerLogin') && $cart->hasItems()) { $this->redirect('shop/transaction:setup'); } $this->getView()->assign('cart', $cart); $this->getView()->assign('user', $this->getLoggedInUser()); $this->getView()->assign('transaction', $transaction); return $this->render(); }
public function paymentJson() { $request = Ajde::app()->getRequest(); $provider = $request->getPostParam('provider', false); if (empty($provider)) { return array('success' => false, 'message' => __('Please choose a payment provider')); } // Check for current transaction Ajde_Model::register($this); $transaction = new TransactionModel(); $session = new Ajde_Session('AC.Shop'); if ($session->has('currentTransaction') && $transaction->loadByPK($session->get('currentTransaction'))) { if ($transaction->payment_status !== 'pending') { return array('success' => false, 'message' => __('Payment already initiated, please refresh this page')); } } else { return array('success' => false, 'message' => __('No current transaction found')); } $transaction->payment_provider = $provider; $provider = $transaction->getProvider(); $redirectUrl = $provider->getRedirectUrl(); if ($redirectUrl !== false) { $transaction->payment_status = 'requested'; $transaction->save(); $cart = new CartModel(); $cart->loadCurrent(); $cart->emptyItems(); if ($provider->usePostProxy()) { $this->setAction('postproxy'); $proxy = $this->getView(); $proxy->assign('provider', $provider); return array('success' => true, 'postproxy' => $proxy->render()); } return array('success' => true, 'redirect' => $redirectUrl); } return array('success' => false, 'message' => 'Could not contact the payment provider, please try again'); }