-
Notifications
You must be signed in to change notification settings - Fork 43
Closed
Description
We use PHP 8.2 and bitpay/sdk:7.3 (the same error is on 7.2 and dev-master)
A call to GET /payoutBatches/:payoutBatchId throws an exception:
Cannot use object of type stdClass as array
Stack trace:
vendor/bitpay/sdk/src/BitPaySDK/Model/Payout/PayoutBatch.php:87
vendor/bitpay/sdk/src/BitPaySDK/Model/Payout/PayoutBatch.php:243
???:0
vendor/bitpay/sdk/src/BitPaySDK/Util/JsonMapper/JsonMapper.php:651
vendor/bitpay/sdk/src/BitPaySDK/Util/JsonMapper/JsonMapper.php:249
vendor/bitpay/sdk/src/BitPaySDK/Client.php:2030
The JSON response from the endpoint seems to be valid. When the SDK tries to deserialize it with JsonMapper it fails on array of 'instructions'.
vendor/bitpay/sdk/src/BitPaySDK/Model/Payout/PayoutBatch.php:79-92
private function _computeAndSetAmount()
{
$amount = 0.0;
if ($this->_instructions) {
foreach ($this->_instructions as $instruction) {
if ($instruction instanceof PayoutInstruction) {
$amount += $instruction->getAmount();
} else {
$amount += $instruction['amount']; // <-- This line
}
}
}
$this->_amount = $amount;
}
Instructions are deserialized as an array of stdClass, so it fails on the line $amount += $instruction['amount']; which used to be $amount += $instruction->amount; in the previous versions.
Metadata
Metadata
Assignees
Labels
No labels