I have configured Authorize.net, accept hosted payment method for my client requirement, where everything is happening fine, except Transaction reponse. As per Authorize.net, response comes only either of these ways, webhooks or CommunicatorUrl. CommunicatorUrl not working for my code. so, opted for webhooks. Below is my code. please, suggest me something.
My doubts are:
My Code displaying this error when calling list of available webhooks
{ "status": 405, "reason": "Method Not Allowed", "message": "The requested resource does not support http method 'POST' for given parameters.", "correlationId": "ff90ee25-0ba7-4006-bb1e-225ea64897e3" }
Should i configure webhook anywhere in my Merchant Panel
How would i get my transaction response using webhook
<?php $login_transKey = 'xxx:xxx'; //Login and Transaction Key of Authorize.net $jsonObj = '{ "name": "Get WebHooks", "request": { "url": "http://localhost:81/hosted_payment_form/webhookstwo.php", "method": "GET", "header": [ { "key": "Content-Type", "value": "application/json", "description": "" }, { "key": "Authorization", "value": "'.$login_transKey.'", "description": "" } ], "body": { "mode": "formdata", "formdata": [] }, "description": "" }, "response": [] }'; $jsonObj = json_encode($jsonObj); $url = "https://apitest.authorize.net/rest/v1/eventtypes"; curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json')); curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonObj); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 300); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_DNS_USE_GLOBAL_CACHE, false ); $content = curl_exec($ch); echo '<pre>'; print_r($content); die(); curl_close($ch); ?>
Please, Let me know for more information.
You need to specify the webhook URL in authorize.net account.
Also you need to select the events in the settings page.
Please make sure that the Web-hook URL always return HTTP 200 response. Otherwise it will be automatically changed to Inactive status.