Ejemplo n.º 1
0
        public ActionResult Index(ChargeWalletViewModel charge)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ListWallet = userService.GetWalletUser(User.Identity.Name);
                return(View(charge));
            }

            int walletId = userService.ChargeWallet(User.Identity.Name, charge.Amount, "شارژ حساب");

            #region Online Payment

            var payment = new ZarinpalSandbox.Payment(charge.Amount);

            var res = payment.PaymentRequest("شارژ کیف پول", "https://*****:*****@gmail.com", "09197070750");

            if (res.Result.Status == 100)
            {
                return(Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + res.Result.Authority));
            }

            #endregion


            return(null);
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Index(ChargeWalletViewModel model)
        {
            ViewBag.TransactionHistory = await _walletRepo.GetAllUserTransactions(User.Identity.Name);

            if (ModelState.IsValid)
            {
                var id = await _walletRepo.ChargeWallet(User.Identity.Name, model.Price, "شارژ کیف پول");

                var payment  = new Payment(model.Price);
                var response = await payment.PaymentRequest("شارژ کیف پول", "https://localhost:44395/onlinepayment/" + id);

                if (response.Status == 100)
                {
                    Response.Redirect(response.Link);
                }
            }

            return(View(model));
        }