/** * Method to save fraud events on the fraud system once event triggered * * @param array $row the line from lines collection * @param Mongodloid_Entity $balance * @param string $usage_type, the usage type could be: call, data, mms, sms * @param array $rate * @param string $volume * @param Billrun_Calculator $calculator * * @return boolean in case we are on chain return true if all ok and chain can continue, else return false if require to stop the plugin chain * */ public function afterUpdateSubscriberBalance($row, $balance, $rowPrice, $calculator) { if (is_null($balance)) { Billrun_Factory::log("Fraud plugin - balance is empty or not transfer to the plugin" . $row['stamp'] . ' | calculator ' . $calculator->getType(), Zend_Log::WARN); return true; } // if not plan to row - cannot do anything if (!isset($row['plan'])) { Billrun_Factory::log("Fraud plugin - plan not exists for line " . $row['stamp'], Zend_Log::ERR); return true; } // first check we are not on tap3, because we prevent intl fraud on nrtrde if ($row['type'] == 'tap3') { return true; } // check if row is too "old" to be considered as a fraud. TODO: consider lowering min_time in 1-2 days. if ($row['urt']->sec <= $this->min_time) { return true; } $thresholds = Billrun_Factory::config()->getConfigValue('fraud.thresholds', array()); foreach ($thresholds as $type => $limits) { switch ($type) { case 'cost': $this->costCheck($limits, $row, $balance, $rowPrice); break; case 'usage': $this->usageCheck($limits, $row, $balance); break; default: Billrun_Factory::log("Fraud plugin - method doesn't exists " . $type, Zend_Log::WARN); break; } } return true; }