0

我想使用Coinbase Commerce API接受比特币支付。我使用 curl 创建了费用。现在我想创建一个 webhook 来验证付款状态。

我如下创建 webhook ( https://github.com/coinbase/coinbase-commerce-php/blob/master/examples/Webhook/Webhook.php )

require_once __DIR__ . "/vendor/autoload.php";

use CoinbaseCommerce\Webhook;

$secret = 'SECRET_KEY';
$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();
}

我尝试使用 GET 和 POST 方法调用。得到$payload$signraturHeader空白。

4

0 回答 0