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 paymentResult = new PaymentResult();
            var orderId       = _orderApplication.PlaceOrder(cart);

            if (paymentMethod == 1)
            {
                _orderApplication.PaymentSucceeded(orderId, 23231);
                return(RedirectToPage("/PaymentResult",
                                      paymentResult.Succeeded(
                                          "سفارش شما با موفقیت ثبت شد. در اسرا وقت برای شما ارسال میشود.", null)));
            }
            else
            {
                _orderApplication.PaymentSucceeded(orderId, 23231);
                return(RedirectToPage("/PaymentResult",
                                      paymentResult.Succeeded(
                                          "سفارش شما با موفقیت ثبت شد. پس از تماس کارشناسان ما و پرداخت وجه، سفارش ارسال خواهد شد.", null)));
            }



            /*   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));*/
        }
Example #2
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}"));
            }
        }
Example #3
0
        public IActionResult OnGetCallBack([FromQuery] string authority, [FromQuery] string status,
                                           [FromQuery] long oId)
        {
            var orderAmount          = _orderApplication.GetAmountBy(oId);
            var verificationResponse =
                _zarinPalFactory.CreateVerificationRequest(authority,
                                                           orderAmount.ToString(CultureInfo.InvariantCulture));

            var result = new PaymentResult();

            if (status == "OK" && verificationResponse.Status >= 100)
            {
                var issueTrackingNo = _orderApplication.PaymentSucceeded(oId, verificationResponse.RefID);
                Response.Cookies.Delete("cart-items");
                result = result.Succeeded("پرداخت با موفقیت انجام شد.", issueTrackingNo);
                return(RedirectToPage("/PaymentResult", result));
            }

            result = result.Failed(
                "پرداخت با موفقیت انجام نشد. درصورت کسر وجه از حساب، مبلغ تا 24 ساعت دیگر به حساب شما بازگردانده خواهد شد.");
            return(RedirectToPage("/PaymentResult", result));
        }