Exemple #1
0
 /**
  * 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", \Hansvn\Icepay\API\Logger::ERROR);
         return false;
     }
     $this->_logger->log(sprintf("Postback: %s", serialize($_POST)), \Hansvn\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 (!ParameterValidation::merchantID($this->data->merchant)) {
         $this->_logger->log("Merchant ID is not numeric: {$this->data->merchant}", \Hansvn\Icepay\API\Logger::ERROR);
         return false;
     }
     if (!ParameterValidation::amount($this->data->amount)) {
         $this->_logger->log("Amount is not numeric: {$this->data->amount}", \Hansvn\Icepay\API\Logger::ERROR);
         return false;
     }
     if ($this->_merchantID != $this->data->merchant) {
         $this->_logger->log("Invalid Merchant ID: {$this->data->merchant}", \Hansvn\Icepay\API\Logger::ERROR);
         return false;
     }
     if (!in_array(strtoupper($this->data->status), array(StatusCode::OPEN, StatusCode::AUTHORIZED, StatusCode::SUCCESS, StatusCode::ERROR, StatusCode::REFUND, StatusCode::CHARGEBACK))) {
         $this->_logger->log("Unknown status: {$this->data->status}", \Hansvn\Icepay\API\Logger::ERROR);
         return false;
     }
     if ($this->generateChecksumForPostback() != $this->data->checksum) {
         $this->_logger->log("Checksum does not match", \Hansvn\Icepay\API\Logger::ERROR);
         return false;
     }
     return true;
 }
Exemple #2
0
 /**
  * Validate the merchant settings
  * 
  * @since 1.0.0
  * @throws \Exception
  */
 private function validateSettings()
 {
     // Validate Merchant ID
     if (!ParameterValidation::merchantID($this->getMerchantID())) {
         throw new \Exception('Merchant ID not set, use the setMerchantID() method', 1001);
     }
     // Validate SecretCode
     if (!ParameterValidation::secretCode($this->getSecretCode())) {
         throw new \Exception('Secretcode ID not set, use the setSecretCode() method', 1002);
     }
 }