How to access Authorize.net webhook payload values

526 views Asked by At

I have setup webhook for my sandbox account of authorize.net. I am getting the webhook when any event happens. but I can't find anything in $_POST or $_GET or $_REQUEST

I have tried to read PHP input stream

$webhook = fopen('php://input' , 'rb');
while (!feof($webhook)) {
    $webhookContent .= fread($webhook, 4096);
}
fclose($webhook);

But still, I could not get payload variables. Please help me identifying How authorize.Net sends payload variable!

2

There are 2 answers

0
user1752065 On

Get the header parameters : $headers = getallheaders();

Get the payload : $payload = file_get_contents("php://input");

Encode payload - $response= json_encode($payload);

Encode header parameters : $headersresponse = json_encode($headers);

Payload will contains the parameters like responseCode,authCode,authAmount,entityName,notificationId

0
Raju V V Ravuri On

Probably if you were trying to display the content in your code to make sure of the response from Authorize.net then, that could not be solved your problem, and you may not sure unless you store the response somewhere. Please, try either of these two ways.

  1. Put db connection and insert query (or)
  2. Insert gotten response into a file by file_put_contents($filename,$webhookContent)

Put any of either step immediately after the end of while loop, and come back after 1 or 2 minutes, you will be finding the response either in database or created file, based upon the method you follow above.