public function forceSyncronisation() { // determine the start time $settings = $this->getSettings(); $lastSync = $settings["LAST_SYNC"]; $now = time(); // perform file fetch $loader = new Loader($this); $pages = $loader->retrieveData($lastSync); // perform analysis/scrubbing $scrubber = new Scrubber(); foreach ($pages as $page) { $rows = $scrubber->scrubRows($page); // save data to database foreach ($rows as $row) { $tuple = Transaction::updateData($row, $this); if ($tuple[1] and is_object($tuple[0])) { $this->handleCallback($tuple[0]); } } } // save last entry time as last sync - but only if any is found. // this way we are safeguarded against MPESA fallouts like the one of 3-5 November 2014 $lastFound = \PLUSPEOPLE\PesaPi\Base\TransactionFactory::factoryOneByTime($this, $now); if (is_object($lastFound)) { $settings["LAST_SYNC"] = $lastFound->getTime(); $this->setSettings($settings); $this->update(); } }
public function forceSyncronisation() { // determine the start time $settings = $this->getSettings(); $lastSync = $settings["LAST_SYNC"]; // We keep the timestamp from just _BEFORE_ we start connecting - this way we ensure that incomming payment while // the process is in operation will be discovered at the NEXT request. $now = time(); // perform file fetch $loader = new Loader($this); $pages = $loader->retrieveData($lastSync); // perform analysis/scrubbing $scrubber = new Scrubber(); foreach ($pages as $page) { $rows = $scrubber->scrubRows($page); // save data to database foreach ($rows as $row) { $payment = Transaction::updateData($row, $this); if (is_object($payment)) { $this->handleCallback($payment); } } } // save last entry time as last sync $settings["LAST_SYNC"] = $now; $this->setSettings($settings); $this->update(); }