Classic ASP and Amazon MWS

Okay, I know I am writing about stuff almost no one cares about. Classic ASP is the Dodo of web programming. Who in their right mind would be writing Classic ASP transactions to Amazon MWS? Isn’t Classic ASP dead! The only saving grace from Amazon not supporting Classic ASP is that Amazon’s support of PHP or C# is  not exactly brilliant. So for the few of you who might be interested, submitting MWS transactions using Classic ASP can be done. Most of the ASP code is already available in the forums. The only trick is the  request and feed signatures.

The key to the request signature problem was to implement Daniel O’Malley’s contribution in the post, I have authentication code for Classic ASP — anyone need it?. The trick was how to create a base64 encoded SHA256 signature that Amazon requires for the request. Several people tried to write native ASP functions for SHA256, MD5, and Base64 encoding but they could not match the results of the Amazon Scratchpad.  Daniel’s solution was to call JavaScript functions from ASP. That was brilliantly simple! He wrote a simple WSC wrapper for the JavaScript code available at http://pajhome.org.uk/crypt/md5/ and published it as sha256.wsc. That was cool! The Base64 encoded SHA256 signatures it generates matches the Amazon Scratchpad. I got it to work on the ListOrders and GetOrder transactions but I needed more. I needed to submit a “_POST_ORDER_FULFILLMENT_DATA_” feed and Amazon required a Base64 encoded MD5 signature for the feed data. This is an important transaction if you want to get paid. If you do not have a lot of Amazon orders your marketing person could update this manually. If you prefer the marketing person to focus on generating more sales, you should probably consider doing this task automatically. In our case we had a system that kept track of tracking numbers for each order.  So I followed Daniel’s example and merged the MD5 code from the same web site into Daniel’s code. My code is called sha256md5.wsc file. My testing confirmed that it generated both sha256 and md5 signatures that matched the Amazon Scratchpad. After a week of posting fulfillment data I have to conclude it is working. Your mileage may vary! Guess what? Our sales are up! I guess the plan of letting marketing folks focus on marketing is working! I love it when a plan comes together!

Since several people asked for it. Here is the wsc file, sha256md5.txt. I hope it helps.