/**
  * {@inheritdoc}
  */
 public function validateForm(array &$form, FormStateInterface $form_state)
 {
     require_once drupal_get_path('module', 'uc_icepay') . '/api/ParameterValidation.php';
     if (!\Icepay_ParameterValidation::merchantID($form_state->getValue('uc_icepay_merchant_id'))) {
         $form_state->setErrorByName('uc_icepay_merchant_id', t('You have specified an invalid Icepay Merchant ID.'));
     }
     if (!\Icepay_ParameterValidation::secretCode($form_state->getValue('uc_icepay_secret_code'))) {
         $form_state->setErrorByName('uc_icepay_secret_code', t('You have specified an invalid Icepay Secret Code.'));
     }
 }
Example #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 ($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;
 }
Example #3
0
 /**
  * Validate the merchant settings
  *
  * @since 1.0.0
  * @throws Exception
  */
 private function validateSettings()
 {
     // Validate Merchant ID
     if (!Icepay_ParameterValidation::merchantID($this->getMerchantID())) {
         throw new Exception('Merchant ID not set, use the setMerchantID() method', 1001);
     }
     // Validate SecretCode
     if (!Icepay_ParameterValidation::secretCode($this->getSecretCode())) {
         throw new Exception('Secretcode ID not set, use the setSecretCode() method', 1002);
     }
 }
Example #4
0
 /**
  * Set OrderID
  *
  * @param string $orderID
  * @return \Icepay_Pbm_Object
  * @throws Exception
  */
 public function setOrderID($orderID)
 {
     if (!Icepay_ParameterValidation::orderID($orderID)) {
         throw new Exception('The Order ID cannot be longer than 10 characters', 1007);
     }
     $this->orderID = $orderID;
     return $this;
 }
Example #5
0
 /**
  * Set the Pin Code field
  * @since 1.0.1
  * @access public
  * @param (int) $pinCode
  */
 public function setPinCode($pinCode)
 {
     if (!Icepay_ParameterValidation::pinCode($pinCode)) {
         throw new Exception('Pincode not valid');
     }
     $this->_pinCode = (string) $pinCode;
     return $this;
 }
Example #6
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 (!Icepay_ParameterValidation::amount($amount)) {
         throw new Exception('Amount not valid');
     }
     $this->data->ic_amount = $amount;
     return $this;
 }