コード例 #1
0
ファイル: Client.php プロジェクト: harisinfo/eway-rapid-php
 /**
  * @param ResponseInterface $response
  *
  * @throws RequestException
  */
 private function _checkResponse($response)
 {
     $hasRequestError = false;
     if (preg_match('/4\\d\\d/', $response->getStatusCode())) {
         $this->_addError(self::ERROR_HTTP_AUTHENTICATION_ERROR);
         $hasRequestError = true;
     } elseif (preg_match('/5\\d\\d/', $response->getStatusCode())) {
         $this->_addError(self::ERROR_HTTP_SERVER_ERROR);
         $hasRequestError = true;
     } elseif ($response->getStatusCode() == 0) {
         $this->_addError(self::ERROR_CONNECTION_ERROR);
         $hasRequestError = true;
     }
     if ($hasRequestError) {
         throw new RequestException(sprintf("Last HTTP response status code: %s", $response->getStatusCode()));
     }
 }
コード例 #2
0
ファイル: Client.php プロジェクト: eWAYPayment/eway-rapid-php
 /**
  * @param ResponseInterface $response
  *
  * @throws RequestException
  */
 private function checkResponse($response)
 {
     $hasRequestError = false;
     if (preg_match('/4\\d\\d/', $response->getStatusCode())) {
         $this->log('error', "Invalid API key or password");
         $this->addError(self::ERROR_HTTP_AUTHENTICATION_ERROR, false);
         $hasRequestError = true;
     } elseif (preg_match('/5\\d\\d/', $response->getStatusCode())) {
         $this->log('error', "Gateway error - HTTP " . $response->getStatusCode());
         $this->addError(self::ERROR_HTTP_SERVER_ERROR);
         $hasRequestError = true;
     } elseif ($response->getError()) {
         $this->log('error', "Connection error: " . $response->getError());
         $this->addError(self::ERROR_CONNECTION_ERROR);
         $hasRequestError = true;
     }
     if ($hasRequestError) {
         throw new RequestException(sprintf("Last HTTP response status code: %s", $response->getStatusCode()));
     }
 }