コード例 #1
0
ファイル: HomeController.cs プロジェクト: Queercon/dcbadge
        public IActionResult Recover(string RequestCode, string email)
        {
            Helpers.Sql    sql  = new Helpers.Sql();
            Helpers.Mailer mail = new Helpers.Mailer();

            string[] data = sql.getRecover(RequestCode, email);

            if ((!String.IsNullOrEmpty(data[0])) && (!String.IsNullOrEmpty(data[0])))
            {
                mail.SendEmailAsync(email, data[1], data[0]);
            }



            return(View());
        }
コード例 #2
0
ファイル: HomeController.cs プロジェクト: Queercon/dcbadge
        public IActionResult Complete(string stripeEmail, string stripeToken)
        {
            ViewData["Message"]    = "If your seeing this, either you shouldnt be here, or something went wrong. Email us, or try again.";
            ViewData["Back"]       = 1;
            ViewData["qrcode"]     = "";
            ViewData["ShowEnd"]    = 0;
            ViewData["TransError"] = "";
            ViewData["Image"]      = "";
            ViewData["badgenum"]   = "";
            ViewData["Email"]      = "";
            ViewData["uri"]        = Startup.uri;

            string qrcode = "";


            ViewBag.RequestCode = Request.Cookies["RequestCode"];
            string RequestCode = ViewBag.RequestCode;

            Helpers.Sql    sql  = new Helpers.Sql();
            Helpers.QRGen  qr   = new Helpers.QRGen();
            Helpers.Mailer mail = new Helpers.Mailer();

            int price = sql.getPrice(RequestCode);

            var customers = new StripeCustomerService();
            var charges   = new StripeChargeService();

            if (!sql.codeUsed(RequestCode))
            {
                if (!String.IsNullOrEmpty(stripeEmail) && !String.IsNullOrEmpty(stripeToken))
                {
                    try
                    {
                        var customer = customers.Create(new StripeCustomerCreateOptions
                        {
                            Email       = stripeEmail,
                            SourceToken = stripeToken
                        });

                        var charge = charges.Create(new StripeChargeCreateOptions
                        {
                            Amount      = price,
                            Description = "QC-DCBadgeOrder",
                            Currency    = "usd",
                            CustomerId  = customer.Id
                        });


                        if (String.Compare(charge.Status, "succeeded", true) == 0)
                        {
                            ViewData["Back"] = 0;
                            String guid = Guid.NewGuid().ToString();
                            qrcode = sql.getID(RequestCode) + ";" + guid;
                            sql.updateSale(RequestCode, stripeEmail, customer.Id, charge.Id, qrcode);
                            int badgenum = charge.Amount / Startup.price;
                            ViewData["badgenum"] = badgenum;
                            ViewData["qrcode"]   = qrcode;
                            ViewData["ShowEnd"]  = 1;
                            ViewData["Message"]  = "";
                            ViewData["Image"]    = qr.genQRCode64(qrcode);
                            ViewData["Email"]    = stripeEmail;
                            mail.SendEmailAsync(stripeEmail, qrcode, badgenum.ToString());
                        }
                    }
                    catch (StripeException e)
                    {
                        ViewData["TransError"] = e.Message;
                        ViewData["Message"]    = "Something went wrong... look at the error message, email us or try again.";
                    }
                }
            }



            return(View());
        }