protected void Page_Load(object sender, EventArgs e) { //used for debugging purposes //foreach(string key in Request.Form) //{ // Response.Write(key + " = " + Request.Form[key] + "<br />"); //} var properties = new HttpProperties(); var returnLicenseKey = string.Empty; try { if (!string.IsNullOrEmpty(Request.Form.ToString())) { FillProperties(properties); var handshake1 = Encoding.Default.GetString(Crypto.DecryptFromBase64String(Properties.Settings.Default.Handshake1)); var handshake2 = Encoding.Default.GetString(Crypto.DecryptFromBase64String(Properties.Settings.Default.Handshake2)); var handshake = Utility.GetMd5Hash(handshake1) + Utility.GetMd5Hash(handshake2); if (handshake.Equals(properties.Handshake,StringComparison.InvariantCultureIgnoreCase)) { bool validProduct; using (var webServices = GeneralClient.NewClient()) { validProduct = webServices.ProductExists(properties.ItemNumber); } if (validProduct) { var name = properties.PayerFirstName + " " + properties.PayerLastName; var productName = properties.ItemNumber; string licenseKey; Helper.GetProductAndLicenseKey(name, null, productName, out licenseKey); //var licenseKey = Helper.GenerateLicenseKey( // name, // null, // productName); returnLicenseKey = Utility.FormatLicenseKey(licenseKey); } else { EmailUs("Invalid Item Number: " + properties.ItemNumber, string.Empty); } } } } catch (Exception exception) { Logger.TraceErr(exception); EmailUs("Ipn Exception", exception.ToString()); } if (!string.IsNullOrEmpty(returnLicenseKey)) { Response.Write(returnLicenseKey); } }
private void FillProperties(HttpProperties properties) { properties.RequestLength = HttpContext.Current.Request.Form.ToString(); var cartPosition = HttpContext.Current.Request.Form["item_cart_position"]; properties.ItemName = HttpContext.Current.Request.Form["item_name" + cartPosition]; properties.ItemNumber = HttpContext.Current.Request.Form["item_number" + cartPosition]; properties.Quantity = HttpContext.Current.Request.Form["quantity" + cartPosition]; properties.PaymentGross = HttpContext.Current.Request.Form["mc_gross" + cartPosition]; properties.Handshake = HttpContext.Current.Request["handshake"]; properties.PayerCity = HttpContext.Current.Request.Form["address_city"]; properties.PayerCountry = HttpContext.Current.Request.Form["address_country"]; properties.PayerCountryCode = HttpContext.Current.Request.Form["address_country_code"]; properties.PayerState = HttpContext.Current.Request.Form["address_state"]; properties.PayerAddressStatus = HttpContext.Current.Request.Form["address_status"]; properties.PayerAddress = HttpContext.Current.Request.Form["address_street"]; properties.PayerZipCode = HttpContext.Current.Request.Form["address_zip"]; properties.PayerFirstName = HttpContext.Current.Request.Form["first_name"]; properties.PayerLastName = HttpContext.Current.Request.Form["last_name"]; properties.PayerBusinessName = HttpContext.Current.Request.Form["payer_business_name"]; properties.PayerEmail = HttpContext.Current.Request.Form["payer_email"]; properties.PayerID = HttpContext.Current.Request.Form["payer_id"]; properties.PayerStatus = HttpContext.Current.Request.Form["payer_status"]; properties.PayerPhone = HttpContext.Current.Request.Form["contact_phone"]; properties.Business = HttpContext.Current.Request.Form["business"]; properties.ReceiverEmail = HttpContext.Current.Request.Form["receiver_email"]; properties.ReceiverID = HttpContext.Current.Request.Form["receiver_id"]; properties.Custom = HttpContext.Current.Request.Form["custom"]; properties.Memo = HttpContext.Current.Request.Form["memo"]; properties.Invoice = HttpContext.Current.Request.Form["invoice"]; properties.Tax = HttpContext.Current.Request.Form["tax"]; properties.QuantityCartItems = HttpContext.Current.Request.Form["num_cart_items"]; properties.PaymentDate = HttpContext.Current.Request.Form["payment_date"]; properties.PaymentStatus = HttpContext.Current.Request.Form["payment_status"]; properties.PaymentType = HttpContext.Current.Request.Form["payment_type"]; properties.PendingReason = HttpContext.Current.Request.Form["pending_reason"]; properties.TXN_ID = HttpContext.Current.Request.Form["txn_id"]; properties.TXN_Type = HttpContext.Current.Request.Form["txn_type"]; properties.PaymentFee = HttpContext.Current.Request.Form["mc_fee"]; properties.NotifyVersion = HttpContext.Current.Request.Form["notify_version"]; properties.VerifySign = HttpContext.Current.Request.Form["verify_sign"]; }