protected void Page_Load(object sender, EventArgs e) { // SortedDictionary to hold the form input values in sorted order var postInput = new SortedDictionary<string, string>(); // log the signature received Logger.TraceInfo(String.Format("suppliedSignature={0}", Request.Form["signature"])); // initialize a string to hold the signature returned from PayNowWidgetUtils.IsValidIPNPost string postSignature; // get the name/value pairs input as form data NameValueCollection postedValues = Request.Form; string nextKey; for (int i = 0; i < postedValues.AllKeys.Length; i++) { nextKey = postedValues.AllKeys[i]; postInput.Add(nextKey.Trim(), postedValues[i].Trim()); Logger.TraceInfo(String.Format("{0}={1}", nextKey.Trim(), postedValues[i].Trim())); } var utils = new AmazonUtils(); var isValidIPN = utils.IsValidIPNPost(postInput, out postSignature); Logger.TraceInfo(String.Format("calculatedSignature={0}{1}", postSignature, Environment.NewLine)); // Add the state of the IPN (passed/failed) to the log if (isValidIPN) { Logger.TraceInfo("IPN verification passed"); AmazonIPN amazonIPN = AmazonIPN.Create(); if (amazonIPN.Amazon.Status == "PS") { amazonIPN.EmailBuyer("Order Received", "Your order has been received and will begin processing shortly."); LicenseKey.Send(amazonIPN); } } else { Logger.TraceInfo("IPN verification failed"); } Logger.TraceInfo("--End--"); }
protected void Application_Start(object sender, EventArgs e) { AmazonUtils amazonUtils = new AmazonUtils(Path.Combine(DataPath, "AmazonIPN.log")); Application["utils"] = amazonUtils; }