我的 Authorize.net webhook 在 A.net 端正确设置,当我触发一个事件来获取通知时,我在错误日志中得到这个:
PHP 致命错误:未捕获的异常 'JohnConde\Authnet\AuthnetInvalidJsonException' 和消息 'Invalid JSON sent in the Webhook notification' in /.../AuthnetWebhook.php:67 堆栈跟踪:0 /.../webhook.php(23) : JohnConde\Authnet\AuthnetWebhook->__construct('xxxxxxxxxxx...', '', Array) 1 {main} 在第 67 行的 /.../AuthnetWebhook.php 中抛出
我可以通过 Github 上的库成功设置 webhook 并获取通知历史记录。这是我用作端点的代码。allow_url_fopen 和 allow_url_include 在我的服务器上都设置为启用。
<?php
namespace myapplication;
use JohnConde\Authnet\AuthnetWebhook;
require('.../config.inc.php');
require('.../autoload.php');
$headers = getallheaders();
$payload = file_get_contents("php://input");
$webhook = new AuthnetWebhook(AUTHNET_SIGNATURE, $payload, $headers);
if ($webhook->isValid()) {
$transactionId = $webhook->payload->id;
$fp = fopen('results.json', 'w');
fwrite($fp, json_encode($webhook));
fclose($fp);
// Access notifcation values
// echo $webhook->eventType;
}
?>
谢谢你的帮助!