diff --git a/src/Message/PurchaseRequest.php b/src/Message/PurchaseRequest.php index ddc5da0..47e65e1 100644 --- a/src/Message/PurchaseRequest.php +++ b/src/Message/PurchaseRequest.php @@ -30,6 +30,16 @@ public function sendData($data) { $httpResponse = $this->sendRequest('POST', '/buttons', $data); - return $this->response = new PurchaseResponse($this, $httpResponse->json()); + try{ + $jsonRes = $httpResponse->json(); + } + catch (\Error $e){ + $res = array(); + $res["error"] = $e->getMessage(); + + return $this->response = new PurchaseResponse($this, $res); + + } + return $this->response = new PurchaseResponse($this, $jsonRes); } }