/// <summary>
 /// Returns boolean indicating whether payment has been accepted by zarinpal
 /// </summary>
 /// <param name="authority">36digit long code</param>
 /// <param name="status">status code</param>
 /// <returns>true - accepted; false - not accepted.</returns>
 public bool VerifyPayment(string authority, string status)
 {
     try
     {
         var query = from or in _orderRepository.Table
                     where or.AuthorizationTransactionCode == authority
                     select or;
         _logger.InsertLog(LogLevel.Debug, "in verify1 :" + query.Count());
         ZarinPalService.PaymentGatewayImplementationService zps = new ZarinPalService.PaymentGatewayImplementationService();
         _logger.InsertLog(LogLevel.Debug, "in verify2 : merch code: " + _zarinPalPaymentSettings.MerchantCode + " %% authority code: " + authority + " %% order total: " + query.FirstOrDefault().OrderTotal);
         if (zps.PaymentVerification(_zarinPalPaymentSettings.MerchantCode, authority, Convert.ToInt32(query.FirstOrDefault().OrderTotal / 10), out long RefID).Equals(100))
         {
             _logger.InsertLog(LogLevel.Debug, "in verify3");
             query.FirstOrDefault().AuthorizationTransactionResult = RefID.ToString();
             _logger.InsertLog(LogLevel.Debug, "in verify4");
             _orderRepository.Update(query.FirstOrDefault());
             _logger.InsertLog(LogLevel.Debug, "in verify5");
             return(true);
         }
         else
         {
             _logger.InsertLog(LogLevel.Debug, "in verify: verification failed");
             return(false);
         }
     }
     catch (Exception ex)
     {
         _logger.InsertLog(LogLevel.Debug, "in verify: " + ex.Message);
         return(false);
     }
 }
Beispiel #2
0
        protected override void InitData()
        {
            base.InitData();

            if (MasterBindingSource.Current != null)
            {
                var fixedAssetArmortizationId = ((FixedAssetArmortizationModel)MasterBindingSource.Current).RefId;
                KeyValue    = fixedAssetArmortizationId.ToString(CultureInfo.InvariantCulture);
                _keyForSend = KeyValue;
                RefId       = long.Parse(KeyValue);
            }
            else
            {
                _keyForSend = RefID.ToString();
            }

            _fixedAssetsPresenter.DisplayByActiveWithFixedAssetCurrency(false);

            _budgetItemsPrensenter.Display(3, true);

            _cboCurrencyCode.Items.Add(CurrencyLocal);
            if (CurrencyLocal != CurrencyAccounting)
            {
                _cboCurrencyCode.Items.Add(CurrencyAccounting);
            }

            _fixedAssetArmortizationPresenter.Display(long.Parse(KeyValue));
            CurrencyCode          = CurrencyLocal;
            cboCurrency.EditValue = CurrencyLocal;
        }
Beispiel #3
0
        public override TreeNode PopulateTreeNode()
        {
            base.PopulateTreeNode();

            TreeNode ThisNode = new TreeNode();

            ThisNode.Text = string.Format("Type4: {0}", Unk1);
            ThisNode.Name = RefID.ToString();
            ThisNode.Tag  = this;

            return(ThisNode);
        }
Beispiel #4
0
        public override TreeNode PopulateTreeNode()
        {
            base.PopulateTreeNode();

            TreeNode ThisNode = new TreeNode();

            ThisNode.Text = "Type7";
            ThisNode.Name = RefID.ToString();
            ThisNode.Tag  = this;

            return(ThisNode);
        }
Beispiel #5
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());
        }
Beispiel #6
0
        internal Transaction ZarinPalCallBackPayRequest(Guid transId, string status, string authority)
        {
            var transaction = PaymentComponenets.Instance.TransactionFacade.Get(transId);

            if (transaction == null)
            {
                return(null);
            }

            string value   = transaction.AdditionalData;
            string deValue = StringUtils.Decrypt(value);
            var    data    = deValue.Split('#');

            if (status.Equals("OK"))
            {
                int    Amount = ((int)transaction.Amount) / 10;
                long   RefID;
                string merchantId = data[0];
                System.Net.ServicePointManager.Expect100Continue = false;
                ZarinPalService.PaymentGatewayImplementationServicePortTypeClient zarinPalService = new ZarinPalService.PaymentGatewayImplementationServicePortTypeClient();

                int Status = zarinPalService.PaymentVerification(merchantId, authority, Amount, out RefID);

                transaction.RefId  = RefID.ToString();
                transaction.Status = Status;
                if (Status == 100)
                {
                    transaction.Done = true;
                }

                if (!PaymentComponenets.Instance.TransactionFacade.Update(transaction))
                {
                    return(null);
                }
                return(transaction);
            }
            else
            {
                //انصراف توسط کاربر یا عدم موفقیت پرداخت
                transaction.Status = 404;
                if (!PaymentComponenets.Instance.TransactionFacade.Update(transaction))
                {
                    return(null);
                }
                return(transaction);
            }
        }
        public override TreeNode PopulateTreeNode()
        {
            base.PopulateTreeNode();

            TreeNode ThisNode = new TreeNode();

            ThisNode.Text = "Type1 Group";
            ThisNode.Name = RefID.ToString();
            ThisNode.Tag  = this;

            foreach (IType AIPoint in AIPoints)
            {
                ThisNode.Nodes.Add(AIPoint.PopulateTreeNode());
            }

            return(ThisNode);
        }
        public async Task <IHttpActionResult> ZarinpalPaid(long id, string Authority, string Status)
        {
            if (string.IsNullOrEmpty(Authority) || string.IsNullOrEmpty(Status))
            {
                return(BadRequest());
            }

            if (Status != "OK")
            {
                return(InternalServerError(new Exception("Zarinpal gateway error, Authority:" + Authority + ", Status:" + Status)));
            }

            var invoice = await db.DepositInvoices.FindAsync(id);

            if (invoice == null)
            {
                return(NotFound());
            }
            System.Net.ServicePointManager.Expect100Continue = false;
            Zarinpal.PaymentGatewayImplementationServicePortTypeClient zp = new Zarinpal.PaymentGatewayImplementationServicePortTypeClient();

            long RefID;
            int  verStatus = zp.PaymentVerification("YOUR-ZARINPAL-MERCHANT-CODE", Authority, invoice.Amount, out RefID);

            if (verStatus == 100)
            {
                invoice.ReferenceNumber = RefID.ToString();
                //1) Create an account for the payer according to AccountName
                //2) Create two journal entries to debit the campaign and credit the user
                //3) Create the related transaction
            }
            else
            {
                return(InternalServerError(new Exception("Zarinpal gateway error, status:" + verStatus.ToString())));
            }
            db.Entry(invoice).State = EntityState.Modified;
            await db.SaveChangesAsync();

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private List <CheckInService.IdcProperty> GetCustomDocMetaData(DocumentM doc)
        {
            List <CheckInService.IdcProperty> customDocMetaData = new List <CheckInService.IdcProperty>();
            int RefID;

            customDocMetaData.Add(new CheckInService.IdcProperty()
            {
                name = "xProfileTrigger", value = ConfigurationManager.AppSettings["xProfileTrigger"]
            });
            customDocMetaData.Add(new CheckInService.IdcProperty()
            {
                name = "xIdcProfile", value = ConfigurationManager.AppSettings["xIdcProfile"]
            });
            customDocMetaData.Add(new CheckInService.IdcProperty()
            {
                name = "xAgencyDepartment", value = ConfigurationManager.AppSettings["xAgencyDepartment"]
            });
            customDocMetaData.Add(new CheckInService.IdcProperty()
            {
                name = "xDivision", value = ConfigurationManager.AppSettings["xDivision"]
            });
            var refIDResult = _commonService.GetDocReferenceID(doc);

            if (refIDResult.status.Status == StatusEnum.Success)
            {
                RefID = refIDResult.result;
            }
            else
            {
                RefID = 6312;
            }
            customDocMetaData.Add(new CheckInService.IdcProperty()
            {
                name = "xReferenceType", value = RefID.ToString()
            });
            return(customDocMetaData);
        }
Beispiel #10
0
        public ActionResult Verify()
        // public void Verify()
        {
            try
            {
                if (Request.QueryString["Status"] != "" && Request.QueryString["Status"] != null && Request.QueryString["Authority"] != "" && Request.QueryString["Authority"] != null)
                {
                    if (Request.QueryString["Status"].ToString().Equals("OK"))
                    {
                        string json  = "";
                        string json2 = "";
                        using (var client = new WebClient())
                        {
                            json = client.DownloadString("http://supectco.com/webs/textile/getorderamount.php?auth=" + Request.QueryString["Authority"]);
                        }

                        var log2   = JsonConvert.DeserializeObject <List <AUTHModel> >(json);
                        int Amount = Convert.ToInt32(log2[0].TotalPrice);


                        long RefID;
                        System.Net.ServicePointManager.Expect100Continue = false;
                        ServiceReference1.PaymentGatewayImplementationServicePortTypeClient zp = new ServiceReference1.PaymentGatewayImplementationServicePortTypeClient();



                        int Status = zp.PaymentVerification("9e9d57bc-07e1-11e8-ad17-000c295eb8fc", Request.QueryString["Authority"].ToString(), Amount, out RefID);

                        if (Status == 100)
                        {
                            string device = RandomString();
                            string code   = MD5Hash(device + "ncase8934f49909");

                            string result2 = "";
                            using (WebClient client = new WebClient())
                            {
                                var collection2 = new NameValueCollection();
                                collection2.Add("device", device);
                                collection2.Add("code", code);
                                collection2.Add("auth", Request.QueryString["Authority"]);
                                collection2.Add("amount", Amount.ToString());
                                collection2.Add("token", GlobalVariables.token);
                                collection2.Add("refID", RefID.ToString());

                                byte[] response =
                                    client.UploadValues("http://supectco.com/webs/textile/Main/handler/doFinalCheck.php", collection2);

                                result2 = System.Text.Encoding.UTF8.GetString(response);
                            }


                            //using (var client = new WebClient())
                            //{
                            //    json = client.DownloadString("http://supectco.com/webs/textile/getorderdetail.php?auth=" + Request.QueryString["Authority"]);
                            //}
                            //var log = JsonConvert.DeserializeObject<List<OrderIdModel>>(json);
                            //ViewBag.message = "موفق";
                            //ViewBag.message2 = RefID;
                            //ViewBag.message3 = log[0].ID;

                            //HttpCookie productides = new HttpCookie("cartmodel");
                            //productides = Request.Cookies["cartmodel"];
                            //List<ProductDetail> data = JsonConvert.DeserializeObject<List<ProductDetail>>(productides.Value);
                            //foreach (var item in data)
                            //{

                            //    using (var client = new WebClient())
                            //    {
                            //        json2 = client.DownloadString("http://supectco.com/webs/textile/addOrderProduct.php?orderid=" + log[0].ID + "&productid=" + item.productid + "&quantity=" + item.quantity);
                            //    }


                            //}

                            //Response.Cookies["cartmodel"].Expires = DateTime.Now.AddDays(-1);
                            HttpCookie myCookie = new HttpCookie("cartmodel");
                            myCookie.Expires = DateTime.Now.AddDays(-1d);
                            Response.Cookies.Add(myCookie);
                            ViewBag.message  = "موفق";
                            ViewBag.message2 = RefID;
                        }
                        else
                        {
                            ViewBag.message  = "عدم موفقیت خرید";
                            ViewBag.message2 = "شماره پیگیری:" + RefID;
                        }
                    }
                    else
                    {
                        Response.Write("some thing wrong with payment");
                    }
                }
                else
                {
                    Response.Write("Invalid Input");
                }
            }
            catch (Exception e)
            {
                Response.Write(e.Message);
            }

            return(View());
        }