Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * 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();
- try {
- throw new Klarna_Checkout_ApiErrorException(
- "API Error: ", $result->getStatus(), $payload
- );
- } catch(Klarna_Checkout_ApiErrorException $e) {
- foreach($e->getPayload() as $error){
- echo "<span style='padding-left: 12px'>".$error."</span><br/>";
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement