コード例 #1
0
        public void PostProcessPayment(PostProcessPaymentRequest postProcessPaymentRequest)
        {
            string text = string.Empty;

            ServicePointManager.Expect100Continue = false;
            PaymentGatewayImplementationServicePortTypeClient service = new PaymentGatewayImplementationServicePortTypeClient(this.Binding, this.EndPoint);
            string  callbackURL = this._webHelper.GetStoreLocation(false) + "Plugins/ZarinpalNopFarsi/Verify";
            decimal value       = Math.Round(postProcessPaymentRequest.Order.OrderTotal / 10m, 0);

            if (this._zarinpalPaymentSettings.IsToman)
            {
                value *= 10;
            }
            string text2;
            int    num = service.PaymentRequest(this._zarinpalPaymentSettings.MerchantId, (int)value * 10, string.Format(this._localizationService.GetResource("NopFarsi.Zarinpal.Payment.Description"), postProcessPaymentRequest.Order.Id.ToString("#,#")), postProcessPaymentRequest.Order.BillingAddress.Email, postProcessPaymentRequest.Order.BillingAddress.PhoneNumber, callbackURL, out text2);

            if (num == 100)
            {
                this._genericAttributeService.SaveAttribute <string>(postProcessPaymentRequest.Order, "ZarinpalAuthority", text2, 0);
                text = string.Format(this._zarinpalPaymentSettings.PayementUrl, text2);
            }
            if (string.IsNullOrWhiteSpace(text))
            {
                throw new Exception(string.Format(this._localizationService.GetResource("NopFarsi.Zarinpal.Payment.FailureMessage"), this.TranslateStatus(num)));
            }
            this._httpContext.Response.Redirect(text);
        }
コード例 #2
0
        private static PaymentGatewayImplementationServicePortTypeClient GetService()
        {
            ServicePointManager.Expect100Continue = false;
            var zp = new PaymentGatewayImplementationServicePortTypeClient();

            return(zp);
        }
コード例 #3
0
        public ActionResult Payment()
        {
            List <ShopCartItem> cart = Session["ShoppingCart"] as List <ShopCartItem>;

            if (cart.Count == 0)
            {
                ViewBag.Error = "سبد خرید شما خالی است.";
                return(RedirectToAction("Index"));
            }
            var order = _repoOr.AddOrder(cart, int.Parse(User.Identity.Name));

            ServicePointManager.Expect100Continue = false;
            PaymentGatewayImplementationServicePortTypeClient zp = new PaymentGatewayImplementationServicePortTypeClient();
            string Authority;

            int Status = zp.PaymentRequest("YOUR-ZARINPAL-MERCHANT-CODE", order.TotalPrice, "درگاه پرداخت تست زرین پال", "*****@*****.**", "09361997137", "http://localhost:13327/ShoppingCart/Verify/" + order.Id, out Authority);

            if (Status == 100)
            {
                Response.Redirect("https://sandbox.zarinpal.com/pg/StartPay/" + Authority);
            }
            else
            {
                ViewBag.Error = Status;
            }

            return(View());
        }
コード例 #4
0
 public FakeStrategy()
 {
     _zarinPal            = new PaymentGatewayImplementationServicePortTypeClient();
     _userBusiness        = IocInitializer.GetInstance <IUserBusiness>();
     _transactionBusiness = IocInitializer.GetInstance <ITransactionBusiness>();
     _orderBusiness       = IocInitializer.GetInstance <IOrderBusiness>();
     _observerManager     = IocInitializer.GetInstance <Lazy <IObserverManager> >();
 }
コード例 #5
0
        private async Task <BankPaymentRequestResponseDto> GetZarinPalReferenceId(InvoiceDto invoice, int invoiceAmount, string transactionNumber, string userId, BankNameType bankName)
        {
            try
            {
                System.Net.ServicePointManager.Expect100Continue = false;
                PaymentGatewayImplementationServicePortTypeClient zp = new PaymentGatewayImplementationServicePortTypeClient();
                string authority;

                var callBackUrl = ApplicationSettings.FinancialSettings.ZarinPal.DefaultCallBackUrl;

                int status = zp.PaymentRequest(
                    ApplicationSettingsHelper.AppSetting("ZarinPal.MerchantCode"),
                    (int)invoiceAmount,
                    $"Invoice #{invoice.InvoiceNumber}",
                    ApplicationSettings.DefaultEmailAddress,
                    ApplicationSettings.DefaultMobileNumber,
                    callBackUrl,
                    out authority);

                if (status == 100)
                {
                    var authorityUrl = ZarinPalHelper.GetUrl(authority);
                    var transaction  = new FinanceTransaction(invoice.Id, transactionNumber, userId, bankName, authority);

                    UnitOfWork.FinanceTransactionRepository.Create(transaction);
                    await UnitOfWork.SaveAsync();

                    return(new BankPaymentRequestResponseDto()
                    {
                        Response = authorityUrl,
                        PaymentRequestType = PaymentRequestType.Url,
                        PaymentRequestTypeTitle = "URL"
                    });
                }
                else
                {
                    return(new BankPaymentRequestResponseDto()
                    {
                        HasError = true,
                        Error = BankResultException(status.ToString(), BankNameType.ZarinPal)
                    });
                }
            }
            catch
            {
                return(new BankPaymentRequestResponseDto()
                {
                    HasError = true,
                    Error = BankResultException("", BankNameType.ZarinPal)
                });
            }
        }
コード例 #6
0
        //Check payment status from authority
        private void CheckPaymentStatus(string autohority)
        {
            PaymentGatewayImplementationServicePortTypeClient request = new PaymentGatewayImplementationServicePortTypeClient();
            long refID   = -1;
            bool stopit  = false;
            long curtick = DateTime.Now.Ticks / TimeSpan.TicksPerSecond;

            while (true)
            {
                if (stopit)
                {
                    break;
                }
                int verf = -21;
                try
                {
                    verf = request.PaymentVerification(MerchantID, autohority, 120, out refID);
                }
                catch (Exception ex)
                {
                }
                if (verf > 0)
                {
                    stopit = true;
                    if (OnPaymentAction != null)
                    {
                        OnPaymentAction(this, new pay.PayArgs(verf, autohority, refID));
                    }
                }
                else
                {
                    if (!stopit && verf != -21)
                    {
                        stopit = true;
                        if (OnPaymentAction != null)
                        {
                            OnPaymentAction(this, new pay.PayArgs(verf, autohority, refID));
                        }
                    }
                }
                long curtime = DateTime.Now.Ticks / TimeSpan.TicksPerSecond;
                if ((curtime - curtick) > 1850) // 30 * 60 +- 50
                {
                    if (!stopit)
                    {
                        OnPaymentAction(this, new pay.PayArgs(-22, autohority, refID));
                        stopit = true;
                    }
                }
            }
        }
コード例 #7
0
        public ActionResult Verify(int id)
        {
            //پیدا کردن sum

            var order = _repoOr.GetOrder(id);

            //Status == Ok || NOK
            //Authority == كد يكتاي شناسه مرجع درخواست
            if (Request.QueryString["Status"] != "" && Request.QueryString["Status"] != null &&
                Request.QueryString["Authority"] != "" && Request.QueryString["Authority"] != null)
            {
                //اگر وضعیت پرداخت اوکی بود
                if (Request.QueryString["Status"].ToString().Equals("OK"))
                {
                    //jame tamame maghadir onja save hastesh
                    int  Amount = order.TotalPrice;
                    long RefID;
                    ServicePointManager.Expect100Continue = false;
                    PaymentGatewayImplementationServicePortTypeClient zp =
                        new PaymentGatewayImplementationServicePortTypeClient();

                    int Status =
                        zp.PaymentVerification("YOUR-ZARINPAL-MERCHANT-CODE",
                                               Request.QueryString["Authority"].ToString(), Amount, out RefID);

                    if (Status == 100)
                    {
                        Session["ShoppingCart"] = null;
                        Session["Count"]        = null;
                        ViewBag.IsSuccess       = true;
                        ViewBag.RefId           = RefID;
                        _repoOr.UpdateIsFinaly(order.Id, RefID.ToString());
                    }
                    else
                    {
                        ViewBag.Status = Status;
                    }
                }
                else
                {
                    ViewBag.Status = "Error! Authority: " + Request.QueryString["Authority"].ToString() + " Status: " + Request.QueryString["Status"].ToString();
                }
            }
            else
            {
                Response.Write("Invalid Input");
            }
            return(View());
        }
コード例 #8
0
        public ActionResult Purchase(string stripeEmail, string stripeToken, AdManageViewModel model)
        {
            AdManage objAdManage = new AdManage();
            var      result      = new JsonResult();

            int    selectedplan = Convert.ToInt32(TempData["PlanAmount"]);
            string planname     = Enum.GetName(typeof(CommanClass.Plans), selectedplan);
            int    planvalue    = (int)Enum.Parse(typeof(CommanClass.PlanType), planname.ToString());
            int    planamount   = selectedplan * 100;
            string FileName     = string.Empty;
            int    userid       = Convert.ToInt32(Session["UserId"]);
            var    customers    = new StripeCustomerService();
            var    charges      = new StripeChargeService();

            try
            {
                var RegisteredUser = registrationRepository.GetClientById(userid);

                if (!string.IsNullOrEmpty(stripeEmail))
                {
                    var customer = customers.Create(new StripeCustomerCreateOptions
                    {
                        Email       = stripeEmail,
                        SourceToken = stripeToken
                    });

                    var charge = charges.Create(new StripeChargeCreateOptions
                    {
                        Amount      = planamount,
                        Description = selectedplan.ToString(),
                        //Currency = "usd",
                        Currency   = "eur",
                        CustomerId = customer.Id
                    });

                    //Save Response in PaymentTransaction Table
                    PaymentTransaction payment = new PaymentTransaction()
                    {
                        RegistId                             = userid,
                        Customer_stripeEmail                 = stripeEmail,
                        Customer_Id                          = customer.Id,
                        Customer_stripeToken                 = stripeToken,
                        Customer_Created                     = customer.Created,
                        Customer_DefaultSourceId             = customer.DefaultSourceId,
                        Customer_InvoicePrefix               = customer.InvoicePrefix,
                        Customer_StripeResponse_RequestId    = customer.StripeResponse.RequestId,
                        Customer_StripeResponse_ResponseJson = customer.StripeResponse.ResponseJson,

                        Charge_Id     = charge.Id,
                        Charge_Amount = charge.Amount,
                        Charge_BalanceTransactionId = charge.BalanceTransactionId,
                        Charge_Created               = charge.Created,
                        Charge_CustomerId            = charge.CustomerId,
                        Charge_Description           = charge.Description,
                        Charge_FailureCode           = charge.FailureCode,
                        Charge_FailureMessage        = charge.FailureMessage,
                        Charge_Outcome_SellerMessage = charge.Outcome.SellerMessage,
                        Charge_Paid      = charge.Paid,
                        Charge_Source_Id = charge.Source.Id,
                        Charge_Status    = charge.Status,
                        Charge_StripeResponse_RequestId    = charge.StripeResponse.RequestId,
                        Charge_StripeResponse_ResponseJson = charge.StripeResponse.ResponseJson,
                        IsSuccess     = true,
                        Response      = "Complete",
                        PaymentMethod = (int)CommanClass.PaymentMethod.Stripe
                    };
                    _paymentRepository.AddPayment(payment);
                    //_paymentRepository.SaveAll();

                    //Insert stripe response information in PaymentTransaction table
                    //db.PaymentTransaction.Add(payment);
                    //db.SaveChanges();

                    RegisteredUser.PaymentStatus = true;
                    registrationRepository.Edit(RegisteredUser);

                    if (!string.IsNullOrEmpty(charge.FailureCode))
                    {
                        model.ResponseMessage = "Your subscription failed!!";
                        model.Paymentstatus   = CommanClass.PaymentStatus.Failed;
                        return(View(model));
                    }
                }
                //for zarinpal payment plugin
                else
                {
                    //Payment with Zarinpal Service reference.
                    string             authority = string.Empty;
                    int                payment_request_response = 0;
                    PaymentTransaction payment = new PaymentTransaction();
                    try
                    {
                        PaymentGatewayImplementationServicePortTypeClient request = new PaymentGatewayImplementationServicePortTypeClient();
                        Amount = PlanCalculate.CalculatePlanAmount(selectedplan);
                        payment_request_response = request.PaymentRequest(MerchantID, 120, "Test", "", "", ZarinpalCallbackURL, out authority);
                        if (payment_request_response > 0)
                        {
                            if (Request.Files[0].ContentLength > 0)
                            {
                                Guid FileNameGuid = Guid.NewGuid();
                                FileName = FileNameGuid.ToString() + ".html";
                                string _path = Path.Combine(Server.MapPath("~/AdHTML"), FileName);
                                Request.Files[0].SaveAs(_path);
                            }

                            objAdManage             = Mapper.Map <AdManageViewModel, AdManage>(model);
                            objAdManage.Addeddate   = DateTime.Now.Date;
                            objAdManage.RegistAdId  = userid;
                            objAdManage.UpdateDate  = DateTime.Now.Date;
                            objAdManage.UpdatedBy   = userid;
                            objAdManage.UploadFile  = FileName;
                            objAdManage.Description = model.Description;

                            adManageRepository.AddAd(objAdManage);
                            adManageRepository.SaveAll();

                            payment.IsSuccess = false;
                            payment.RegistId  = userid;
                            payment.Authority = authority;
                            payment.Payment_RequestResponse = payment_request_response;
                            payment.Charge_Amount           = Convert.ToInt32(Amount);
                            //Insert in Payment Table
                            Session["IsPaymentPrecessing"] = false;
                            _paymentRepository.InsertPaymentTransactionData(payment);
                            //Redirect to zarinpal gateway site for payment.
                            return(Redirect(ZarinpalPaymentURL + authority));
                        }
                    }
                    catch (Exception ex)
                    {
                        payment.Charge_Amount                = Convert.ToInt32(Amount);
                        payment.IsSuccess                    = false;
                        payment.RegistId                     = userid;
                        payment.Authority                    = authority;
                        payment.Payment_RequestResponse      = payment_request_response;
                        payment.PaymentRequest_ErrorResponse = ex.ToString();
                        _paymentRepository.InsertPaymentTransactionData(payment);
                        Session["PaymentStatus"]       = false;
                        Session["IsPaymentPrecessing"] = false;
                    }
                }

                //Insert in DB
                if (Request.Files[0].ContentLength > 0)
                {
                    //FileName = Convert.ToString(Session["UserId"]) + ".html";
                    Guid FileNameGuid = Guid.NewGuid();
                    FileName = FileNameGuid.ToString() + ".html";
                    string _path = Path.Combine(Server.MapPath("~/AdHTML"), FileName);
                    Request.Files[0].SaveAs(_path);
                }

                // AdManage objAdManage = new AdManage();
                objAdManage             = Mapper.Map <AdManageViewModel, AdManage>(model);
                objAdManage.Addeddate   = DateTime.Now;
                objAdManage.RegistAdId  = Convert.ToInt64(Session["UserId"]);
                objAdManage.UpdateDate  = DateTime.Now;
                objAdManage.UpdatedBy   = Convert.ToInt32(Session["UserId"]);
                objAdManage.UploadFile  = FileName;
                objAdManage.Description = model.Description;

                adManageRepository.AddAd(objAdManage);
                if (adManageRepository.SaveAll())
                {
                    Registration objRegisterUser = registrationRepository.GetClientById(userid);
                    objRegisterUser.PaymentStatus = true;
                    registrationRepository.Edit(objRegisterUser);
                    Session["PaymentStatus"] = true;
                    model.ResponseMessage    = "Your subscription succesfully!!";
                    model.Paymentstatus      = CommanClass.PaymentStatus.Sucess;
                    return(View(model));
                }
                else
                {
                    model.ResponseMessage    = "Your subscription failed!!";
                    model.Paymentstatus      = CommanClass.PaymentStatus.Failed;
                    Session["PaymentStatus"] = false;
                }
            }
            catch (Exception ex)
            {
                //result.Data = "Your subscription failed!! " + ex.Message.ToString();
                model.ResponseMessage    = "Your subscription failed!! " + ex.Message.ToString();
                model.Paymentstatus      = CommanClass.PaymentStatus.Failed;
                Session["PaymentStatus"] = false;
            }

            return(View(model));
        }
コード例 #9
0
        public ActionResult ZarinpalCallback(string Authority = "", string Status = "")
        {
            ShortnerContext   db    = new ShortnerContext();
            AdManageViewModel model = new AdManageViewModel();
            PaymentGatewayImplementationServicePortTypeClient request = new PaymentGatewayImplementationServicePortTypeClient();
            long userid = (long)Session["UserId"];
            PaymentRepository  paymentrepo        = new PaymentRepository(db);
            PaymentTransaction paymenttransaction = new PaymentTransaction();

            long RefID    = 0;
            int  response = 0;

            try
            {
                var RegisteredUser = registrationRepository.GetClientById(userid);
                paymenttransaction = _paymentRepository.GetPaymentByRegistId(userid);

                if (Status == "OK")
                {
                    Amount = PlanCalculate.CalculatePlanAmount(Convert.ToInt32(TempData["PlanAmount"]));

                    //PAYMENT VERIFICATION
                    response = request.PaymentVerification(MerchantID, Authority, 120, out RefID);

                    if (RefID > 0)
                    {
                        //CheckPaymentStatus(Authority);
                        Registration objRegisterUser = registrationRepository.GetClientById(userid);
                        objRegisterUser.PaymentStatus = true;
                        registrationRepository.Edit(objRegisterUser);
                        Session["PaymentStatus"]         = true;
                        model.ResponseMessage            = "Your subscription succesfully!!";
                        model.Paymentstatus              = CommanClass.PaymentStatus.Sucess;
                        paymenttransaction.RegistId      = userid;
                        paymenttransaction.Charge_Paid   = true;
                        paymenttransaction.IsSuccess     = true;
                        paymenttransaction.PaymentMethod = (int)CommanClass.PaymentMethod.Zarinpal;
                        paymenttransaction.Response      = "Complete";
                        paymenttransaction.Status        = Status;
                        paymenttransaction.ReferenceID   = RefID;
                        paymenttransaction.PaymentVerificationResponse = response;
                        paymenttransaction.Charge_Amount = Convert.ToInt32(Amount);
                        _paymentRepository.UpdatePaymentTransactionData(paymenttransaction);

                        RegisteredUser.PaymentStatus = true;
                        registrationRepository.Edit(RegisteredUser);
                        Session["IsPaymentPrecessing"] = true;
                        return(RedirectToAction("Purchase", "Payment", model));
                    }
                }
                if (Status == "NOK")
                {
                    paymenttransaction.RegistId      = userid;
                    paymenttransaction.Charge_Amount = Convert.ToInt32(Amount);
                    paymenttransaction.Charge_Paid   = false;
                    paymenttransaction.ExpireDate    = DateTime.Now.AddDays(30);
                    paymenttransaction.IsSuccess     = false;
                    paymenttransaction.PaymentMethod = (int)CommanClass.PaymentMethod.Zarinpal;
                    paymenttransaction.Response      = "Failed";
                    paymenttransaction.Status        = Status;
                    paymenttransaction.ReferenceID   = RefID;
                    paymenttransaction.Authority     = Authority;
                    paymenttransaction.PaymentVerificationResponse = response;
                    _paymentRepository.UpdatePaymentTransactionData(paymenttransaction);
                    Session["IsPaymentPrecessing"] = false;

                    RegisteredUser.PaymentStatus = false;
                    registrationRepository.Edit(RegisteredUser);

                    model.ResponseMessage    = "Your subscription failed!!";
                    model.Paymentstatus      = CommanClass.PaymentStatus.Failed;
                    Session["PaymentStatus"] = false;
                }
            }
            catch (Exception ex)
            {
                paymenttransaction.RegistId      = userid;
                paymenttransaction.Charge_Amount = Convert.ToInt32(Amount);
                paymenttransaction.Charge_Paid   = false;
                paymenttransaction.IsSuccess     = false;
                paymenttransaction.PaymentMethod = (int)CommanClass.PaymentMethod.Zarinpal;
                paymenttransaction.Response      = "Failed" + ex.ToString();
                paymenttransaction.Status        = Status;
                paymenttransaction.ReferenceID   = RefID;
                paymenttransaction.Authority     = Authority;
                paymenttransaction.PaymentVerificationResponse = Convert.ToInt32(response);
                _paymentRepository.UpdatePaymentTransactionData(paymenttransaction);

                model.ResponseMessage          = "Your subscription failed!" + ex;
                model.Paymentstatus            = CommanClass.PaymentStatus.Failed;
                Session["PaymentStatus"]       = false;
                Session["IsPaymentPrecessing"] = false;
            }
            return(RedirectToAction("Purchase", "Payment", model));
        }
コード例 #10
0
 private static System.ServiceModel.EndpointAddress GetDefaultEndpointAddress()
 {
     return(PaymentGatewayImplementationServicePortTypeClient.GetEndpointAddress(EndpointConfiguration.PaymentGatewayImplementationServicePort));
 }
コード例 #11
0
 private static System.ServiceModel.Channels.Binding GetDefaultBinding()
 {
     return(PaymentGatewayImplementationServicePortTypeClient.GetBindingForEndpoint(EndpointConfiguration.PaymentGatewayImplementationServicePort));
 }
コード例 #12
0
 public PaymentGatewayImplementationServicePortTypeClient(EndpointConfiguration endpointConfiguration, System.ServiceModel.EndpointAddress remoteAddress) :
     base(PaymentGatewayImplementationServicePortTypeClient.GetBindingForEndpoint(endpointConfiguration), remoteAddress)
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
コード例 #13
0
 public PaymentGatewayImplementationServicePortTypeClient(EndpointConfiguration endpointConfiguration) :
     base(PaymentGatewayImplementationServicePortTypeClient.GetBindingForEndpoint(endpointConfiguration), PaymentGatewayImplementationServicePortTypeClient.GetEndpointAddress(endpointConfiguration))
 {
     this.Endpoint.Name = endpointConfiguration.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
コード例 #14
0
 public PaymentGatewayImplementationServicePortTypeClient() :
     base(PaymentGatewayImplementationServicePortTypeClient.GetDefaultBinding(), PaymentGatewayImplementationServicePortTypeClient.GetDefaultEndpointAddress())
 {
     this.Endpoint.Name = EndpointConfiguration.PaymentGatewayImplementationServicePort.ToString();
     ConfigureEndpoint(this.Endpoint, this.ClientCredentials);
 }
コード例 #15
0
        public async Task <ActionResult> ResultHandler(string status, string authority, string oGUID)
        {
            if (!(await _paymentPluginManager.LoadPluginBySystemNameAsync("Payments.Zarinpal") is ZarinPalPaymentProcessor processor) || !_paymentPluginManager.IsPluginActive(processor))
            {
                throw new NopException("ZarinPal module cannot be loaded");
            }

            var orderNumberGuid = Guid.Empty;

            orderNumberGuid = new Guid(oGUID);


            var order = await _orderService.GetOrderByGuidAsync(orderNumberGuid);

            var total = Convert.ToInt32(Math.Round(order.OrderTotal, 2));

            if (_zarinPalPaymentSettings.RialToToman)
            {
                total = total / 10;
            }


            if (string.IsNullOrEmpty(status) == false && string.IsNullOrEmpty(authority) == false)
            {
                var refId = "0";
                System.Net.ServicePointManager.Expect100Continue = false;
                var statusCode = -1;
                var storeScope = await _storeContext.GetActiveStoreScopeConfigurationAsync();

                var zarinPalSettings = await _settingService.LoadSettingAsync <ZarinpalPaymentSettings>(storeScope);

                if (_zarinPalPaymentSettings.Method == EnumMethod.SOAP)
                {
                    if (_zarinPalPaymentSettings.UseSandbox)
                    {
                        using (PaymentGatewayImplementationServicePortTypeClient zpalSr = new PaymentGatewayImplementationServicePortTypeClient())
                        {
                            var res = zpalSr.PaymentVerificationAsync
                                      (
                                zarinPalSettings.MerchantID,
                                authority,
                                total
                                      ).Result; //test

                            statusCode = res.Body.Status;
                            refId      = res.Body.RefID.ToString();
                        }
                    }
                    else
                    {
                        using (PaymentGatewayImplementationServicePortTypeClient zpalSr = new ServiceReferenceZarinpal.PaymentGatewayImplementationServicePortTypeClient())
                        {
                            var res = zpalSr.PaymentVerificationAsync(
                                zarinPalSettings.MerchantID,
                                authority,
                                total).Result;
                            statusCode = res.Body.Status;
                            refId      = res.Body.RefID.ToString();
                        }
                    }
                }
                else if (_zarinPalPaymentSettings.Method == EnumMethod.REST)
                {
                    var url    = $"https://{(_zarinPalPaymentSettings.UseSandbox ? "sandbox" : "www")}.zarinpal.com/pg/rest/WebGate/PaymentVerification.json";
                    var values = new Dictionary <string, string>
                    {
                        { "MerchantID", zarinPalSettings.MerchantID },
                        { "Authority", authority },
                        { "Amount", total.ToString() }     //Toman
                    };

                    var paymenResponsetJsonValue = JsonConvert.SerializeObject(values);
                    var content = new StringContent(paymenResponsetJsonValue, Encoding.UTF8, "application/json");

                    var response       = ZarinPalPaymentProcessor.ClientZarinPal.PostAsync(url, content).Result;
                    var responseString = response.Content.ReadAsStringAsync().Result;

                    var restVerifyModel =
                        JsonConvert.DeserializeObject <RestVerifyModel>(responseString);
                    statusCode = restVerifyModel.Status;
                    refId      = restVerifyModel.RefID;
                }

                var result = ZarinpalHelper.StatusToMessage(statusCode);

                var orderNote = new OrderNote()
                {
                    OrderId = order.Id,
                    Note    = string.Concat(
                        "پرداخت ",
                        (result.IsOk ? "" : "نا"), "موفق", " - ",
                        "پیغام درگاه : ", result.Message,
                        result.IsOk ? string.Concat(" - ", "کد پی گیری : ", refId) : ""
                        ),
                    DisplayToCustomer = true,
                    CreatedOnUtc      = DateTime.UtcNow
                };

                await _orderService.InsertOrderNoteAsync(orderNote);

                if (result.IsOk && _orderProcessingService.CanMarkOrderAsPaid(order))
                {
                    order.AuthorizationTransactionId = refId;
                    await _orderService.UpdateOrderAsync(order);

                    await _orderProcessingService.MarkOrderAsPaidAsync(order);

                    return(RedirectToRoute("CheckoutCompleted", new { orderId = order.Id }));
                }
            }

            return(RedirectToRoute("orderdetails", new { orderId = order.Id }));
        }