Ejemplo n.º 1
0
 private void OnSendToGrowerProfileTransAction(object sender, NavigationFramework.NavigationArgs.ProfileTransactionEventArgs e)
 {
     foreach (var item in e.Data)
     {
         TransactionsData.Add(item);
     }
 }
Ejemplo n.º 2
0
        public TransactionsData PoolTransactions(string hash, int page, int txcount)
        {
            const int numPerPage = 50;

            if (page <= 0)
            {
                page = 1;
            }
            using (var client = CreateApi())
            {
                var lastPage = ConvUtils.GetNumPages(txcount, numPerPage);
                if (page > lastPage)
                {
                    page = lastPage;
                }
                var result = new TransactionsData
                {
                    Page         = page,
                    LastPage     = lastPage,
                    HaveNextPage = page < lastPage
                };
                var offset = numPerPage * (page - 1);
                var poolTr = client.PoolTransactionsGet(ConvUtils.ConvertHashBack(hash), offset, numPerPage);
                var i      = offset + 1;
                foreach (var t in poolTr.Transactions)
                {
                    var tInfo = new TransactionInfo(i, t.Id, t.Trxn);
                    result.Transactions.Add(tInfo);
                    i++;
                }
                result.NumStr = poolTr.Transactions.Any() ? $"{offset + 1} - {offset + poolTr.Transactions.Count} of {txcount}" : "0";
                return(result);
            }
        }
Ejemplo n.º 3
0
        public TransactionsData GetCustomerInfo(
            long transactionId,
            string firstName,
            string lastName,
            string emailId,
            string userMobileNo,
            string barcodeNumber,
            bool isFulFilment)
        {
            var spGetDetails = (string)null;
            TransactionsData transactionsData = new TransactionsData();

            if (isFulFilment)
            {
                spGetDetails = "spGetFulFilmentDataInfo";
            }
            else
            {
                spGetDetails = "spGetTransactionInfo";
            }
            var TransactionInfo = GetCurrentConnection().QueryMultiple(spGetDetails, new
            {
                TransactionId = transactionId,
                FirstName     = firstName,
                LastName      = lastName,
                EmailId       = emailId,
                UserMobileNo  = userMobileNo,
                BarcodeNumber = barcodeNumber
            }, commandType: CommandType.StoredProcedure);

            transactionsData.TransactionInfos = TransactionInfo.Read <TransactionInfo>();
            return(transactionsData);
        }
Ejemplo n.º 4
0
 public TransactionsData AccountTransactions(string id, int page, bool conv = true)
 {
     if (page <= 0)
     {
         page = 1;
     }
     using (var client = CreateApi())
     {
         const int itemsPerPage = 15;
         var       result       = new TransactionsData {
             Page = page, Transactions = new List <TransactionInfo>()
         };
         var offset = itemsPerPage * (page - 1);
         var trs    = client.TransactionsGet(Base58Encoding.Decode(id), offset, itemsPerPage + 1);
         result.HaveNextPage = trs.Transactions.Count > itemsPerPage;
         var count = Math.Min(itemsPerPage, trs.Transactions.Count);
         for (var i = 0; i < count; i++)
         {
             var t     = trs.Transactions[i];
             var tInfo = new TransactionInfo(i + offset + 1, "_", t.Trxn);
             result.Transactions.Add(tInfo);
         }
         return(result);
     }
 }
Ejemplo n.º 5
0
        // Returns the list of txs on given page, from cache
        public TransactionsData Txs(int page, int limit)
        {
            if (limit < 10 || limit > 100)
            {
                limit = 25;
            }
            if (page <= 0)
            {
                page = 1;            // Page
            }
            // Get the list of cached blocks, from given page (we cache last 100K blocks)
            var txs = _indexService.GetTxs(Net, (page - 1) * limit, limit);

            // Prepare all data for page and return
            var offset   = limit * (page - 1);
            var stats    = _indexService.GetStatData(Net);
            var lastPage = ConvUtils.GetNumPages(IndexService.SizeOutAll, limit);

            var result = new TransactionsData
            {
                Page         = page,
                Transactions = txs,
                HaveNextPage = page < lastPage,
                LastPage     = lastPage,
                NumStr       = txs.Any() ? $"{offset + 1} - {offset + txs.Count} of {stats.Total.AllTransactions.Value}" : "-",
                TxCount      = stats.Total.AllTransactions.Value
            };

            return(result);
        }
Ejemplo n.º 6
0
        public TransactionsData PoolTransactions(string hash, int page)
        {
            if (page <= 0)
            {
                page = 1;
            }
            using (var client = CreateApi())
            {
                var result = new TransactionsData {
                    Page = page
                };
                const int numPerPage = 50;
                var       offset     = numPerPage * (page - 1);
                var       poolTr     = client.PoolTransactionsGet(ConvUtils.ConvertHashBack(hash), offset, numPerPage);
                var       i          = offset + 1;
                foreach (var t in poolTr.Transactions)
                {
                    var tInfo = new TransactionInfo(i, $"{hash}.{i}", t.Trxn);
                    result.Transactions.Add(tInfo);
                    i++;
                }

                return(result);
            }
        }
Ejemplo n.º 7
0
        private string BuildUrlStringToSend(TransactionsData data)
        {
            string sendStr;
            string remoteChargeUrl = WebConfigurationManager.AppSettings["RemoteChargeUrl"];

            StringBuilder sb = new StringBuilder(remoteChargeUrl);

            sb.Append("CompanyNum=" + HttpUtility.UrlEncode(data.CompanyNumber) + "&");
            sb.Append("TransType=" + HttpUtility.UrlEncode(Convert.ToInt32(TransactionType.Debit).ToString()) + "&");
            sb.Append("ClientIP=" + HttpUtility.UrlEncode(data.ClientIp) + "&");
            sb.Append("CardNum=" + HttpUtility.UrlEncode(data.CardNumber) + "&");
            sb.Append("ExpMonth=" + HttpUtility.UrlEncode(data.Month.ToString()) + "&");
            sb.Append("ExpYear=" + HttpUtility.UrlEncode(data.Year.ToString()) + "&");
            sb.Append("Member=" + HttpUtility.UrlEncode(data.CardHolderName.ToString()) + "&");
            sb.Append("TypeCredit=" + HttpUtility.UrlEncode(Convert.ToInt32(TypeCredit.Debit).ToString()) + "&");
            sb.Append("Payments=" + HttpUtility.UrlEncode("1") + "&");         // 1 - for regular transaction
            sb.Append("Amount=" + HttpUtility.UrlEncode(data.Amount.ToString()) + "&");
            sb.Append("Currency=" + HttpUtility.UrlEncode(data.Currency.ToString()) + "&");
            sb.Append("CVV2=" + HttpUtility.UrlEncode(data.Cvv.ToString()) + "&");
            sb.Append("Email=" + HttpUtility.UrlEncode(data.Email) + "&");
            sb.Append("PhoneNumber=" + HttpUtility.UrlEncode(data.Phone) + "&");
            sb.Append("BillingAddress1=" + HttpUtility.UrlEncode(data.BillingAddress) + "&");
            sb.Append("BillingCity=" + HttpUtility.UrlEncode(data.City) + "&");
            sb.Append("BillingZipCode=" + HttpUtility.UrlEncode(data.ZipCode) + "&");
            sb.Append("BillingCountry=" + HttpUtility.UrlEncode(data.CountryCode) + "&");
            //Signature
            string signature = data.CompanyNumber + TransactionType.ChargeCC.ToString() + ((int)TypeCredit.Refund).ToString() +
                               data.Amount.ToString() + data.Currency.ToString() + data.CardNumber + data.RefTransID + data.PersonalHashKey;
            string shaSignature = Signature.GenerateSHA256(signature);
            string encodedTo64  = Signature.EncodeTo64(shaSignature);

            sb.Append("Signature=" + HttpUtility.UrlEncode(encodedTo64));
            sendStr = sb.ToString();
            return(sendStr);
        }
Ejemplo n.º 8
0
        private TransactionsData FillTransactionsData()
        {
            string merchantId      = WebConfigurationManager.AppSettings["MerchantId"];
            string personalHashKey = WebConfigurationManager.AppSettings["PersonalHashKey"];

            TransactionsData data = new TransactionsData();

            data.CompanyNumber   = merchantId;  //merchant id
            data.CardHolderName  = txtCardholderName.Text;
            data.Email           = txtEmail.Text;
            data.CardNumber      = txtCardNumber.Text;
            data.Month           = (ddlExpMonth.SelectedValue != "0") ?  Convert.ToInt32(ddlExpMonth.SelectedValue) : 1;
            data.Year            = this.ddlExpYear.SelectedValue;
            data.Cvv             = txtCvv.Text;
            data.BillingAddress  = txtAddress.Text;
            data.City            = txtCity.Text;
            data.ZipCode         = txtZipCode.Text;
            data.CountryCode     = ddlCountry.SelectedValue;
            data.Phone           = txtPhone.Text;
            data.Amount          = 2.00m; //Hardcoded for the exam, the value must be transferred from Order details screen
            data.Currency        = "ILS"; //ILS (Israel New Shekel)
            data.PersonalHashKey = personalHashKey;
            data.ClientIp        = "1.2.3.4";
            data.RefTransID      = "1234";
            return(data);
        }
Ejemplo n.º 9
0
        public TransactionsData ScHistory(int page, string from, string to)
        {
            using (var client = CreateApi())
            {
                var data  = new TransactionsData();
                var pools = client.PoolListGet(0, 100);
                foreach (var poolsPool in pools.Pools)
                {
                    if (poolsPool.TransactionsCount == 0)
                    {
                        continue;
                    }
                    var poolHash = ConvUtils.ConvertHashAscii(poolsPool.Hash);
                    var trs      = client.PoolTransactionsGet(poolsPool.Hash, 0, 0, long.MaxValue);
                    var i        = 1;
                    foreach (var trsTransaction in trs.Transactions)
                    {
                        if (string.IsNullOrEmpty(trsTransaction.SmartContract?.SourceCode))
                        {
                            continue;
                        }
                        data.Transactions.Add(new TransactionInfo(i, $"{poolHash}.{i}", trsTransaction));
                        i++;
                    }
                }

                data.Page         = page;
                data.HaveNextPage = false;
                return(data);
            }
        }
Ejemplo n.º 10
0
        public TransactionsData AccountTransactions(string id, int page, bool conv = true)
        {
            const int numPerPage = 15;

            if (page <= 0)
            {
                page = 1;
            }
            using (var client = CreateApi())
            {
                var offset = numPerPage * (page - 1);
                var trs    = client.TransactionsGet(Base58Encoding.Decode(id), offset, numPerPage + 1);
                var result = new TransactionsData
                {
                    Page         = page,
                    Transactions = new List <TransactionInfo>(),
                    HaveNextPage = trs.Transactions.Count > numPerPage
                };
                var count = Math.Min(numPerPage, trs.Transactions.Count);
                for (var i = 0; i < count; i++)
                {
                    var t     = trs.Transactions[i];
                    var tInfo = new TransactionInfo(i + offset + 1, t.Id, t.Trxn);
                    result.Transactions.Add(tInfo);
                }
                result.NumStr = count > 0 ? $"{offset + 1} - {offset + count}" : "-";
                return(result);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        ///     Close view, which binding with this viewModel.
        /// </summary>
        /// <param name="obj"></param>
        private void OnCloseCommand(object obj)
        {
            SelectedMenuItem = null;
            TransactionsData.Clear();

            BaseSingleton <NavigationObserver> .Instance.OnCloseView();
        }
Ejemplo n.º 12
0
 private void OnSendToBuyerProfileTransAction(object sender, ProfileTransactionEventArgs e)
 {
     foreach (var item in e.Data)
     {
         TransactionsData.Add(item);
     }
 }
Ejemplo n.º 13
0
        /// <summary>
        ///     ctor().
        /// </summary>
        public BuyerProfilePageViewModel()
        {
            BaseSingleton <NavigationObserver> .Instance.SendToBuyerProfileTransAction += OnSendToBuyerProfileTransAction;

            CloseCommand = new Command(() => {
                TransactionsData.Clear();
                BaseSingleton <NavigationObserver> .Instance.OnCloseView();
            });
        }
Ejemplo n.º 14
0
        /// <summary>
        ///     ctor().
        /// </summary>
        public GrowerProfileViewModel()
        {
            BaseSingleton <NavigationObserver> .Instance.SendToGrowerProfileTransAction += OnSendToGrowerProfileTransAction;

            CloseCommand = new Command(() => {
                SelectedMenuItem = null;
                TransactionsData.Clear();

                BaseSingleton <NavigationObserver> .Instance.OnCloseView();
            });
        }
Ejemplo n.º 15
0
        public TransactionsData PoolData(string id)
        {
            using (var client = CreateApi())
            {
                var poolHash = ConvUtils.ConvertHashBack(id);
                var pool     = client.PoolInfoGet(poolHash, 0);

                var result = new TransactionsData
                {
                    Page  = 1,
                    Found = pool.IsFound,
                    Info  = new PoolInfo(pool.Pool)
                };
                return(result);
            }
        }
Ejemplo n.º 16
0
        // Gets pool transactions from API by given block hash, page
        // txcount is for making a label
        public TransactionsData PoolTransactions(string hash, int page, int limit, int txcount)
        {
            if (limit < 10 || limit > 100)
            {
                limit = 25;
            }
            if (page <= 0)
            {
                page = 1;
            }

            using (var client = CreateApi())
            {
                // Calculate last page
                var lastPage = ConvUtils.GetNumPages(txcount, limit);
                if (page > lastPage)
                {
                    page = lastPage;
                }

                // Prepare result
                var result = new TransactionsData
                {
                    Page         = page,
                    LastPage     = lastPage,
                    HaveNextPage = page < lastPage
                };

                // Get the list of transactions from API
                var offset = limit * (page - 1);
                var poolTr = client.PoolTransactionsGet(ConvUtils.ConvertHashBack(hash), offset, limit);
                var i      = offset + 1;

                // Fill result with transactions
                foreach (var t in poolTr.Transactions)
                {
                    var tInfo = new TransactionInfo(i, t.Id, t.Trxn);
                    result.Transactions.Add(tInfo);
                    i++;
                }

                // Make label that above transactions table, it's simpler to make it here, and return the result
                result.NumStr = poolTr.Transactions.Any() ? $"{offset + 1} - {offset + poolTr.Transactions.Count} of {txcount}" : "0";
                return(result);
            }
        }
Ejemplo n.º 17
0
        // Gets block data from API by given hash (id)
        public TransactionsData PoolData(string id)
        {
            using (var client = CreateApi())
            {
                // Get data from node
                var poolHash = ConvUtils.ConvertHashBack(id);
                var pool     = client.PoolInfoGet(poolHash, 0);

                // Prepare and return result
                var result = new TransactionsData
                {
                    Page  = 1,
                    Found = pool.IsFound,
                    Info  = new BlockInfo(pool.Pool)
                };
                return(result);
            }
        }
Ejemplo n.º 18
0
        private void SilentPostCharge(TransactionsData data)
        {
            string sendStr = BuildUrlStringToSend(data);

            ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create(sendStr);

            webReq.Method = "GET";

            try
            {
                HttpWebResponse webRes = (HttpWebResponse)webReq.GetResponse();
                StreamReader    sr     = new StreamReader(webRes.GetResponseStream());
                string          resStr = sr.ReadToEnd();

                if (!string.IsNullOrEmpty(resStr))
                {
                    TransactionResult transResult = new TransactionResult();
                    string[]          resParts    = resStr.Split('&');
                    if (resParts != null && resParts.Length > 0)
                    {
                        string   reply      = resParts.ToList().Where(l => l.StartsWith("Reply")).Select(l => l).FirstOrDefault();
                        string[] replyParts = reply.Split('=');
                        if (replyParts?.Length > 1)
                        {
                            transResult.Code = replyParts[1];
                        }
                        string   replyDesc = resParts.ToList().Where(l => l.StartsWith("ReplyDesc")).Select(l => l).FirstOrDefault();
                        string[] descParts = replyDesc.Split('=');
                        if (descParts?.Length > 1)
                        {
                            transResult.Description = descParts[1];
                        }
                    }
                    Session["TransactionResult"] = transResult;
                }

                Response.Redirect("TransResult.aspx");
            }
            catch (Exception ex)
            {
                Response.Write(ex.Message);
            }
        }
Ejemplo n.º 19
0
        public TransactionsData AccountTransactions(string id, int page)
        {
            using (var client = CreateApi())
            {
                const int itemsPerPage = 15;
                var       result       = new TransactionsData {
                    Page = page, Transactions = new List <TransactionInfo>()
                };
                var offset = itemsPerPage * (page - 1);
                var trs    = client.TransactionsGet(id, offset, itemsPerPage + 1);
                result.HaveNextPage = trs.Transactions.Count > itemsPerPage;
                for (var i = 0; i < trs.Transactions.Count; i++)
                {
                    var t     = trs.Transactions[i];
                    var tInfo = new TransactionInfo(i + offset + 1, "_", t);
                    result.Transactions.Add(tInfo);
                }

                return(result);
            }
        }
Ejemplo n.º 20
0
        // Gets the list of transactions by given account id, and page,
        // conv must = false if smart contract transactions requested
        public TransactionsData AccountTransactions(string id, int page, int limit, bool conv = true)
        {
            if (limit < 10 || limit > 25)
            {
                limit = 25;
            }
            if (page <= 0)
            {
                page = 1;
            }

            using (var client = CreateApi())
            {
                // Get the list of transactions from the API
                var offset   = limit * (page - 1);
                var trs      = client.TransactionsGet(Base58Encoding.Decode(id), offset, limit + 1);
                var lastPage = page;

                // Prepare the result
                var result = new TransactionsData
                {
                    Page         = page,
                    Transactions = new List <TransactionInfo>(),
                    HaveNextPage = trs.Transactions.Count > limit,
                    LastPage     = lastPage
                };

                // Fill data and return the result
                var count = Math.Min(limit, trs.Transactions.Count);
                for (var i = 0; i < count; i++)
                {
                    var t     = trs.Transactions[i];
                    var tInfo = new TransactionInfo(i + offset + 1, t.Id, t.Trxn);
                    result.Transactions.Add(tInfo);
                }
                result.NumStr = count > 0 ? $"{offset + 1} - {offset + count} of {offset + count}" : "-";
                return(result);
            }
        }
Ejemplo n.º 21
0
        protected void btnPay_Click(object sender, EventArgs e)
        {
            TransactionsData data = FillTransactionsData();

            SilentPostCharge(data);
        }