【发布时间】:2018-09-03 21:04:50
【问题描述】:
我的 Authorize.net webhook 在 A.net 端设置正确,当我触发一个事件来获取通知时,我在错误日志中得到这个:
PHP 致命错误:未捕获的异常 带有消息“无效”的“JohnConde\Authnet\AuthnetInvalidJsonException” JSON 在 /.../AuthnetWebhook.php:67 中的 Webhook 通知中发送 堆栈跟踪: 0 /.../webhook.php(23): JohnConde\Authnet\AuthnetWebhook->__construct('xxxxxxxxxxx...', '', 大批) 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;
}
?>
感谢您的帮助!
【问题讨论】:
标签: php authorize.net authorize.net-webhooks