Exemplo 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);
        }
Exemplo n.º 2
0
        public async Task <IActionResult> Index(TransactionViewModel transactionForm)
        {
            var email = User.Identity.Name;
            var transactionViewModel = await _userService.GetUserTransactionViewModelAsync(email);

            transactionForm.TransactionsList = transactionViewModel.TransactionsList;

            if (!ModelState.IsValid)
            {
                return(View(transactionForm));
            }

            var transactionId = await _userService.ChargeUserWallet(email,
                                                                    transactionForm.ChargeWallet.Amount, "شارژ حساب", false);

            var payment = new ZarinpalSandbox.Payment(transactionForm.ChargeWallet.Amount);

            var result = await payment
                         .PaymentRequest("شارژ کیف پول",
                                         string.Concat(Request.Scheme, "://", Request.Host.ToUriComponent(),
                                                       $"/OnlinePayment/{transactionId}"), "*****@*****.**", "09905492104");

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

            await _userService.RemoveFailedTransactionAsync(
                await _userService.GetTransactionByIdAsync(transactionId));

            TempData["Error"] = "پرداخت با خطا مواجه شد";
            return(View(transactionForm));
        }
        public PaymentRequest Pay(PayInput input)
        {
            _payment = new ZarinpalSandbox.Payment(Convert.ToInt32(input.Amount));
            // var result = _payment.PaymentRequest(input.OrderId + input.Description, "https://localhost:5001/Payment/Verify", input.Email, input.Mobile);
            var            result = _payment.PaymentRequest(input.OrderId + input.Description, "https://localhost:5001/Payment/Verify");
            PaymentRequest pay    = new PaymentRequest();

            if (result.IsCompletedSuccessfully)
            {
                _session.SetInt32(result.Result.Authority, input.Amount);

                pay.Authority = result.Result.Authority;
                pay.Link      = result.Result.Link;
                pay.Status    = result.Result.Status;
            }
            return(pay);;
        }
        public VerifyResponse Verify(string Authority)
        {
            VerifyResponse verify = new VerifyResponse();

            if (!string.IsNullOrEmpty(Authority))
            {
                _payment = new ZarinpalSandbox.Payment(Convert.ToInt32(_session.GetInt32(Authority)));
                _session.Clear();
                var result = _payment.Verification(Authority);
                if (result.Result.Status == 100)
                {
                    verify.Status    = result.Result.Status;
                    verify.RefId     = result.Result.RefId;
                    verify.Authority = Authority;
                }
            }
            return(verify);
        }
Exemplo n.º 5
0
 public IActionResult OnlinePayment(int id)
 {
     if (HttpContext.Request.Query["Status"] != "" &&
         HttpContext.Request.Query["Status"].ToString().ToLower() == "ok" &&
         HttpContext.Request.Query["Authority"] != "")
     {
         string authority = HttpContext.Request.Query["Authority"];
         var    wallet    = _userService.GetWalletByWalletId(id);
         var    payment   = new ZarinpalSandbox.Payment(wallet.Amount);
         var    res       = payment.Verification(authority).Result;
         if (res.Status == 100)
         {
             ViewBag.code      = res.RefId;
             ViewBag.IsSuccess = true;
             wallet.IsPay      = true;
             _userService.UpdateWallet(wallet);
         }
     }
     return(View());
 }
Exemplo n.º 6
0
        public ActionResult Index(WalletViewModel.WalletChargeViewModle charge)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.ListWallet = _userService.GetWalletUser(User.Identity.Name);
                return(View(charge));
            }

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

            // Online Payment bank
            var payment = new ZarinpalSandbox.Payment(charge.Amount);
            var res     = payment.PaymentRequest("شارژ کیف پول", "http://*****:*****@gmail.com", "09339689095");

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

            return(null);
        }
Exemplo n.º 7
0
        public async Task <IActionResult> OnlinePayment(string authority, string status, int transactionId = 0)
        {
            if (string.IsNullOrEmpty(status) ||
                string.IsNullOrEmpty(authority))
            {
                return(NotFound());
            }

            if (transactionId is 0)
            {
                return(NotFound());
            }

            var transaction = await _userService.GetTransactionByIdAsync(transactionId);

            if (transaction is null)
            {
                return(NotFound());
            }

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

            var result = payment.Verification(authority).Result;

            if (!(result.Status is 100))
            {
                await _userService.RemoveFailedTransactionAsync(transaction);

                ViewBag.IsSuccess = false;
                return(View());
            }

            await _userService.VerifyTransactionAsync(transaction);

            ViewBag.RefId     = result.RefId;
            ViewBag.IsSuccess = true;
            return(View());
        }
Exemplo n.º 8
0
        public ActionResult Index()
        {
            if (!ModelState.IsValid)
            {
                return(View(_userService.GetCartUser(User.Identity.Name)));
            }

            int cartId = _userService.ChargeCart(User.Identity.Name, _userService.GetAmountCarts(User.Identity.Name), "شارژ حساب");


            #region Online Payment

            var payment = new ZarinpalSandbox.Payment(_userService.GetAmountCarts(User.Identity.Name));

            var res = payment.PaymentRequest("شارژ کیف پول", "https://Foroghefarda.ir/OnlinePayment/" + cartId);

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

            #endregion
            return(null);
        }
Exemplo n.º 9
0
        public IActionResult Index(ChargeViewModel charge)
        {
            if (!ModelState.IsValid)
            {
                ViewBag.listwallet = _UserService.getuserwallet(User.Identity.Name);
                return(View(charge));
            }


            int walletid = _UserService.Chargewallet(User.Identity.Name, charge.Amount, "شارژ کیف");

            #region Payment
            var payment = new ZarinpalSandbox.Payment(charge.Amount);
            var res     = payment.PaymentRequest("شارژ کیف پول", "https://localhost:44373/OnlinePayment/" + walletid);
            if (res.Result.Status == 100)
            {
                Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + res.Result.Authority);
            }


            #endregion

            return(null);
        }