/** * Set Amount * * @since 1.0.0 * @param int $amount * @return \Icepay_Pbm_Object * @throws Exception */ public function setAmount($amount) { if (!Icepay_ParameterValidation::amount($amount)) { throw new Exception('Please enter a valid amount (in cents)', 1003); } $this->amount = $amount; return $this; }
/** * Validate the postback data * @since version 1.0.0 * @access public * @return boolean */ public function validate() { if ($_SERVER['REQUEST_METHOD'] != 'POST') { $this->_logger->log("Invalid request method", Icepay_Api_Logger::ERROR); return false; } $this->_logger->log(sprintf("Postback: %s", serialize($_POST)), Icepay_Api_Logger::TRANSACTION); /* @since version 1.0.2 */ foreach ($this->getPostbackResponseFields() as $obj => $param) { $this->data->{$obj} = isset($_POST[$param]) ? $_POST[$param] : ""; } if ($this->isVersionCheck()) { return false; } if ($this->_doIPCheck) { $check = false; foreach ($this->_whiteList as $ip) { $start = $ip['start']; $end = $ip['end']; if ($this->ip_in_range($_SERVER['REMOTE_ADDR'], "{$start}-{$end}")) { $check = true; break; } } if (!$check) { $this->_logger->log("IP Address not in range: {$_SERVER['REMOTE_ADDR']}", Icepay_Api_Logger::ERROR); return false; } } if (!Icepay_ParameterValidation::merchantID($this->data->merchant)) { $this->_logger->log("Merchant ID is not numeric: {$this->data->merchant}", Icepay_Api_Logger::ERROR); return false; } if (!Icepay_ParameterValidation::amount($this->data->amount)) { $this->_logger->log("Amount is not numeric: {$this->data->amount}", Icepay_Api_Logger::ERROR); return false; } if ($this->_merchantID != $this->data->merchant) { $this->_logger->log("Invalid Merchant ID: {$this->data->merchant}", Icepay_Api_Logger::ERROR); return false; } if (!in_array(strtoupper($this->data->status), array(Icepay_StatusCode::OPEN, Icepay_StatusCode::AUTHORIZED, Icepay_StatusCode::SUCCESS, Icepay_StatusCode::ERROR, Icepay_StatusCode::REFUND, Icepay_StatusCode::CHARGEBACK))) { $this->_logger->log("Unknown status: {$this->data->status}", Icepay_Api_Logger::ERROR); return false; } if ($this->generateChecksumForPostback() != $this->data->checksum) { $this->_logger->log("Checksum does not match", Icepay_Api_Logger::ERROR); return false; } return true; }
/** * Set the amount field * @since version 1.0.0 * @access public * @param int $amount !Required */ public function setAmount($amount) { $amount = (int) (string) $amount; if (!Icepay_ParameterValidation::amount($amount)) { throw new Exception('Amount not valid'); } $this->data->ic_amount = $amount; return $this; }