示例#1
0
        protected void OnClick_Deposit(object sender, EventArgs e)
        {
            var service = new CreditWebService.CreditWebService();

            double money = double.Parse(DepositText.Text);

            try
            {
                service.DepositMoney(bankAccount.Id, money);
                BalanceLabel.Text = "$" + (bankAccount.Balance + money);
            }
            catch
            {
                SnackbarHelper.DisplaySnackBar(this, "Deposit Failed...");
            }
        }
示例#2
0
        protected void PayButton_OnClick(object sender, EventArgs e)
        {
            var user = (User)Session["user"];

            if (user == null)
            {
                Response.Redirect("Login.aspx");
            }

            if (!UseBalance.Checked)
            {
                var service = new CreditWebService.CreditWebService();
                var details = new CreditCardDto
                {
                    CardNumber            = cardnumber.Text.Replace(" ", ""),
                    CardVerificationValue = securitycode.Text,
                    Month = int.Parse(expirationdate.Text.Substring(0, 2)),
                    Year  = 2000 + int.Parse(expirationdate.Text.Substring(3, 2))
                };

                var transaction = service.Pay(details, service.GetBankAccount(3), amount);
                if (transaction == null)
                {
                    SnackbarHelper.DisplaySnackBar(this, "Payment Failed");
                    return;
                }
            }
            else
            {
                user.UpdateBalance(user.Balance - amount);
            }

            string paymentSuccessPage = "./PaymentSuccess.aspx";
            var    queryString        = HttpUtility.ParseQueryString(string.Empty);

            switch (payingFor)
            {
            case "bal":
                user.UpdateBalance(amount + user.Balance);
                queryString.Add("balance", "" + amount);
                break;

            case "game":
                if (BuyGift.Checked)
                {
                    var code        = GameCode.GenerateCode(game.Id);
                    var codeEncoded = EncodingHelper.Base64Encode(code.Code);
                    queryString.Add("code", HttpUtility.UrlEncode(codeEncoded));
                }
                else
                {
                    UserGame.AddGame(user.Id, game.Id, amount);
                    queryString.Add("game", "" + game.Id);
                    user.AddActivity("Bought " + game.GameName);
                }

                break;
            }


            Response.Redirect(paymentSuccessPage + "?" + queryString);
        }