示例#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;
 }
示例#2
0
文件: Api.php 项目: phamels/icepay
 /**
  * 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);
     }
 }
示例#3
0
文件: Object.php 项目: phamels/icepay
 /**
  * Set OrderID
  * 
  * @param string $orderID
  * @return Object
  * @throws \Exception
  */
 public function setOrderID($orderID)
 {
     if (!ParameterValidation::orderID($orderID)) {
         throw new \Exception('The Order ID cannot be longer than 10 characters', 1007);
     }
     $this->orderID = $orderID;
     return $this;
 }
示例#4
0
 /**
  * Set the amount field
  * @since version 1.0.0
  * @access public
  * @param int $amount !Required
  */
 public function setAmount($amount)
 {
     $amount = (int) (string) $amount;
     if (!ParameterValidation::amount($amount)) {
         throw new \Exception('Amount not valid');
     }
     $this->data->ic_amount = $amount;
     return $this;
 }