protected void GenerateProductKey_Click(object sender, EventArgs e) { var productPackage = CommerceCommon.GetProductPackage(base.CurrentSueetieProduct.ProductID); var purchase2 = new ProductPurchase { UserID = base.CurrentSueetieUserID, CartLinkID = CommerceCommon.GetCartLinkList(base.CurrentSueetieProduct.ProductID).Find(p => p.LicenseTypeID == 1).CartLinkID, ProductID = base.CurrentSueetieProduct.ProductID, PurchaseKey = CommerceCommon.GeneratePurchaseKey(), ActionID = 2 }; var productPurchase = purchase2; var num = Purchases.RecordPurchase(productPurchase); var spt = (SueetiePackageType)Enum.ToObject(typeof(SueetiePackageType), productPackage.PackageTypeID); var productLicense = new ProductLicense { License = LicensingCommon.CreateLicenseKey(SueetieLicenseType.Free, spt), PackageTypeID = productPackage.PackageTypeID, LicenseTypeID = 1, Version = productPackage.Version, UserID = base.CurrentSueetieUserID, CartLinkID = productPurchase.CartLinkID, PurchaseID = num }; Licenses.CreateProductLicense(productLicense); this.ltLicenseGeneration.Text = SueetieLocalizer.GetMarketplaceString("license_created_message"); this.ltNewLicense.Text = productLicense.License; this.SetActivePanel(this.pnlLicenseGeneration); }
protected void btnProductKey_OnClick(object sender, EventArgs e) { SueetiePackageType spt = (SueetiePackageType)Enum.ToObject(typeof(SueetiePackageType), int.Parse(this.rblPackageTypes.SelectedValue)); SueetieLicenseType type2 = (SueetieLicenseType)Enum.ToObject(typeof(SueetieLicenseType), int.Parse(this.rblLicenseTypes.SelectedValue)); CartLink cartLink = CommerceCommon.GetCartLink((int)spt, (int)type2); base.CurrentSueetieProduct = Products.GetSueetieProduct(cartLink.ProductID); ProductPurchase productPurchase = new ProductPurchase { UserID = this.ProductKeySueetieUser.UserID, CartLinkID = cartLink.CartLinkID, ProductID = cartLink.ProductID, PurchaseKey = CommerceCommon.GeneratePurchaseKey(), ActionID = base.CurrentSueetieProduct.ActionType() }; int num = Purchases.RecordPurchase(productPurchase); ProductPackage productPackage = CommerceCommon.GetProductPackage(cartLink.ProductID); Licenses.CreateProductLicense(new ProductLicense { PackageTypeID = productPackage.PackageTypeID, LicenseTypeID = cartLink.LicenseTypeID, Version = productPackage.Version, UserID = this.ProductKeySueetieUser.UserID, CartLinkID = cartLink.CartLinkID, PurchaseID = num, License = LicensingCommon.CreateLicenseKey(type2, spt) }); this.txtKey.Text = LicensingCommon.CreateLicenseKey(type2, spt); }
protected void Page_Load(object sender, EventArgs e) { if (!this.Page.IsPostBack) { this.lblPurchaseTitle.Text = SueetieLocalizer.GetMarketplaceString("productpurchase_title_success"); this.pnlLicenses.Visible = false; this.transactionXID = base.Request.QueryString["tx"]; PaymentService primaryPaymentService = CommerceContext.Current.PrimaryPaymentService; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(primaryPaymentService.TransactionUrl); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; byte[] bytes = base.Request.BinaryRead(HttpContext.Current.Request.ContentLength); string str = Encoding.ASCII.GetString(bytes) + string.Format("&cmd=_notify-synch&tx={0}&at={1}", this.transactionXID, primaryPaymentService.IdentityToken); request.ContentLength = str.Length; StreamWriter writer = new StreamWriter(request.GetRequestStream(), Encoding.ASCII); writer.Write(str); writer.Close(); StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream()); string input = reader.ReadToEnd(); reader.Close(); this.lblTransactionXID.Text = this.transactionXID; List <string> list = (from s in Regex.Split(input, "\n", RegexOptions.ExplicitCapture) where !string.IsNullOrEmpty(s) select s).ToList <string>(); if (list[0] == "SUCCESS") { List <ProductPurchase> list2 = new List <ProductPurchase>(); List <ProductLicense> list3 = new List <ProductLicense>(); this.PaymentProperties = this.CreateDictionary((from t in list where t.Contains("=") select t).ToList <string>()); int num = this.GetNum("num_cart_items"); int num2 = 0; int cartLinkID = -1; int num4 = -1; this.transactionXID = this.GetString("txn_id"); for (int i = 1; i <= num; i++) { num2 = this.GetNum("quantity".AddItemNum(i)); cartLinkID = this.GetNum("item_number".AddItemNum(i)); CartLink cartLink = CommerceCommon.GetCartLink(cartLinkID); for (int j = 0; j < num2; j++) { base.CurrentSueetieProduct = Products.GetSueetieProduct(cartLink.ProductID); ProductPurchase item = new ProductPurchase { TransactionXID = this.transactionXID, UserID = base.CurrentSueetieUserID, CartLinkID = cartLinkID, ProductID = cartLink.ProductID, PurchaseKey = CommerceCommon.GeneratePurchaseKey(), ActionID = base.CurrentSueetieProduct.ActionType() }; list2.Add(item); num4 = Purchases.RecordPurchase(item); if (base.CurrentSueetieProduct.ProductTypeID == 5) { ProductPackage productPackage = CommerceCommon.GetProductPackage(cartLink.ProductID); SueetiePackageType spt = (SueetiePackageType)System.Enum.ToObject(typeof(SueetiePackageType), productPackage.PackageTypeID); ProductLicense license = new ProductLicense { PackageTypeID = productPackage.PackageTypeID, LicenseTypeID = cartLink.LicenseTypeID, Version = productPackage.Version, UserID = base.CurrentSueetieUserID, CartLinkID = cartLinkID, PurchaseID = num4, License = Guid.NewGuid().ToString().ToUpper() }; SueetieLicenseType type2 = (SueetieLicenseType)System.Enum.ToObject(typeof(SueetieLicenseType), cartLink.LicenseTypeID); license.License = LicensingCommon.CreateLicenseKey(type2, spt); list3.Add(license); Licenses.CreateProductLicense(license); } } } this.rptPurchases.DataSource = Purchases.GetPurchasesByTransaction(this.transactionXID); this.rptPurchases.DataBind(); if (list3.Count > 0) { this.rptLicenses.DataSource = Licenses.GetLicensesByTransaction(this.transactionXID); this.rptLicenses.DataBind(); this.pnlLicenses.Visible = true; } } else { this.lblPurchaseTitle.Text = SueetieLocalizer.GetMarketplaceString("productpurchase_title_failure"); this.pnlLicenses.Visible = false; this.pnlPurchases.Visible = false; this.pnlTransactionCode.Visible = false; this.pnlSuccess.Visible = false; this.pnlFailure.Visible = true; MailMessage message = new MailMessage { From = new MailAddress(SiteSettings.Instance.FromEmail, SiteSettings.Instance.FromName) }; MailAddress address = new MailAddress(SiteSettings.Instance.ContactEmail, SiteSettings.Instance.SiteName + SueetieLocalizer.GetMarketplaceString("purchase_failure_email_admin")); message.To.Add(address); message.Subject = SueetieLocalizer.GetMarketplaceString("purchase_failure_email_subject"); string str4 = SueetieLocalizer.GetMarketplaceString("purchase_failure_email_firstline") + Environment.NewLine + Environment.NewLine; object obj2 = str4 + base.CurrentSueetieUser.UserName.ToString() + " (" + base.CurrentSueetieUser.DisplayName + ")"; string str3 = string.Concat(new object[] { obj2, Environment.NewLine, DateTime.Now.ToLongDateString(), ' ', DateTime.Now.ToLongTimeString() }) + Environment.NewLine + Environment.NewLine; message.Body = str3; if (SueetieConfiguration.Get().Core.SendEmails) { EmailHelper.AsyncSendEmail(message); } } } }
protected void Page_Load(object sender, EventArgs e) { if (DataHelper.GetIntFromQueryString("id", -1) == -1) { base.Response.Redirect("Browse.aspx"); return; } if (this.Page.IsPostBack) { return; } var product = this.CurrentSueetieProduct; var user = this.CurrentSueetieUser; base.CurrentContentID = product.ContentID; this.PurchaseKey = CommerceCommon.GeneratePurchaseKey(); this.LoginButtonLI2.Visible = false; this.ProductKeyButtonLI2.Visible = false; this.DownloadButtonLI2.Visible = false; this.DownloadButton2.Text = string.Format("Télécharger {0}", product.Title); this.LoginButton2.Text = SueetieLocalizer.GetMarketplaceString(string.Format("loginto_{0}", product.ProductType.ToString().ToLower())); if (!this.IsFileAvailable) { this.lblOptions.Text = "Nous sommes désolés, mais ce document n'est pas disponible actuellement."; return; } if (user.IsRegistered) { this.lblOptions.Text = "Actions possibles en tant que visiteur"; this.ResponseContactEmailTextBox.Text = this.EmailSenderAddressTextBox.Text = user.Email; this.ResponseContactNameTextBox.Text = this.EmailSenderNameTextBox.Text = user.DisplayName; } else { this.lblOptions.Text = "Actions possibles en tant que membre"; } if (product.PurchaseType == PurchaseType.FreeAll) { if (product.ProductType == ProductType.ElectronicDownload) { this.DownloadButtonLI2.Visible = true; } } else if (product.PurchaseType == PurchaseType.FreeRegistered) { if (user.IsRegistered) { this.DownloadButtonLI2.Visible = true; } else { this.LoginButtonLI2.Visible = true; } } }