Ejemplo n.º 1
0
 /**
  * Set OrderID
  * 
  * @param string $orderID
  * @return \Icepay_Pbm_Object
  * @throws Exception
  */
 public function setOrderID($orderID)
 {
     if (!Icepay_Parameter_Validation::orderID($orderID)) {
         throw new Exception('The Order ID cannot be longer than 10 characters', 1007);
     }
     $this->orderID = $orderID;
     return $this;
 }
Ejemplo n.º 2
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", 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 (!Icepay_Parameter_Validation::merchantID($this->data->merchant)) {
         $this->_logger->log("Merchant ID is not numeric: {$this->data->merchant}", Icepay_Api_Logger::ERROR);
         return false;
     }
     if (!Icepay_Parameter_Validation::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;
 }