Example #1
0
        public async Task <IActionResult> PaymentVerify(int amount, string description, string email, string mobile, string Authority, string Status)
        {
            if (_signInManager.IsSignedIn(User))
            {
                // get name of user
                string UserId = _ius.GetId();
                ViewBag.fullname = _ius.GetById(UserId).FirstName + " " + _ius.GetById(UserId).LastName;
                // update wallet
                ViewBag.Wallet = _ius.GetById(UserId).Wallet;
            }

            if (Status == "NOK")
            {
                return(View("failedPayment"));
            }

            // ارسال به صفحه خطا
            var verification = await new ZarinpalSandbox.Payment(amount).Verification(Authority);

            // ارسال کد تراکنش جهت نمایش به کاربر
            if (verification.Status != 100)
            {
                return(View("failedView"));
            }
            // اطلاعات پرداخت
            var RefId = verification.RefId;

            // اگر اطلاعات درست باشد، باید در دیتابیس ذخیره شود ------------
            DateTimePersian dt         = new DateTimePersian();
            string          shamsiDate = dt.shamsiDate();
            string          shamsiTime = dt.shamsiTime();

            // ثبت اطلاعات پرداخت در دیتابیس
            var result = _ips.PaymentVerify(_ius.GetId(),
                                            email,
                                            mobile,
                                            description,
                                            amount,
                                            verification.RefId.ToString());

            if (result)
            {
                ViewBag.TransactionNo   = verification.RefId.ToString();
                ViewBag.TransactonDate  = shamsiDate;
                ViewBag.TransactionTime = shamsiTime;
                ViewBag.Description     = description;
                ViewBag.Amount          = amount;

                return(View("SuccessfullyPayment"));
            }
            else
            {
                return(View("failedPayment"));
            }
        }