Exemple #1
0
        public IActionResult Img(string qrtext)
        {
            if (qrtext == null)
            {
                qrtext = " ";
            }

            ViewData["Back"] = 1;

            Helpers.Sql sql = new Helpers.Sql();
            if (sql.verifyQR(qrtext))
            {
                ViewData["Back"] = 0;
            }

            Helpers.QRGen qr = new Helpers.QRGen();
            ViewData["qrcode"] = qrtext;
            ViewData["Image"]  = qr.genQRCode64(qrtext);
            ViewData["uri"]    = Startup.uri;

            return(View());
        }
Exemple #2
0
        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());
        }