/**
  * Test for API Error Exception
  * Note this wont use annotation as this exception has extra data that must be validated
  */
 public function testApiErrorException()
 {
     $errorCode = \Upg\Library\Error\Codes::ERROR_MAC;
     $message = "Invalid Mac Error from API";
     $exceptionRaised = false;
     $header = "HTTP/1.1 200 OK\n            \r\nDate: Wed, 18 Nov 2015 14:23:48 GMT\n            \r\nServer: Jetty(8.1.15.v20140411)\n            \r\nContent-Type: application/json;charset=UTF-8\n            \r\nAccess-Control-Allow-Origin: *\n            \r\nAccess-Control-Allow-Methods: POST\n            \r\nAccess-Control-Expose-Headers: X-Payco-TOKEN, X-Payco-HMAC\n            \r\nX-Payco-HMAC: d91d92a84c215dbbc045d7fdce0405a0ea14ae61\n            \r\nVia: 1.1 www.payco-sandbox.de\n            \r\nConnection: close\n            \r\nTransfer-Encoding: chunked";
     $rawResponse = '{
       "resultCode": ' . $errorCode . ',
       "message": "' . $message . '",
       "salt": "nMp9eFTqrURBqquBb3P9hRX8g7RDzE8DCvu3nKwYJLvwha8F"
     }';
     try {
         $request = new CreateTransaction($this->config);
         $request->setOrderID(1)->setUserID(1)->setIntegrationType(CreateTransaction::INTEGRATION_TYPE_HOSTED_AFTER)->setAutoCapture(true)->setContext(CreateTransaction::CONTEXT_ONLINE)->setMerchantReference("TEST")->setUserType(CreateTransaction::USER_TYPE_PRIVATE)->setUserRiskClass(\Upg\Library\Risk\RiskClass::RISK_CLASS_DEFAULT)->setUserIpAddress("192.168.1.2")->setUserData($this->getUser())->setBillingAddress($this->getAddress())->setAmount($this->getAmount())->addBasketItem($this->getBasketItem())->setLocale(\Upg\Library\Locale\Codes::LOCALE_EN);
         $api = new CreateTransactionApi($this->config, $request);
         $api->setResponseRaw($rawResponse, 400, $header);
         $api->sendRequest();
     } catch (\Upg\Library\Api\Exception\ApiError $e) {
         $exceptionRaised = true;
         $response = $e->getParsedResponse();
         $this->assertEquals($errorCode, $response->getData('resultCode'));
         $this->assertEquals($message, $response->getData('message'));
         $this->assertEquals($errorCode, $e->getCode());
     }
     if (!$exceptionRaised) {
         $this->fail("Excpected exception was not raised");
     }
 }