Open Dadibom opened 6 years ago
When creating an invoice, either an error message or data has to be returned by BitPay.
Can you explain when this happens? Because if no data is returned, invoice creation fails and an error should be thrown as well.
Just a comment to confirm this bug report. Had a couple of these between 07-Jun-2018 21:59:21 (CEST) and 07-Jun-2018 22:15:42 (CEST).
My theory is that the server returned a non-200 response, with which the code doesn't take care of in src/Bitpay/Client/Adapter/CurlAdapter.php::sendRequest()
I normally do something like this:
$res = curl_exec($ch);
$curl_errno = curl_errno($ch);
$curl_error = $curl_errno ? curl_error($ch) : null;
$status_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
if ($res === false) {
throw new ...
}
if ($status_code != 200) {
throw new ...
}
.. etc etc
Sorry, forgot to respond. I don't know what causes this. It's only happened at one point for me (not personally, i found the error in my logs), a couple of attempts in a row.
To prevent this error, I think we can check the $data
is array type or casting this to array
type before passing to the array_key_exists
function.
Latest release sometimes gives the following error: array_key_exists() expects parameter 2 to be array, null given in Client.php (line 125)
the function fillInvoiceData receives null as its second parameter as $data = $body['data']; is null on line 206 (createInvoice)