/** * Cancel payments automatically after 90 days (30 days for Maestro) */ protected function cancelPayments() { $i = 0; $sql = "SELECT `vendorTxCode` FROM payment WHERE status = ? AND " . "((cardType='MAESTRO' AND created <= ?) OR created <= ?)"; $params = array(SAGEPAY_REMOTE_STATUS_AUTHENTICATED, date('Y-m-d H:i:s', strtotime('-30 days')), date('Y-m-d H:i:s', strtotime('-90 days'))); $cancelStatus = array('Status' => SAGEPAY_REMOTE_STATUS_CANCELLED); $payment = new ModelPayment(); $paymentStm = $this->dbHelper->execute($sql, $params); if (!$paymentStm) { exit('Invalid query'); } $payments = $paymentStm->fetchAll(PDO::FETCH_ASSOC); foreach ($payments as $row) { if ($payment->update($row['vendorTxCode'], $cancelStatus)) { $i++; } } printf('Updated %d payments', $i); }
/** * Application Constructor * * @param SagepaySettings $config Sagepay configuration object */ public function __construct(SagepaySettings $config = null) { $this->_db = HelperDatabase::getInstance(); $this->_config = $config; $pathinfo = isset($_SERVER['PATH_INFO']) ? substr($_SERVER['PATH_INFO'], 1) : (isset($_SERVER['ORIG_PATH_INFO']) ? substr($_SERVER['ORIG_PATH_INFO'], 1) : ''); $path = explode('/', $pathinfo); $getController = isset($path[0]) ? $path[0] : null; $controller = $this->_createNameAlias($getController); $getAction = isset($path[1]) ? $path[1] : null; $action = $this->_createNameAlias($getAction); $this->_view($controller, $action); }
/** * Check account in database */ protected function checkAccount() { // Check only for SERVER and DIRECT transaction if (in_array($this->integrationType, array(SAGEPAY_SERVER, SAGEPAY_DIRECT))) { $account = HelperCommon::getStore('account'); if ($account) { $sql = 'SELECT id FROM customer WHERE id = ? AND email = ? AND hashedPassword = ?'; $stm = $this->dbHelper->execute($sql, array($account['id'], $account['email'], $account['password'])); $row = $stm->fetch(PDO::FETCH_ASSOC); if (empty($row) || empty($row['id'])) { HelperCommon::clearStore('account'); $this->redirect($this->integrationType); } } } }
/** * Get instance * * @return HelperDatabase */ public static function getInstance() { if (self::$_instance === null) { self::$_instance = new HelperDatabase(); } return self::$_instance; }
/** * Delete all rows from specific table * * @return int */ public function deleteAll() { $query = 'DELETE FROM `' . $this->table . '`'; return $this->dbHelper->execute($query)->rowCount(); }