Example #1
0
 /**
  * Sends the headers of the response to the client.
  *
  * @return void
  */
 protected function sendHeaders()
 {
     if (!headers_sent()) {
         $status = $this->response->getMessage() ?: $this->response->getStatus();
         header(sprintf("%s %s", $this->response->getProtocol(), $status));
         foreach ($this->response->getHeaders() as $name => $value) {
             header("{$name}: {$value}", true);
         }
         foreach ($this->response->getCookies() as $cookie) {
             header("Set-Cookie: {$cookie}", false);
         }
     }
 }
 public function testConstruct()
 {
     $data = array('sid' => '12345', 'total' => '10.00');
     $mock = $this->getMockBuilder('\\Omnipay\\TwoCheckout\\Message\\Request')->disableOriginalConstructor()->getMock();
     $mock->expects($this->once())->method('getAction')->will($this->returnValue('foo'));
     $response = new Response($mock, $data);
     $this->assertFalse($response->isSuccessful());
     $this->assertTrue($response->isRedirect());
     $this->assertNull($response->getTransactionReference());
     $this->assertNull($response->getMessage());
     $this->assertSame('foo', $response->getRedirectUrl());
     $this->assertSame('POST', $response->getRedirectMethod());
     $this->assertSame('POST', $response->getRedirectMethod());
     $this->assertSame($data, $response->getRedirectData());
 }
 /**
  * @return null|string
  */
 public function getMessage()
 {
     $errors = parent::getMessage();
     /*
      * In addition to errors directly provided by gateway,
      * we check if we can guess what caused payment to fail.
      * If request was not successful and there is no errors
      * from gateway we check if CVV or address or zip verification failed.
      */
     if (!$this->isSuccessful() && is_null($errors)) {
         $errorsArray = array();
         if ($this->isCvvNotMatched()) {
             $errorsArray[] = 'CvvNotMatched';
         }
         if ($this->isAddressNotMatched()) {
             $errorsArray[] = 'AddressNotMatched';
         }
         if ($this->isZipNotMatched()) {
             $errorsArray[] = 'ZipNotMatched';
         }
         $errors = count($errorsArray) > 0 ? implode(' ', $errorsArray) : null;
     }
     return $errors;
 }
 /**
  * Get a message describing the status of this response.
  *
  * @return string message
  */
 public function getMessage()
 {
     return $this->isSuccessful() ? $this->getStatusMessage() : parent::getMessage();
 }
 /**
  * 
  * @param \ifirma\Response $response
  * @throws IfirmaException
  */
 private function _checkResponseAfterAccountancyMonthChange(Response $response)
 {
     if (!$response->isOk()) {
         throw new IfirmaException($response->getMessage());
     }
 }