예제 #1
0
    /**
     * Make sure that getHeader works regardless of case
     *
     * @return void
     */
    public function testGetHeaderCaseInsensitive()
    {
        $request = new Klarna_Checkout_HTTP_Request('url');
        $response = new Klarna_Checkout_HTTP_Response(
            $request, array('Test' => 'value'), 203, 'my data'
        );

        $this->assertEquals('value', $response->getHeader('TEST'));
        $this->assertEquals('value', $response->getHeader('Test'));
        $this->assertEquals('value', $response->getHeader('test'));
    }
예제 #2
0
 /**
  * Throw an exception if the server responds with an error code.
  *
  * @param Klarna_Checkout_HTTP_Response $result HTTP Response object
  *
  * @throws Klarna_Checkout_HTTP_Status_Exception
  * @return void
  */
 protected function verifyResponse(Klarna_Checkout_HTTP_Response $result)
 {
     // Error Status Code recieved. Throw an exception.
     if ($result->getStatus() >= 400 && $result->getStatus() <= 599) {
         throw new Klarna_Checkout_ConnectorException(
             $result->getData(), $result->getStatus()
         );
     }
 }
예제 #3
0
 /**
  * Throw an exception if the server responds with an error code.
  *
  * @param Klarna_Checkout_HTTP_Response $result HTTP Response object
  *
  * @throws Klarna_Checkout_ApiErrorException
  * @return void
  */
 protected function verifyResponse(Klarna_Checkout_HTTP_Response $result)
 {
     // Error Status Code recieved. Throw an exception.
     if ($result->getStatus() >= 400 && $result->getStatus() <= 599) {
         $json = json_decode($result->getData(), true);
         $payload = $json && is_array($json) ? $json : array();
         throw new Klarna_Checkout_ApiErrorException("API Error", $result->getStatus(), $payload);
     }
 }