04-20-2018 09:30 AM
I am attempting to create a webhook that would send back notifications to my site everytime a customer is created, a transaction has been made, etc.
I am going through the steps detailed here https://developer.authorize.net/api/reference/features/webhooks.html
"Retrieving Event Types" went fine.
"List My Webhooks" went fine.
"Get a Webhook" went fine.
But, when I get to "Retrieve Notification History" I get a blank array...I have made a transaction, so I don't understand why this would be so.
This is the PHP I am using:
// jSON URL which should be requested $json_notifications_url = 'https://apitest.authorize.net/rest/v1/notifications'; // Initializing curl $ch_notifications_url = curl_init( $json_notifications_url ); $options_notifications_url = array( CURLOPT_RETURNTRANSFER => true, CURLOPT_USERPWD => $username . ":" . $password, // authentication CURLOPT_HTTPHEADER => array('Content-type: application/json') ); // Setting curl options curl_setopt_array( $ch_notifications_url, $options_notifications_url ); // Getting results $result_notifications_url = curl_exec($ch_notifications_url); // Getting jSON result string var_dump($result_notifications_url);
The var_dump returns this:
Can someone help me figure out what I am doing wrong!?
04-20-2018 02:04 PM
Let's verify step by step the scenario
1) You have subscribed to webhooks successfully and the url of your website has been provided correctly, either from the Merchant Interface OR the Webhook APIs
2) You are able to successfully retrieve the webhooks subscribed to using the GET Webhooks API
3) You perform an action that satisfies one of the events to which you are subscribed to
For eg: You create a customer and you have subscribed to the event type "net.authorize.customer.created"
4) Your website to which the notifications are to be posted is up and listening to a POST request
Could you please confirm the sequence and the success result of the above steps ?
5) Then you perform the GetNotifications call on the Webhook REST API.
04-20-2018 02:53 PM
1) When I had it in 'inactive' mode and ran the Test webhook it said it pinged the url. Right now I set the Status back to "Active" though.
2) I can receive a list of all my webhooks (which at this point is just 1)...as well as I am able to just call that specific webhook and see what events I have attached to it.
3) I have "All Events" assigned to this webhook. I have purchased something on this account and it shows up in Reports as approved.
4) The website is up.
5) I am specifically calling this GET https://apitest.authorize.net/rest/v1/notifications to get all notifications that would be on there.
04-20-2018 03:57 PM
Ok, looks like the pre-requisites are set up correctly.
I tried GetNotifications on Sandbox environment and it works for my test merchant.
However, could you please try sending the GETNotifications request through a RestClient like PostMan ?
Auth Type: Basic Auth with your API username and password and see what you get ?
04-23-2018 02:18 PM
Thank you for recommending PostMan. However, I set it up as you said, and I'm still getting an empty array. This leads me to believe, as you said as well, that perhaps my code is sound but something isn't setup properly with the webhook itself?
Although, I have no idea what might be wrong...
I have my endpoint url setup and (when testing in "inactive") it said it was fine.
I have status set to "Active".
I have "All Events" selected.
Could it have something to do with being in Sandbox mode? I have been using apitest.com as the base url for the Get request though.
04-23-2018 11:57 PM
Have you received any webhook notification on your endpoint when doing the transaction ?
If the notification is not susccesfully delivered , its goes into retry mode and it is retired 10 times over the course of 9 days .
During the retying , the notificaiton will not be available in the notificationHistory API .
Only if the notification is successfull or all retries are exhauseted and notification moved to failed , it will be visible via the notificationHistory API .
Hope it helps !!
04-24-2018 06:31 AM - edited 04-24-2018 06:32 AM
So, for some reason, I made another transaction last night and I got notifications!! So, I don't know why it wasn't working before...but it seems to be working now. Thanks so much for everyone's assistance though, and Postman will certainly come in handy!!
04-24-2018 10:01 PM
Thanks @jonCherlin1 for update .
We do have the postman for Webhooks APIs at https://github.com/AuthorizeNet/webhooks-postman-collection