You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Our production client died due to breaks in this client. #269
php-bitpay-client throws an Exception (on production) for mere Notices. This is a huge risk to end-clients. bitpay/php-client/src/Bitpay/Client/Client.php line
Our server logs started filling up with [2018-03-31 02:11:53] production.ERROR: Could not generate a Bitpay Invoice:Undefined index: btcPrice
The source of the problem is bitpay/php-client/src/Bitpay/Client/Client.php.
The Bitpay API apparently broke backward compatibility and no longer sends the btcPrice nor btcPaid.
The Solution
Ideally, bitpay's API wouldn't break backward compatibility, at least without notice.
Barring that, you must tweak the following code in Client.php:
if (false !== $error_message) {
thrownew \Exception($error_message);
}
This will definitely throw exceptions on mere notices, due to any array element from the Bitpay API being different / missing from what you expect.
Next, you must not use the base \Exception for throwing any errors, anywhere in the library. It makes it well-nigh impossible for end-developers to adequately handle cases where your client isn't working correctly.
My Workaround Hack
To save production, I had to manually edit vendor/bitpay/php-client/src/Bitpay/Client/Client.php and add the following lines in createInvoice(): Above the $invoice->setToken() on line 177:
I'm working on a v4 update, which resolves these issues.
Can you elaborate on this comment:
php-bitpay-client throws an Exception (on production) for mere Notices. This is a huge risk to end-clients. bitpay/php-client/src/Bitpay/Client/Client.php line"
Are you referring to the if (false !== $error_message) line?
An error message in the BitPay response to create invoice always refers to a failure of invoice creation, so it's not a mere notice.
I've currently updated the lines to: if (false !== $error_message) { throw new \Bitpay\Client\BitpayException($error_message); }
If you have other / better ideas, please let me know
Activity
abixalmon commentedon Apr 2, 2018
Mine too. This is really unprofessional!
pieterpoorthuis commentedon Apr 4, 2018
I'm working on a v4 update, which resolves these issues.
Can you elaborate on this comment:
Are you referring to the
if (false !== $error_message)line?An error message in the BitPay response to create invoice always refers to a failure of invoice creation, so it's not a mere notice.
I've currently updated the lines to:
if (false !== $error_message) { throw new \Bitpay\Client\BitpayException($error_message); }If you have other / better ideas, please let me know
hopeseekr commentedon Apr 6, 2018
I've already forked your project and I am working to resolve this on my end.
I incoricate you to definitely merge my upcoming PR(s).