private function _Connect() { // connect to the database if ($this->db === false) { if (Config::GetInstance()->sdrive) { $this->db = new DataAccessSQLite('save_sqlite'); // attach the transaction database if the form uses payments if (Config::GetInstance()->UsePayments()) { $dbfile = TransactionLogger::GetInstance()->GetSqliteFile(); if (empty($dbfile) || !file_exists($dbfile)) { writeErrorLog('Tried to attach transaction log, but file is not defined or doesn\'t exist:', $dbfile); } else { $this->transacts = $this->db->AttachTransActions($dbfile); } } } else { $this->db = new DataAccessMySQL('save_database'); } } }
public function saveCartToDB() { $data = $this->getCartInstance()->exportCart(); $data['status'] = 'redirect'; $data['testmode'] = -1; // get existing order reference in case this is an update instead of a new transaction $transactid = Config::GetInstance()->GetSessionVariable(ORDERREFKEY); if (!TransactionLogger::GetInstance()->saveData($data, $transactid)) { // unset the session variable to ensure the cart scripts don't use empty values Config::GetInstance()->UnsetSessionVariable(ORDERREFKEY); Config::GetInstance()->UnsetSessionVariable(CC_FB_CARTID); writeErrorLog('Failed to write transaction details to the database', TransactionLogger::GetInstance()->getError()); return false; } // add the transaction id to the session for the cart Config::GetInstance()->SetSessionVariable(ORDERREFKEY, $transactid); // store a copy for FB, avoids the need to including the cart when getting feedback from a gateway Config::GetInstance()->SetSessionVariable(CC_FB_CARTID, $transactid); return $transactid; }
public function DropTransactions() { // nothing to do if the form doesn't have payments associated if (!Config::GetInstance()->UsePayments()) { return; } TransactionLogger::GetInstance()->dropData(); }