Hi there,
I am testing webhooks, and I’m getting the following error:
Return type of CoinbaseCommerce\Resources\ApiResource::offsetGet($key) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
Array
(
[0] => Array
(
[file] => /home/user/vendor/coinbase/coinbase-commerce/src/Resources/ApiResource.php
[line] => 8
[function] => error_handler
[args] => Array
(
[0] => 8192
[1] => Return type of CoinbaseCommerce\Resources\ApiResource::offsetGet($key) should either be compatible with ArrayObject::offsetGet(mixed $key): mixed, or the #[\ReturnTypeWillChange] attribute should be used to temporarily suppress the notice
[2] => /home/user/vendor/coinbase/coinbase-commerce/src/Resources/ApiResource.php
[3] => 139
)
)
It seems like this is an error in the Coinbase code, is that correct? This is the PHP code that I am using:
require '../../vendor/autoload.php';
use CoinbaseCommerce\Webhook;
$secret = 'my secret here';
$headerName = 'X-Cc-Webhook-Signature';
$headers = getallheaders();
$signatureHeader = isset($headers[$headerName]) ? $headers[$headerName] : null;
$payload = trim(file_get_contents('php://input'));
try
{
$event = Webhook::buildEvent($payload, $signatureHeader, $secret);
http_response_code(200);
file_put_contents('test.txt',sprintf('Successully verified event with id %s and type %s.', $event->id, $event->type));
//echo sprintf('Successully verified event with id %s and type %s.', $event->id, $event->type);
}
catch (\Exception $exception)
{
http_response_code(400);
file_put_contents('test.txt','Error occured. '.$exception->getMessage());
//echo 'Error occured. ' . $exception->getMessage();
}
It’s the same as being shown on the github page for PHP, coinbase-commerce-php/Webhook.php at master · coinbase/coinbase-commerce-php · GitHub. If I test a charge:confirmed webhook, I get a 500 response.
Can you see why this is happening?
Kind regards,
Jay