public void Update(Receipt receipt) { ReceiptDao dao = new ReceiptDao(); using (Transaction tx = new Transaction()) { dao.Save<Receipt>(receipt); tx.Commit(); } }
public void SendPurchaseEmail(Receipt receipt) { String template = GooeyConfigManager.GetEmailTemplate(EmailTemplates.Purchase); String body = PerformReplacements(template, receipt: receipt); UserInfo user = MembershipUtil.FindByUserGuid(receipt.UserGuid).UserInfo; EmailInfo info = GetEmailInfo(body,user.Email); SendEmail(info); }
public void Issue(Receipt receipt) { receipt.Processed = DateTime.MaxValue; receipt.PaidDeveloperOn = DateTime.MaxValue; ReceiptDao dao = new ReceiptDao(); using (Transaction tx = new Transaction()) { dao.Save<Receipt>(receipt); tx.Commit(); } }
private void DoDataBind() { Data.Guid guid = Data.Guid.New(Request.QueryString["g"]); IList<Package> results = new List<Package>(); Package package = SitePackageManager.NewInstance.GetPackage(guid); results.Add(package); SitePackages.DataSource = results; SitePackages.DataBind(); this.LblPrice.Text = String.Format("{0:c}", package.Price); this.LblPurchaser.Text = LoggedInUser.Wrapper.UserInfo.Firstname + " " + LoggedInUser.Wrapper.UserInfo.Lastname; //Create a receipt that we'll use to process this purchase Receipt receipt = new Receipt(); receipt.Amount = package.Price; receipt.Created = UtcDateTime.Now; receipt.Guid = System.Guid.NewGuid().ToString(); receipt.PackageGuid = package.Guid; receipt.UserGuid = LoggedInUser.Wrapper.UserInfo.Guid; receipt.IsComplete = false; ReceiptManager.Instance.Issue(receipt); Amount = package.Price; PackageTitle = package.Title; PackageGuid = package.Guid; ReceiptGuid = receipt.Guid; ReturnUrl = GooeyConfigManager.StoreSiteHost + "/complete.aspx"; BtnPaypalPurchase.PostBackUrl = GooeyConfigManager.PaypalPostUrl; if (GooeyConfigManager.IsPaypalSandbox) BtnPaypalPurchase.OnClientClick = "alert('This purchase is using the paypal sandbox environment. No actual funds will be transferred.')"; /* * PAYPAL NOTE: * Merchant MUST enable auto-return */ }
private String PerformReplacements(String body, CmsSubscription subscription = null, Registration registration = null, Receipt receipt = null) { UserInfo user = null; if (receipt == null) user = MembershipUtil.FindByUserGuid(subscription.PrimaryUserGuid).UserInfo; else user = MembershipUtil.FindByUserGuid(receipt.UserGuid).UserInfo; body = body.Replace("{email}", user.Email); body = body.Replace("{firstname}", user.Firstname); body = body.Replace("{lastname}", user.Lastname); body = body.Replace("{username}", user.Username); body = body.Replace("{current-date}", UtcDateTime.Now.ToString("MM/dd/yyyy hh:mm:ss")); if (subscription != null) { Double totalCost = SubscriptionManager.CalculateCost(subscription); body = body.Replace("{domain}", subscription.Domain); body = body.Replace("{staging-domain}", subscription.StagingDomain); body = body.Replace("{subscription-cost}", String.Format("{0:c}", totalCost)); body = body.Replace("{subscription-description}", SubscriptionManager.GetSubscriptionDescription(subscription).ToString()); body = body.Replace("{paypal-id}", subscription.PaypalProfileId); } else { body = body.Replace("{domain}", String.Empty); body = body.Replace("{staging}", String.Empty); body = body.Replace("{subscription-cost}", String.Empty); body = body.Replace("{subscription-description}", String.Empty); body = body.Replace("{paypal-id}", String.Empty); } if (registration != null) { String password = TextEncryption.Decode(registration.EncryptedPassword); body = body.Replace("{password}", password); } else { body = body.Replace("{password}", String.Empty); } if (receipt != null) { String packageGuid = receipt.PackageGuid; Package package = SitePackageManager.NewInstance.GetPackage(packageGuid); body = body.Replace("{purchase-type}", package.PackageType.ToString()); body = body.Replace("{purchase-date}", receipt.Created.ToString("MM/dd/yyyy")); body = body.Replace("{purchase-amount}", String.Format("{0:c}",receipt.Amount)); body = body.Replace("{purchase-name}", package.Title); body = body.Replace("{purchase-txid}", receipt.TransactionId); } return body.Trim(); }