From e02369006ac80b565862b8a863638f1fc41b926b Mon Sep 17 00:00:00 2001 From: Herquiloide Hele Date: Tue, 20 Aug 2019 11:42:31 +0200 Subject: [PATCH] Adding response error MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Estas modificações irão permitir que erros também sejam mostrados no TransactionResponse em caso de alguma falha na requisição do Curl. Actualmente em caso de erro com a requisição , o TransactionResponse fica vazio. --- src/Transaction.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/Transaction.php b/src/Transaction.php index 83a163d..b7339e7 100644 --- a/src/Transaction.php +++ b/src/Transaction.php @@ -71,6 +71,10 @@ public function payment( curl_setopt($request_handle, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($request_handle, CURLOPT_POSTFIELDS, $payload); $result = curl_exec($request_handle); + + if ($result === false) + $result = curl_error($request_handle); + return new TransactionResponse($result); } @@ -103,6 +107,10 @@ public function refund(string $transaction_id, float $amount): TransactionRespon curl_setopt($request_handle, CURLOPT_CUSTOMREQUEST, 'PUT'); curl_setopt($request_handle, CURLOPT_POSTFIELDS, $payload); $result = curl_exec($request_handle); + + if ($result === false) + $result = curl_error($request_handle); + return new TransactionResponse($result); } @@ -128,6 +136,10 @@ public function query(string $query_reference): TransactionResponseInterface 'Authorization: ' . $this->config->getBearerToken() ]); $result = curl_exec($request_handle); + + if ($result === false) + $result = curl_error($request_handle); + return new TransactionResponse($result); } -} \ No newline at end of file +}