My Authorize.net webhook is set up properly on the A.net side, and when I trigger an event to get the notification, I get this in the error log:
PHP Fatal error: Uncaught exception 'JohnConde\Authnet\AuthnetInvalidJsonException' with message 'Invalid JSON sent in the Webhook notification' in /.../AuthnetWebhook.php:67 Stack trace: 0 /.../webhook.php(23): JohnConde\Authnet\AuthnetWebhook->__construct('xxxxxxxxxxx...', '', Array) 1 {main} thrown in /.../AuthnetWebhook.php on line 67
I can successfully setup the webhook and get notification history through the library on Github. Here is the code I'm using as my endpoint. Both allow_url_fopen and allow_url_include are set to enabled on my server.
<?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;
}
?>
Thanks for any help!
Your payload is an empty string.. you can see it in the error.
So
I am not familiar with
AuthnetWebhook
but I would bet (if I was a gambler) that the payload variable should not be empty.