0

我想添加一个 webhook 来验证和获取 coinbase 事件。

https://github.com/coinbase/coinbase-commerce-php

这是我的 webhook 控制器

public function verifyCoinbase() {
$secret = 'xxxxxxxxxxxxxxxxx';
$headerName = 'X-Cc-Webhook-Signature';
$headers = getallheaders();
$signraturHeader = isset($headers[$headerName]) ? $headers[$headerName] : null;
$payload = trim(file_get_contents('php://input'));

try {
    $event = Webhook::buildEvent($payload, $signraturHeader, $secret);
    http_response_code(200);
    echo sprintf('Successully verified event with id %s and type %s.', $event->id, $event->type);
} catch (\Exception $exception) {
    http_response_code(400);
    echo 'Error occured. ' . $exception->getMessage();
}

}

在运行测试时,我收到一条错误消息,上面写着

hash_equals():期望 known_string 是一个字符串,给定 null

现在尝试了 3 天。如果我能找到解决方案,我真的很高兴,请帮忙!

4

0 回答 0