cancel
Showing results for 
Search instead for 
Did you mean: 

How to get transaction details after payment occurs?

Hello y'all,

 

I have created an app that uses Accept Hosted with redirect to Authorize.net payment page. Everything works great; I can make payments and the payment transactions are successful. The only thing I need now is to configure the app so that every time a payment occurs, it sends the transactions details back to my server. 

 

I know it has been suggested that I use webhooks to get notifications, but the thing I'm confused about webhooks is that it looks like I have to send GET request to the Authorize.net API in certain time intervals, rather than only when the transaction happens. I want to receive transaction details only after a payment happens and I don't want my server sending requests to the API continuously. 

 

I am using ASP.NET with C#. 

 

Any help or guidance is appreciated. Thank you!

toirovd
Member
5 REPLIES 5
@toirovd

You do not have to send get requests. You set up a non parameterised endpoint and authorize.net delivers the webhooks. The thing you are seeing about the redelivery where it happens in 3 second intervals, then 3 minute, then xyz minutes/hours, etc. is authorize.nets redelivery schedule. What happens is when the transaction is successful authorize sends the webhook. Usually happens within 3 to 5 seconds of when the customer pays. If your server responds then the webhook is delivered and you’re done. If your server sends a 500 error or some other non response, authorize will attempt to redeliver over the intervals given in those docs you are referencing. The get requests you are seeing are for manual calls you may wish to make.

I can tell you from a lot of experience with this that if your server has any reasonable uptime you will have a great experience with this. I have tested so many I cannot count. Probably nearing 1,000 at this point. Have also set them up in real money live environments. 98%+ are delivered within 3 to 5 seconds. I have never had one failure from authorize. I have had a handful where my endpoint scripts didn’t execute, but all of those are due to my code overpowering the resources on the low cost remote server I used for testing. Best of luck to you.
Renaissance
All Star

Thank you for your response. So now, as I understand Authorize.net sends the notifications automatically as soon as payment happens. I tried configuring a webhook on my sandbox account, like "https://my.server.com/notifications" as instructed in the sample code, but when I test it in the Inactive mode, it is giving me the error: Error: Error occured in connecting to the endpoint:https://my.server.com/notifications. But if I try with the directory my app is in, like "https://my.server.com/myapp/" then it says Ping Successful. What is the reason for this error and are there any quick solutions or tricks, or am I doing something wrong?

 

Also, once I configure the webhook endpoint, how could I receive the notification data on my server, so that I can use it for my purposes. I'm using .net with C#.

 

Thank you!

The question about the url I cannot answer. I would look for some difference on your server, for instance a different port from one file to the next. For the data, you write a server side script on the file tied to your endpoint. The script should be designed to capture the json payload. The json payload will have the transaction id that you can use to pull the entire transaction or generate a new transaction via various API method calls. The getTransactionDetails method call is the first place you should look. There is also a security step you can implement. For that you will capture the headers and extract the value of a header called X-Anet signature and compare it to a sha512 hash you create with your signature key and the json payload. That is used to verify it is actually auth.net communicating with your server.
@antonie17

You do not have to send get requests, period. Not in time intervals and not even one single time. Here is how it works-

-you create a file on your website to process the webhook
-tie that file to a non-parameterized url on your website
-go to your merchant interface, then account, then Webhooks
-under endpoint copy and paste the url from step 2
-enroll in the events you want tied to that endpoint. E.G. authcapture
-set it on inactive and save
-you will have the endpoint set up with a Test button in your interface. Click test . If it says successful, set your endpoint on active. It it isn’t successful, three main causes are 500 response from server, url auth.net doesn’t like (e.g. url with query string), or DNS resolution. Also you cannot do them locally. Has to be on a remote connection or routed to some service like ngrok. IIS i believe has something where you can have webhooks routed to your localhost. Check your server logs and see what’s up. Do this and test. Once you get a ping successful notification move it to active

-Once it is active, you are ready to process live transactions (meaning sandbox or production transactions)
-every order that is completed on your accept hosted page will send a webhook to your endpoint, provided you are enrolled in the event. This happens with no effort on your part
-auth.net almost never goes down. If it fails to hit your endpoint 99.9% of the time it is you. So what auth.net does is repeatedly try to send any webhooks that do not return a 200 response. They do this over a period of 3 days. They do this at various intervals, without you doing anything.

-so what you need to do once you are getting successful pings (if your Test button pings are successful, all of your live pings will be too, unless your DNS is on and off, or if you change your programming on your endpoint and start throwing errors) is set up your programming to do the updates you need. Start by running test transactions and capturing the json payload. It will have a transid. That’s all you need.

Then once your updates are happening, you can set up the hash validation. For this you can set up a hash function and have successes and failures dumped to a log file. Set your endpoint on inactive and ping it with the Test button. See if you get failure or success. If you get success that means your hash function is working right.

It totally depends our payment system which you are using currently. But if you go to your acccount details than you'll find this transaction counter where you can check transaction details. 

shamilagul
Member