コード例 #1
0
        public IActionResult OnPostPay(int paymentMethod)
        {
            var cart = _cartService.Get();

            cart.SetPaymentMethod(paymentMethod);

            var result = _productQuery.CheckInventoryStatus(cart.Items);

            if (result.Any(x => !x.IsInStock))
            {
                return(RedirectToPage("/Cart"));
            }

            var orderId = _orderApplication.PlaceOrder(cart);

            if (paymentMethod == 1)
            {
                var paymentResponse = _zarinPalFactory.CreatePaymentRequest(
                    cart.PayAmount.ToString(CultureInfo.InvariantCulture), "", "",
                    "خرید از درگاه لوازم خانگی و دکوری", orderId);

                return(Redirect(
                           $"https://{_zarinPalFactory.Prefix}.zarinpal.com/pg/StartPay/{paymentResponse.Authority}"));
            }

            var paymentResult = new PaymentResult();

            return(RedirectToPage("/PaymentResult",
                                  paymentResult.Succeeded(
                                      "سفارش شما با موفقیت ثبت شد. پس از تماس کارشناسان ما و پرداخت وجه، سفارش ارسال خواهد شد.", null)));
        }
コード例 #2
0
        public IActionResult OnPostPay(int paymentMethod, string address, string phoneNumber)
        {
            if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(phoneNumber))
            {
                long number;
                if (string.IsNullOrEmpty(address))
                {
                    Message = "آدرس خود را مشخص نمایید";
                }
                if (string.IsNullOrEmpty(phoneNumber) || !phoneNumber.StartsWith("09") || !long.TryParse(phoneNumber, out number) || phoneNumber.Length != 11)
                {
                    Message = "شماره موبایل خود را وارد نمایید";
                }
                return(RedirectToPage("Checkout", new { message = Message }));
            }

            Cart = _cartService.GetCart();

            if (Cart.CartItems.Any(c => !c.IsInStock))
            {
                return(RedirectToPage("Cart"));
            }
            Cart.SetPaymentMethod(paymentMethod);
            Cart.Address      = address;
            Cart.MobileNumber = phoneNumber;

            var user    = _userQuery.GetUserBy(User.Identity.Name);
            var orderId = _orderApplication.PlaceOrder(Cart);

            if (paymentMethod == PaymentMethod.Online)
            {
                var paymentResponse = _zarinPalFactory.CreatePaymentRequest(Cart.PayAmount.ToString(), user.Mobile, user.Email, "خرید محصول", orderId);
                return(Redirect(
                           $"https://{_zarinPalFactory.Prefix}.zarinpal.com/pg/StartPay/{paymentResponse.Authority}"));
            }

            else if (paymentMethod == PaymentMethod.Cash)
            {
                OperationResult result = new OperationResult();

                var issueTrackingNo = _orderApplication.CreateCashOrderOperation(orderId);
                result.Succeeded($"سفارش شما ثبت گردید ، جهت ارسال محصول ، همکاران ما با شما تماس خواهند گرفت!\nشماره پیگیری شما :{issueTrackingNo}");
                Response.Cookies.Delete(CookieName);

                return(RedirectToPage("PaymentResult", result));
            }

            return(RedirectToPage("Index"));
        }
コード例 #3
0
        public IActionResult OnPostPay(int paymentMethod, PersonalInfoItemViewModel personalInfo)
        {
            var cart = _cartService.Get();

            cart.SetPaymentMethod(paymentMethod);


            var result = _productQuery.CheckInventoryStatus(cart.Items);

            if (result.Any(x => !x.IsInStock))
            {
                return(RedirectToPage("/ShoppingCart"));
            }

            var orderId         = _orderApplication.PlaceOrder(cart, personalInfo);
            var accountMobile   = _authHelper.CurrentAccountInfo().Mobile;
            var accountUserName = _authHelper.CurrentAccountInfo().Username;


            if (paymentMethod == 1)
            {
                var paymentResult = new PaymentResult();
                var creationDate  = DateTime.Now.ToFarsi();

                Response.Cookies.Delete(CookieName);

                return(RedirectToPage("/PaymentResult", paymentResult.Succeeded(
                                          "سفارش شما ثبت شد. پس از تماس کارشناسان ما و پرداخت وجه سفارش ارسال خواهد شد.", null, creationDate)));
            }
            else
            {
                var paymentResponse = _zarinPalFactory.CreatePaymentRequest(

                    cart.PayAmount.ToString(CultureInfo.InvariantCulture),
                    accountMobile,
                    accountUserName,
                    "خرید از فروشگاه هنری",
                    orderId

                    );

                return(Redirect($"https://{_zarinPalFactory.Prefix}.zarinpal.com/pg/StartPay/{paymentResponse.Authority}"));
            }
        }
コード例 #4
0
        public IActionResult OnGetPay()
        {
            var cart   = _cartService.Get();
            var result = _productQuery.CheckInventoryStatus(cart.Items);

            if (result.Any(x => !x.IsInStock))
            {
                return(RedirectToPage("/Cart"));
            }

            var orderId         = _orderApplication.PlaceOrder(cart);
            var paymentResponse = _zarinPalFactory.CreatePaymentRequest(

                cart.PayAmount.ToString(CultureInfo.InvariantCulture),
                "",
                "",
                "خرید از فروشگاه دکومال",
                orderId
                );

            return(Redirect($"https://{_zarinPalFactory.Prefix}.zarinpal.com/pg/StartPay/{paymentResponse.Authority}"));
        }