Beispiel #1
0
        public static List <Transaction> BuscaPorCodigo(int pIdConta, string Codigo, out string error)
        {
            error = null;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(false);

                credentials.Email = pMeuEmail[pIdConta];
                credentials.Token = pMeuToken[pIdConta];

                var ret = new List <Transaction>();



                Transaction result =
                    TransactionSearchService.SearchByCode(credentials, Codigo);

                if (result != null)
                {
                    ret.Add(result);
                }
                return(ret);
            }
            catch (Exception ex)
            {
                error = ex.ToString();
                return(null);
            }
        }
Beispiel #2
0
        public bool ConsultaBoletoRef(String reference)
        {
            bool valida    = false;
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);
            var myTimeZone = TimeZoneInfo.FindSystemTimeZoneById("E. South America Standard Time");
            var dataAtual  = TimeZoneInfo.ConvertTimeFromUtc(DateTime.UtcNow, myTimeZone);

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                // Realizando a consulta
                TransactionSearchResult result = TransactionSearchService.SearchByReference(credentials, reference);

                foreach (var item in result.Transactions.Where(m => m.LastEventDate.Month == dataAtual.Month && m.LastEventDate.Year == dataAtual.Year))
                {
                    if (item.TransactionStatus != 3)
                    {
                        valida = false;
                    }
                    else
                    {
                        valida = true;
                    }
                }
            }
            catch (PagSeguroServiceException exception)
            {
            }
            return(valida);
        }
Beispiel #3
0
        public async Task WhenPassedInvalidSearchQueryThenEmptyArrayOfTransactionsReturned()
        {
            //Arrange
            var srcResponse = new GetBlockByNumberResponse
            {
                Result = new Result
                {
                    Transactions = new List <EthereumTransactions.Services.ThirdPartyServices.Dtos.Infura.Transaction>()
                }
            };

            var mockEthereumService = new Mock <IEthereumService>();

            mockEthereumService.Setup(x => x.GetBlockByNumberAsync(It.IsAny <GetBlockByNumberRequest>(), CancellationToken.None))
            .ReturnsAsync(srcResponse).Verifiable();

            var service = new TransactionSearchService(mockEthereumService.Object, _mapper, _logger);

            var request = new TransactionSearchRequest
            {
                BlockNumber = 9148873,
                Address     = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa"
            };

            //Act
            var response = await service.ExecuteAsync(request, CancellationToken.None);

            //Assert
            Assert.NotNull(response);
            var transactions = response.Transactions;

            Assert.Empty(transactions);
            mockEthereumService.VerifyAll();
        }
Beispiel #4
0
        static void SearchByDateExample()
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

            // Definindo a data de ínicio da consulta
            DateTime initialDate = new DateTime(2011, 06, 1, 08, 50, 0);

            // Definindo a data de término da consulta
            DateTime finalDate = new DateTime(2011, 06, 29, 10, 30, 0);

            // Definindo o número máximo de resultados por página
            int maxPageResults = 20;

            // Definindo o número da página
            int pageNumber = 1;

            // Realizando a consulta
            TransactionSearchResult result =
                TransactionSearchService.SearchByDate(
                    credentials,
                    initialDate,
                    finalDate,
                    pageNumber,
                    maxPageResults);
        }
Beispiel #5
0
        // GET: PurchaseHistory/Details/1
        public ActionResult Details(int id)
        {
            var cart = Carts.SingleOrDefault(c => c.Id == id);

            if (cart == null)
            {
                return(HttpNotFound());
            }

            var credentials = PagSeguroConfiguration.Credentials();

            if (cart.TransactionCode == null)
            {
                var transactionResult = TransactionSearchService.SearchByReference(
                    credentials,
                    cart.ReferenceCode
                    );

                foreach (var transactionSummary in transactionResult.Transactions)
                {
                    if (transactionResult.Transactions.Count == 1)
                    {
                        cart.TransactionCode = transactionSummary.Code;
                    }
                }

                _context.SaveChanges();
            }

            var transaction = cart.TransactionCode != null?TransactionSearchService.SearchByCode(credentials, cart.TransactionCode) : null;

            return(View(new PurchaseHistoryViewModel(cart, transaction)));
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            String referenceCode = "REF123";

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

                // Realizando a consulta
                TransactionSearchResult result = TransactionSearchService.SearchByReference(credentials, referenceCode);

                if (result.Transactions.Count <= 0)
                {
                }
                foreach (TransactionSummary transaction in result.Transactions)
                {
                }
            }
            catch (PagSeguroServiceException exception)
            {
                foreach (ServiceError element in exception.Errors)
                {
                }
            }
        }
Beispiel #7
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                // TODO: Substitute the code below with a valid transaction code for your transaction
                //Transaction transaction = TransactionSearchService.SearchByCode(credentials, "59A13D84-52DA-4AB8-B365-1E7D893052B0", false);

                //Console.WriteLine(transaction);
                //Console.ReadKey();

                Transaction preApprovalTransaction = TransactionSearchService.SearchByCode(credentials, "3DFAD3123412340334A96F9136C38804", true);

                Console.WriteLine(preApprovalTransaction);
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
        public async Task <JsonResult> WebGetObjectDetail(string Prefix, string Value)
        {
            Prefix = Prefix.Substring(0, 3);
            var objectDetail = (await TransactionSearchService.GetObjectDetail(Prefix, Value)).objectDetail;

            return(Json(new { objectDetail = objectDetail }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult StatusCompra(string id_pagseguro)
        {
            id_pagseguro = "C58740AE-DF00-4732-AA48-DBDFB6A3122E";

            // Inicializando credenciais
            AccountCredentials credentials = new AccountCredentials(
                "*****@*****.**",
                "86D588A7611E48FABA6125B049503F5F"
                );

            // Código identificador da transação
            string transactionCode = id_pagseguro;

            // Realizando uma consulta de transação a partir do código identificador
            // para obter o objeto Transaction
            Transaction transaction = TransactionSearchService.SearchByCode(
                credentials,
                transactionCode
                );
            int status = transaction.TransactionStatus;

            //1   Aguardando pagamento: o comprador iniciou a transação, mas até o momento o PagSeguro não recebeu nenhuma informação sobre o pagamento.WaitingPayment
            //2   Em análise: o comprador optou por pagar com um cartão de crédito e o PagSeguro está analisando o risco da transação.InAnalysis
            //3   Paga: a transação foi paga pelo comprador e o PagSeguro já recebeu uma confirmação da instituição financeira responsável pelo processamento.Paid
            //4   Disponível: a transação foi paga e chegou ao final de seu prazo de liberação sem ter sido retornada e sem que haja nenhuma disputa aberta.	Available
            //5   Em disputa: o comprador, dentro do prazo de liberação da transação, abriu uma disputa.	InDispute
            //6   Devolvida: o valor da transação foi devolvido para o comprador.Refunded
            //7   Cancelada: a transação foi cancelada sem ter sido finalizada.	Cancelled


            return(View());
        }
        // GET: ConfirmacaoPagamento
        public ActionResult Index(string transaction_id)
        {
            PagSeguroConfiguration.UrlXmlConfiguration = HttpRuntime.AppDomainAppPath + "/Configuration/PagSeguroConfig.xml";

            bool        isSandbox   = false;
            string      sdsSituacao = "";
            Transaction transaction = null;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);
                transaction = TransactionSearchService.SearchByCode(credentials, transaction_id);

                if (transaction.TransactionStatus == Uol.PagSeguro.Enums.TransactionStatus.Paid)
                {
                    var reference             = long.Parse(transaction.Reference);
                    FinanceiroController finC = new FinanceiroController();
                    finC.RealizarPagamentoPagSeguro(reference);
                }
                var nnrSituacao = (int)transaction.TransactionStatus;
                if (nnrSituacao == 1)
                {
                    sdsSituacao = "Aguardando Pagamento";
                }
                if (nnrSituacao == 2)
                {
                    sdsSituacao = "Em Ánalise";
                }
                if (nnrSituacao == 3)
                {
                    sdsSituacao = "Paga";
                }
                if (nnrSituacao == 4)
                {
                    sdsSituacao = "Disponível";
                }
                if (nnrSituacao == 5)
                {
                    sdsSituacao = "Em disputa";
                }
                if (nnrSituacao == 6)
                {
                    sdsSituacao = "Devolvida";
                }
                if (nnrSituacao == 7)
                {
                    sdsSituacao = "Cancelada";
                }

                ViewBag.transaction = transaction;
                ViewBag.sdsSituacao = sdsSituacao;

                return(View());
            }
            catch
            {
                throw;
            }
        }
Beispiel #11
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            // Definindo a data de ínicio da consulta
            DateTime initialDate = new DateTime(2015, 10, 14, 08, 50, 0);

            // Definindo a data de término da consulta
            DateTime finalDate = DateTime.Now.AddMinutes(-15);

            // Definindo o número máximo de resultados por página
            int maxPageResults = 10;

            // Definindo o número da página
            int pageNumber = 1;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                // Realizando a consulta
                TransactionSearchResult result =
                    TransactionSearchService.SearchAbandoned(
                        credentials,
                        initialDate,
                        finalDate,
                        pageNumber,
                        maxPageResults);

                if (result.Transactions.Count <= 0)
                {
                    Console.WriteLine("Nenhuma transação abandonada");
                }

                foreach (TransactionSummary transaction in result.Transactions)
                {
                    Console.WriteLine("Começando listagem de transações abandonadas - \n");
                    Console.WriteLine(transaction.ToString());
                    Console.WriteLine(" - Terminando listagem de transações abandonadas");
                }

                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
Beispiel #12
0
        public static List <Transaction> BuscaPorData(int pIdConta, DateTime pDataDesde, out string error, DateTime?pDataAte = null, int?ItemsPerPage = null, string StatusCodes = "")
        {
            error = null;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(false);

                credentials.Email = pMeuEmail[pIdConta];
                credentials.Token = pMeuToken[pIdConta];

                var ret = new List <Transaction>();

                bool hasResult = true;
                int  page      = 1;

                StatusCodes = (StatusCodes == null || StatusCodes == "" ? "" : "," + StatusCodes + ",");
                StatusCodes = StatusCodes.Replace(" ", "");


                do
                {
                    TransactionSearchResult result =
                        TransactionSearchService.SearchByDate(
                            credentials,
                            pDataDesde,
                            pDataAte == null ? DateTime.Now : pDataAte.Value,
                            page,
                            ItemsPerPage == null ? iDefaulMaxPerPage : ItemsPerPage.Value);

                    if (result.Transactions.Count > 0)
                    {
                        foreach (TransactionSummary transactionsummary in result.Transactions)
                        {
                            if (StatusCodes == "" || StatusCodes.Contains("," + transactionsummary.TransactionStatus.ToString() + ","))
                            {
                                Transaction transaction = TransactionSearchService.SearchByCode(credentials, transactionsummary.Code);
                                ret.Add(transaction);
                            }
                        }
                    }

                    page++;
                    hasResult = (page <= result.TotalPages);
                } while (hasResult);

                return(ret);
            }
            catch (Exception ex)
            {
                error = ex.ToString();
                return(null);
            }
        }
Beispiel #13
0
        static void SearchByCodeExample()
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

            string transactionCode = "59A13D84-52DA-4AB8-B365-1E7D893052B0";

            Transaction transaction =
                TransactionSearchService.SearchByCode(credentials, transactionCode);
        }
        //static void RequestExample(HttpWebRequest Request)
        //{
        //    bool isSandbox = false;

        //    EnvironmentConfiguration.ChangeEnvironment(isSandbox);

        //    AccountCredentials credentials = new AccountCredentials("","");

        //    string notificationType = Request.Form["notificationType"];
        //    string notificationCode = Request.Form["notificationCode"];

        //    if (notificationType == "transaction")
        //    {
        //        // obtendo o objeto transaction a partir do código de notificação
        //        Transaction transaction =
        //            NotificationService.CheckTransaction(credentials, notificationCode);

        //        var status = transaction.TransactionStatus;
        //    }
        //}

        static void SearchByCodeExample()
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            AccountCredentials credentials = new AccountCredentials("", "");

            string transactionCode = "59A13D84-52DA-4AB8-B365-1E7D893052B0";

            Transaction transaction =
                TransactionSearchService.SearchByCode(credentials, transactionCode);

            Console.WriteLine(transaction.TransactionStatus);
            Console.WriteLine(transaction.GrossAmount);
        }
Beispiel #15
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            // Definindo a data de ínicio da consulta
            DateTime initialDate = new DateTime(2015, 10, 14, 08, 50, 0);

            // Definindo a data de término da consulta
            DateTime finalDate = DateTime.Now.AddMinutes(-15);

            // Definindo o número máximo de resultados por página
            int maxPageResults = 10;

            // Definindo o número da página
            int pageNumber = 1;

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

                // Realizando a consulta
                TransactionSearchResult result =
                    TransactionSearchService.SearchAbandoned(
                        credentials,
                        initialDate,
                        finalDate,
                        pageNumber,
                        maxPageResults);

                if (result.Transactions.Count <= 0)
                {
                    throw new Exception("Nenhuma transação abandonada");
                }

                foreach (TransactionSummary transaction in result.Transactions)
                {
                }
            }
            catch (PagSeguroServiceException exception)
            {
                foreach (ServiceError element in exception.Errors)
                {
                }
            }
        }
Beispiel #16
0
        static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

                // TODO: Substitute the code below with a valid transaction code for your transaction
                Transaction transaction = TransactionSearchService.SearchByCode(credentials, "59A13D84-52DA-4AB8-B365-1E7D893052B0");
            }
            catch (PagSeguroServiceException exception)
            {
                foreach (ServiceError element in exception.Errors)
                {
                }
            }
        }
Beispiel #17
0
        public int ConsultaTransacaoStatus(string transacao)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);
            AccountCredentials credentials     = PagSeguroConfiguration.Credentials(isSandbox);
            string             transactionCode = transacao;

            try
            {
                Transaction transaction = TransactionSearchService.SearchByCode(
                    credentials,
                    transactionCode);
                return(transaction.TransactionStatus);
            }
            catch (PagSeguroServiceException exception)
            {
                return(0);
            }
        }
Beispiel #18
0
        static void SearchByCodeExample2()
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            AccountCredentials credentials = PagSeguroConfiguration.GetAccountCredentials(isSandbox);

            // Código identificador da transação
            string transactionCode = "59A13D84-52DA-4AB8-B365-1E7D893052B0";

            // Realizando uma consulta de transação a partir do código identificador
            // para obter o objeto Transaction
            Transaction transaction =
                TransactionSearchService.SearchByCode(
                    credentials,
                    transactionCode);

            // Imprime o status da transação
        }
Beispiel #19
0
        public async Task <ActionResult> WebAcctTxnSearch(jQueryDataTableParamModel Params, TxnSearchModel Model, bool isDownload = false)
        {
            var _filtered = new List <AcctPostedTxnSearch>();
            var list      = (await TransactionSearchService.GetAccountTransactionSearch(Convert.ToInt64(Model.AcctNo), Convert.ToInt64(Model.CardNo), Model.SelectedTxnCategory, Convert.ToInt32(Model.SelectedTxnCd), Model.FromDate, Model.ToDate, Model.SelectedStatementDate)).transactionSearches;

            if (!isDownload)
            {
                if (!string.IsNullOrEmpty(Params.sSearch))
                {
                    Params.sSearch = Params.sSearch.ToLower();
                }
                if (!string.IsNullOrEmpty(Params.sSearch))
                {
                    _filtered = list.Where(p => p.InvoicDt.ToLower().Contains(Params.sSearch) || p.TxnDate.ToLower().Contains(Params.sSearch)).ToList();
                    _filtered = _filtered.Skip(Params.iDisplayStart).Take(Params.iDisplayLength).ToList();
                }
                else
                {
                    _filtered = list.Skip(Params.iDisplayStart).Take(Params.iDisplayLength).ToList();
                }
                return(Json(new
                {
                    sEcho = Params.sEcho,
                    iTotalRecords = list.Count(),
                    iTotalDisplayRecords = list.Count(),
                    aaData = _filtered.Select(x => new object[] { null, x.InvoicDt, x.TxnDate, x.PrcsDate, x.AcctNo, x.SelectedCardNo, x.AuthCardNo, x.TxnDesp, x.VehRegNo, x.Stan, x.ApproveCd, x.RRn, x.VATNo, x.Dealer, x.TxnId, x.TxnAmt, x.ProductDescp, x.Quantity, x.ProductAmt, x.VATAmt, x.VATCd, x.VATRate, })
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var title    = "Transaction search | Account";
                var toExport = new List <string[]>();
                var Header   = list.First().ExcelHeader;
                foreach (var item in list)
                {
                    toExport.Add(item.ExcelBody());
                }
                var ExcelPkg = Common.CommonHelpers.CreateExcel(Header, toExport, title);
                return(File(ExcelPkg.GetAsByteArray(), "application/vnd.ms-excel", title + ".xlsx"));
            }
        }
        /// <summary>
        /// Retorno do PagSeguro.
        /// Método executado quando o usuário espera ou clica no botão
        /// para que seja redirecionado novamente ao site, recebe uma
        /// chave que contem o numero da transação no pagSeguro
        /// </summary>
        /// <author>Claudinei Nascimento</author>
        /// <business>Vip-Systems Tecnologia & Inovação LTDA></business>
        /// <param name="id_pagseguro">exemplo de id:766B9C-AD4B044B04DA-77742F5FA653-E1AB24</param>
        /// <returns></returns>
        public ActionResult Retorno(String id_pagseguro)
        {
            ViewBag.Tema = Settings.Default.Tema;

            AccountCredentials credentials = new AccountCredentials(
                Settings.Default.EmailCredential,
                Settings.Default.TokenCredential
                );

            try
            {
                // obtendo o objeto transaction a partir do código de notificação
                Transaction transaction =
                    TransactionSearchService.SearchByCode(credentials, id_pagseguro);

                ViewBag.Stattus   = GetManutencaoPedido.statusRetornoPedido(transaction.TransactionStatus);
                ViewBag.Valor     = "R$ " + transaction.GrossAmount;
                ViewBag.Codigo    = id_pagseguro;
                ViewBag.Pagamento = GetManutencaoPedido.formaPagamentoPorNome(transaction.PaymentMethod.PaymentMethodType);
            }
            catch (PagSeguroServiceException ex)
            {
                StackTrace      exe = new StackTrace(ex, true);
                CustomException ep  = new CustomException(ex, exe, "");
                ep.Save(AppDomain.CurrentDomain.BaseDirectory + "/Logs/Log.log");

                if (ex.StatusCode == HttpStatusCode.Unauthorized)
                {
                    GravarLog.gravarLogError("Unauthorized: lease verify if the credentials used in the web service call  re correct./n", "Erro Transaction");
                }

                foreach (PagSeguroServiceError error in ex.Errors)
                {
                    GravarLog.gravarLogError(error.ToString(), "Erro PagSeguro");
                }
            }

            return(View("Finalizar"));
        }
Beispiel #21
0
        public TransactionSearchResult ConsultaTransacaoDate(DateTime InitialDate, DateTime FinalDate)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

            int maxPageResults = 1000;

            int pageNumber = 1;

            TransactionSearchResult result =
                TransactionSearchService.SearchByDate(
                    credentials,
                    InitialDate,
                    FinalDate,
                    pageNumber,
                    maxPageResults);

            return(result);
        }
        private static void Main(string[] args)
        {
            bool isSandbox = false;

            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            string referenceCode = "REF123";

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                // Realizando a consulta
                TransactionSearchResult result = TransactionSearchService.SearchByReference(credentials, referenceCode);

                if (result.Transactions.Count <= 0)
                {
                    Console.WriteLine("Nenhuma transação encontrada com a referência " + referenceCode);
                }
                foreach (TransactionSummary transaction in result.Transactions)
                {
                    Console.WriteLine("Começando listagem de transações - \n");
                    Console.WriteLine(transaction.ToString());
                    Console.WriteLine(" - Terminando listagem de transações ");
                }
                Console.ReadKey();
            }
            catch (PagSeguroServiceException exception)
            {
                Console.WriteLine(exception.Message + "\n");

                foreach (ServiceError element in exception.Errors)
                {
                    Console.WriteLine(element + "\n");
                }
                Console.ReadKey();
            }
        }
Beispiel #23
0
 public IActionResult CheckTransaction([FromRoute] string code)
 {
     if (string.IsNullOrEmpty(code))
     {
         return(BadRequest());
     }
     try
     {
         const bool isSandbox = true;
         EnvironmentConfiguration.ChangeEnvironment(isSandbox);
         var credentials = PagSeguroConfiguration.Credentials(isSandbox);
         var transaction = TransactionSearchService.SearchByCode(credentials, code, false);
         return(Ok(transaction));
     }
     catch (PagSeguroServiceException exception)
     {
         return(StatusCode(500, exception.Errors));
     }
     catch (Exception ex)
     {
         return(StatusCode(500, ex.Message));
     }
 }
Beispiel #24
0
        public async Task WhenGetBlockByNumberServiceThrowsAnexceptionThenExceptionIsRethrown()
        {
            //Arrange
            var mockEthereumService = new Mock <IEthereumService>();

            mockEthereumService.Setup(x => x.GetBlockByNumberAsync(It.IsAny <GetBlockByNumberRequest>(), CancellationToken.None))
            .Throws(new NullReferenceException("some exception")).Verifiable();

            var service = new TransactionSearchService(mockEthereumService.Object, _mapper, _logger);

            var request = new TransactionSearchRequest
            {
                BlockNumber = 9148873,
                Address     = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa"
            };

            //Act
            var exception = await Assert.ThrowsAsync <NullReferenceException>(() => service.ExecuteAsync(request, CancellationToken.None));

            //Assert
            Assert.Equal("some exception", exception.Message);
            mockEthereumService.VerifyAll();
        }
Beispiel #25
0
        public async Task <ActionResult> WebMerchTxnSearch(jQueryDataTableParamModel Params, TxnSearchModel Model, bool isDownload)
        {
            TxnSearchMaint _Maint    = new TxnSearchMaint();
            var            _filtered = new List <MerchPostedTxnSearch>();

            var list = (await TransactionSearchService.GetMerchTransactionSearch(Model.BusnLocation, Model.MerchAcctNo, Model.SelectedMerchTxnCd, Model.MerchFromDate, Model.MerchToDate, Model.SelectedTxnCategory)).merchPostedTxnSearches;

            if (!string.IsNullOrEmpty(Params.sSearch))
            {
                Params.sSearch = Params.sSearch.ToLower();
            }
            if (!isDownload)
            {
                _filtered = list.Skip(Params.iDisplayStart).Take(Params.iDisplayLength).ToList();
                return(Json(new
                {
                    sEcho = Params.sEcho,
                    iTotalRecords = list.Count(),
                    iTotalDisplayRecords = list.Count(),
                    aaData = _filtered.Select(x => new object[] { null, x.SelectedDealer, x.TermBatch, x.TxnDate, x.cardNo, x.TxnDesp, x.TxnAmt, x.TermId,
                                                                  x.AuthNo, x.AuthCardNo, x.PrcsDate, x.TxnId, x.ProductDescp, x.ProductQty, x.ProductAmt, x.VATAmt, x.BaseAmt, x.VATCd, x.VATRate, })
                }, JsonRequestBehavior.AllowGet));
            }
            else
            {
                var title    = "Transaction search | Merchant";
                var toExport = new List <string[]>();
                var Header   = list.First().ExcelHeader;
                foreach (var item in list)
                {
                    toExport.Add(item.ExcelBody());
                }
                var ExcelPkg = Common.CommonHelpers.CreateExcel(Header, toExport, title);
                return(File(ExcelPkg.GetAsByteArray(), "application/vnd.ms-excel", title + ".xlsx"));
            }
        }
Beispiel #26
0
        public Aluno_pgto ConsultarCode(string code)
        {
            EnvironmentConfiguration.ChangeEnvironment(isSandbox);

            try
            {
                AccountCredentials credentials = PagSeguroConfiguration.Credentials(isSandbox);

                Transaction transaction = TransactionSearchService.SearchByCode(credentials, code);

                return(TratarRetorno(transaction));
            }
            catch (PagSeguroServiceException exception)
            {
                string retorno = exception.Message + "\n";

                foreach (ServiceError element in exception.Errors)
                {
                    retorno += element + "\n";
                }

                return(new Aluno_pgto());
            }
        }
Beispiel #27
0
        public async Task WhenPassedValidSearchQueryThenValidTransactionsReturned()
        {
            //Arrange
            var srcResponse = new GetBlockByNumberResponse
            {
                Result = new Result
                {
                    Transactions = new List <EthereumTransactions.Services.ThirdPartyServices.Dtos.Infura.Transaction>
                    {
                        new EthereumTransactions.Services.ThirdPartyServices.Dtos.Infura.Transaction
                        {
                            BlockHash        = "0x6dbde4b224013c46537231c548bd6ff8e2a2c927c435993d351866d505c523f1",
                            BlockNumber      = "0x8b99c9",
                            From             = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa",
                            Gas              = "0x5208",
                            GasPrice         = "0x4a817c800",
                            Hash             = "0x1fd509bc8a1f26351400f4ca206dbe7b8ebb8dcf3925ddf7201e8764e1bd3ea3",
                            Input            = "0x",
                            Nonce            = "0x95e7",
                            R                = "0x8e0bd4787e3396dc1697ef278960f9d9743323d3e2b8d6a67f773f305385fe89",
                            S                = "0x7fe255386e1bb617c630a0ff8afdb2cc1affab7367df48232bfaddb7bd5b9d22",
                            To               = "0x59422595656a6b7c8917625607934d0e11fa0c40",
                            TransactionIndex = "0x3e",
                            Type             = "0x0",
                            V                = "0x1c",
                            Value            = "0x4563918244f400000"
                        },
                        new EthereumTransactions.Services.ThirdPartyServices.Dtos.Infura.Transaction
                        {
                            BlockHash        = "0x6dbde4b224013c46537231c548bd6ff8e2a2c927c435993d351866d505c523f1",
                            BlockNumber      = "0x8b99c9",
                            From             = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa",
                            Gas              = "0x5208",
                            GasPrice         = "0x4a817c800",
                            Hash             = "0xfcbbca93ff416601e5be95838fcfa2c534c48027b10172c12bf069784a4ec634",
                            Input            = "0x",
                            Nonce            = "0x95e7",
                            R                = "0x1c79013f8efbb2e4dce3d29e3626f08df16247b5069e58a88584878235d89f03",
                            S                = "0x168a66cf4819a5663e32eb09535b005211c9daae7bd25bde58e0e7f43f02adbf",
                            To               = "0x15776a03ef5fdf2a54a1b3a991c1641d0bfa39e7",
                            TransactionIndex = "0x3f",
                            Type             = "0x0",
                            V                = "0x1c",
                            Value            = "0xf17937cf93cc0000"
                        }
                    }
                }
            };

            var mockEthereumService = new Mock <IEthereumService>();

            mockEthereumService.Setup(x => x.GetBlockByNumberAsync(It.IsAny <GetBlockByNumberRequest>(), CancellationToken.None))
            .ReturnsAsync(srcResponse).Verifiable();

            var service = new TransactionSearchService(mockEthereumService.Object, _mapper, _logger);

            var request = new TransactionSearchRequest
            {
                BlockNumber = 9148873,
                Address     = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa"
            };

            //Act
            var response = await service.ExecuteAsync(request, CancellationToken.None);

            //Assert
            Assert.NotNull(response);
            var transactions = response.Transactions.ToList();

            Assert.Equal(2, transactions.Count);
            mockEthereumService.VerifyAll();
        }
 private TransactionSummary GetTransaction(AccountCredentials credentials, string referenceCode) => TransactionSearchService.SearchByReference(credentials, referenceCode)?.Items?.FirstOrDefault();