By Daniel Du
I am going to sell my web services on Autodesk Exchange. As a web service publisher/seller, I would like to get a notification when someone buys my web service from Exchange, so that I can create an account and grant access to him. Instant Payment Notification (IPN) is a message service that automatically notifies merchants of events related to PayPal transactions. Merchants can use it to automate back-office and administrative functions, like fulfilling orders and providing customers with order status. Now Autodesk Exchange supports IPN notification. For priced web service, Autodesk Exchange relays the IPN notification to the publisher, adding some additional information, such as the buyer’s email address. For free web service, Autodesk Exchange sends an IPN notification to publisher including necessary information including buyer’s email address, etc.
Firstly, let’s take a look at how to setup IPN listener. If you go to “My Upload” in Exchange by clicking the up-arrow button near your account name in up-right corner, you will see an new UI like below. You can input your IPN listener URL and activate IPNs so that you can receive IPN notification and handle them according to your business logic. If you do not know what IPN is, please refer to https://developer.paypal.com/webapps/developer/docs/classic/ipn/ht_ipn/.
Now, you can go ahead to publish your web service to Autodesk Exchange. For web service, you can just specify your web service URL. For example, I have a web service – cloud rendering, allowing users uploading models and rendering them in cloud. For example, my web service URL is : http://www.mycompany.com/home/index (It is just for demo.)
To use my service, users need to login to my website. When user buys my web service from Autodesk Exchange, I get an IPN notification from Exchange. My IPN listener receives this notification and creates an account for this buyer, and sends the account information to buyer so that he can use my service.
Now I will create my IPN listener, it is an asp.net MVC application, for example, my IPN listener is : http://www.mycompany.com/home/IPNListener, here is the code:
public void IPNListener()
string ipnNotification = Encoding.ASCII.GetString(Request.BinaryRead(Request.ContentLength));
if (ipnNotification.Trim() == string.Empty)
NetLog.WriteTextLog("No IPN notification received. ");
string validationMessage = HandleIPNNotification(ipnNotification);
For the format of IPN notification, you can refer to https://developer.paypal.com/webapps/developer/docs/classic/ipn/integration-guide/IPNandPDTVariables . Here is an example of priced IPN notification sent from Autodesk Exchange, please note that an additional parameter &buyer_adsk_account is appended, you can use this parameter to get buyer’s email address.
&firstname.lastname@example.org //this one is added by exchange store
For free web service, the IPN notification is simple, it is something like:
To handle the IPN notification, I need to verify whether the notification is a valid one, a valid IPN notification means it is sent from Autodesk Exchange, not anyone else, a hacker for instance. The way to validate IPN notification is to send it back to Autodesk Exchange with POST method, Autodesk Exchange will response “verified” if it is a valid one. The Autodesk Exchange IPN verification URL is : http://apps.exchange.autodesk.com/WebServices/ValidateIPN. Autodesk Exchange marks the IPN notification as “received” when it is verified, otherwise it will send out IPN again and again(10 time maximum) until listener call Exchange webservice to verify it.
Now I can go ahead to set up an account for the customer and inform him to use my web service with this account information. According to current Autodesk Exchange logic, the publisher should send an email to customer. Since I get buyer’s email address, as an example, I can create an account with his email address as username and a random string as initial password, and then sent the account to buyer through email. Please refer to the sample project for detailed information on github: https://github.com/ADN-DevTech/Exchange-IPNListener-Sample
Another problem is how to debug my IPN listener before it goes online. For local test/debug, I cannot count on Autodesk Exchange to verify my temp notification, so I create a helper tool - ExchangeStoreEmulator - to emulate the Autodesk Exchange on local machine, buying an app, send an IPN notification, and validate the IPN notification. It is also included the code samples. ExchangeStoreEmulator is just simplest asp.net webform application:
The IPN Listener URL is the one I am trying to debugging, the AppId is the web service which I need to monitor when someone buys it. As a local test, I need to set the IPN validation URL to the local version, as indicated http://localhost:xxx/ValidatIPN.aspx, which emulate the behavior of Autodesk Exchange, verify the validation of IPN notification. This video demos the whole process and how to debug.
OK, now please go to github to download the sample IPN listener to have a try.https://github.com/ADN-DevTech/Exchange-IPNListener-Sample