Beispiel #1
0
        public T GetPaymentHistory(string id)
        {
            var request = new TransactionSearchRequest().Id.Is(id);
            ResourceCollection <Transaction> collection = _gateway.Transaction.Search(request);

            return((T)collection.FirstItem);
        }
Beispiel #2
0
        public async Task CancelAndRecoverChargesAsync(ISubscriber subscriber)
        {
            if(!string.IsNullOrWhiteSpace(subscriber.GatewaySubscriptionId))
            {
                await _gateway.Subscription.CancelAsync(subscriber.GatewaySubscriptionId);
            }

            if(string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
            {
                return;
            }

            var transactionRequest = new TransactionSearchRequest().CustomerId.Is(subscriber.GatewayCustomerId);
            var transactions = _gateway.Transaction.Search(transactionRequest);

            if((transactions?.MaximumCount ?? 0) > 0)
            {
                foreach(var transaction in transactions.Cast<Transaction>().Where(c => c.RefundedTransactionId == null))
                {
                    await _gateway.Transaction.RefundAsync(transaction.Id);
                }
            }

            await _gateway.Customer.DeleteAsync(subscriber.GatewayCustomerId);
        }
Beispiel #3
0
        public async Task Init()
        {
            var UserID = SignedInUser.User.UserID;
            var req    = new TransactionSearchRequest
            {
                UserID = UserID,
                From   = _from,
                To     = _to
            };

            TransactionList.Clear();
            var list = await transactionService.Get <List <MTransaction> >(req);

            var user = await userService.GetById <MUser>(UserID);

            if (list.Count() != 0)
            {
                foreach (var x in list)
                {
                    var course = await courseService.GetById <MCourse>(x.CourseID);

                    if (x.UserID == user.UserID)
                    {
                        x.CourseName            = course.Name;
                        x.TransactionDateString = x.TransactionDate.ToString("dd/MM/yyyy");
                        TransactionList.Add(x);
                    }
                }
            }
        }
        public void Transaction_Reporting_And_Management_Search_Transaction_Request_Returns_Successfully()
        {
            var paymentsController = new PaymentsControllerTests();
            int transactionId      = paymentsController.Credit_Card_Present_AuthorizationOnly_Request_Returns_Successfully();
            // Arramge
            var request = new TransactionSearchRequest
            {
                TransactionId        = transactionId,
                StartDate            = DateTime.UtcNow.AddDays(-1),
                EndDate              = DateTime.UtcNow.AddDays(1),
                Amount               = 11.00m,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version     = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest <TransactionSearchResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
Beispiel #5
0
        public void Search_Search_GetTran()
        {
            //arrange
            TransactionSearchRequest tran = new TransactionSearchRequest();

            tran.acquirerRefNumber = "05436847276000293995738";
            tran.primaryAccountNum = "5488888888887192";
            tran.transAmountFrom   = "10000";
            tran.transAmountTo     = "20050";
            tran.tranStartDate     = "2017-10-01";
            tran.tranEndDate       = "2017-10-01";

            apiController.Setup(f => f.Create <TransactionSearchResponse>(It.IsAny <long>(), It.IsAny <String>(), tran))
            .Returns(new TransactionSearchResponse()
            {
                authorizationSummaryCount = "1"
            });

            //act
            Transactions transaction = new Transactions(apiController.Object);
            var          result      = transaction.Search(0, tran);

            //assert
            Assert.That(result.authorizationSummaryCount, Is.EqualTo("1"));
            Assert.That(result, Is.TypeOf <TransactionSearchResponse>());
        }
Beispiel #6
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 #7
0
        /// <summary>
        /// Transaction id bulunur
        /// </summary>
        /// <param name="mscMcomPool"></param>
        /// <returns></returns>
        private MscMcomTransaction GetMscMcomTransactionId(MscMcomPool mscMcomPool)
        {
            MscMcomTransaction mscMcomTransactionId = _iTransactionData.GetTransactionId(mscMcomPool.ProvisionRefKey);

            if (mscMcomTransactionId == null)
            {
                //presenment kaydı alınır
                var presentmentData = _iTransactionData.GetIssuerData(mscMcomPool);
                //transaction search yapılarak transaction id bulunur.
                TransactionSearchRequest transactionSearchRequest = new TransactionSearchRequest();
                transactionSearchRequest.primaryAccountNum = presentmentData.F002;
                transactionSearchRequest.acquirerRefNumber = presentmentData.Arn;
                transactionSearchRequest.tranStartDate     = presentmentData.TxnDate.AddDays(-2).ToString("yyyy-MM-dd");
                transactionSearchRequest.tranEndDate       = presentmentData.TxnDate.ToString("yyyy-MM-dd");
                var transactionSearchResponse = _iTransactions.Search(mscMcomPool.ClearingRefKey, transactionSearchRequest);
                if (Convert.ToInt16(transactionSearchResponse.authorizationSummaryCount) > 0)
                {
                    mscMcomTransactionId = new MscMcomTransaction();
                    mscMcomTransactionId.ClearingTransactionId       = transactionSearchResponse.authorizationSummary[0].clearingSummary[0].transactionId;
                    mscMcomTransactionId.AuthenticationTransactionId = transactionSearchResponse.authorizationSummary[0].transactionId;
                    mscMcomTransactionId.ClrRefKey  = mscMcomPool.ClearingRefKey;
                    mscMcomTransactionId.AuthRefKey = mscMcomPool.ProvisionRefKey;
                    _iTransactionData.CreateTransactionId(mscMcomTransactionId);
                }
            }
            return(mscMcomTransactionId);
        }
        public void Transaction_Reporting_And_Management_Search_Transaction_Request_Returns_Successfully()
        {
            // Arramge
            var request = new TransactionSearchRequest
            {
                TransactionId        = 111995104,
                CustomerId           = "5000587",
                StartDate            = Convert.ToDateTime("02/01/2016"),
                EndDate              = Convert.ToDateTime("05/31/2017"),
                Amount               = 11.00m,
                DeveloperApplication = new DeveloperApplication
                {
                    DeveloperId = 12345678,
                    Version     = "1.2"
                }
            };

            var apiContext = new APIContext();
            var controller = new TransactionsController();

            // Act
            var response = controller.ProcessRequest <TransactionSearchResponse>(apiContext, request);

            // Assert
            Assert.IsNotNull(response);
            Assert.IsTrue(response.Success);
        }
Beispiel #9
0
        private async Task LoadList(TransactionSearchRequest request)
        {
            var result = await TransactionService.Get <List <MTransaction> >(request);

            dgvTransactions.AutoGenerateColumns = false;
            dgvTransactions.ReadOnly            = true;
            dgvTransactions.DataSource          = result;
        }
Beispiel #10
0
        public async Task <IActionResult> SearchTransactionsAsync([FromQuery] TransactionSearchRequest request, CancellationToken token)
        {
            HttpContext.Items.TryGetValue("CorrelationId", out var correlationId);

            _logger.LogInformation($"Search request for CorrelationId : {correlationId} Address: {request.Address} BlockNumber: {request.BlockNumber}");

            var response = await _transactionSearchService.ExecuteAsync(request, token);

            return(Ok(response));
        }
Beispiel #11
0
        public async Task WhenServiceReturnsValidResponseThenOkResponseIsReturned()
        {
            //Arrange
            var transactionSearchRequest = new TransactionSearchRequest
            {
                BlockNumber = 9148873,
                Address     = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa"
            };

            _mockTransactionSearchService.Setup(m => m.ExecuteAsync(It.IsAny <TransactionSearchRequest>(), CancellationToken.None))
            .ReturnsAsync(new TransactionSearchResponse
            {
                Transactions = new List <Transaction>
                {
                    new Transaction
                    {
                        BlockHash   = "0x6dbde4b224013c46537231c548bd6ff8e2a2c927c435993d351866d505c523f1",
                        BlockNumber = 9148873,
                        From        = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa",
                        Gas         = 0.000000000000021M,
                        Hash        = "0x1fd509bc8a1f26351400f4ca206dbe7b8ebb8dcf3925ddf7201e8764e1bd3ea3",
                        To          = "0x59422595656a6b7c8917625607934d0e11fa0c40",
                        Value       = 80M
                    },
                    new Transaction
                    {
                        BlockHash   = "0x6dbde4b224013c46537231c548bd6ff8e2a2c927c435993d351866d505c523f1",
                        BlockNumber = 9148873,
                        From        = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa",
                        Gas         = 0.000000000000021M,
                        Hash        = "0xfcbbca93ff416601e5be95838fcfa2c534c48027b10172c12bf069784a4ec634",
                        To          = "0x15776a03ef5fdf2a54a1b3a991c1641d0bfa39e7",
                        Value       = 17.4M
                    }
                }
            })
            .Verifiable();

            var service = new TransactionsController(_mockTransactionSearchService.Object, _logger);

            //Act
            var response = await service.SearchTransactionsAsync(transactionSearchRequest, CancellationToken.None) as OkObjectResult;

            var responseObject = response.Value as TransactionSearchResponse;

            //Assert
            Assert.Equal(200, response.StatusCode);
            Assert.NotNull(responseObject);
            Assert.Equal(2, responseObject.Transactions.Count());
            _mockTransactionSearchService.VerifyAll();
        }
Beispiel #12
0
        public IList <Model.Transaction> GetAll(TransactionSearchRequest t)
        {
            var query = _context.Transaction.AsQueryable();

            if (t?.OfferId.HasValue == true)
            {
                query = query.Where(x => x.OfferId == t.OfferId);
            }

            var list = query.ToList();


            return(_mapper.Map <IList <Model.Transaction> >(list));
        }
Beispiel #13
0
        public async Task <ActionResult <TransactionSearchResponse> > Search([FromQuery] TransactionSearchRequest request)
        {
            request.EnsureValidation();
            TransactionSearchArgs   transactionSearchArgs = new TransactionSearchArgs();
            IMediator               mediator = Factory.Resolve <IMediator>();
            TransactionSearchResult transactionSearchResult = await mediator.Send(new TransactionSearchCommand(transactionSearchArgs));

            transactionSearchResult.EnsureSuccess();
            TransactionSearchResponse response = new TransactionSearchResponse
            {
                Transactions = transactionSearchResult.Results
                               .Select(x => { return(new TransactionLiteView(x)); })
                               .ToArray()
            };

            return(Ok(response));
        }
        public async Task WhenInvalidBlockNumberReturnsBadRequest()
        {
            var requestContent = new TransactionSearchRequest
            {
                Address = "0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7fa"
            };

            var request = new HttpRequestMessage
            {
                RequestUri = new Uri($"{_client.BaseAddress}api/transactions?blockNumber=0000000&address=0xc55eddadeeb47fcde0b3b6f25bd47d745ba7e7f"),
                Method     = HttpMethod.Get
            };

            var response = await _client.SendAsync(request);

            Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
        }
Beispiel #15
0
        public void Search_Search_GetTran()
        {
            //arrange
            TransactionSearchRequest tran = new TransactionSearchRequest();

            tran.acquirerRefNumber = "05436847276000293995738";
            tran.primaryAccountNum = "5488888888887192";
            tran.transAmountFrom   = "10000";
            tran.transAmountTo     = "20050";
            tran.tranStartDate     = "2017-10-01";
            tran.tranEndDate       = "2017-10-01";
            //act
            Transactions transaction = new Transactions(apiController);
            var          result      = transaction.Search(tran);

            //assert
            Assert.That(result.authorizationSummaryCount, Is.EqualTo("1"));
        }
Beispiel #16
0
        public async Task <BillingInfo> GetBillingAsync(ISubscriber subscriber)
        {
            var billingInfo = new BillingInfo();

            if (!string.IsNullOrWhiteSpace(subscriber.GatewayCustomerId))
            {
                var customer = await _gateway.Customer.FindAsync(subscriber.GatewayCustomerId);

                if (customer != null)
                {
                    if (customer.DefaultPaymentMethod != null)
                    {
                        billingInfo.PaymentSource = new BillingInfo.BillingSource(customer.DefaultPaymentMethod);
                    }

                    var transactionRequest = new TransactionSearchRequest().CustomerId.Is(customer.Id);
                    var transactions       = _gateway.Transaction.Search(transactionRequest);
                    billingInfo.Charges = transactions?.Cast <Transaction>().OrderByDescending(t => t.CreatedAt)
                                          .Select(t => new BillingInfo.BillingCharge(t));
                }
            }

            if (!string.IsNullOrWhiteSpace(subscriber.GatewaySubscriptionId))
            {
                var sub = await _gateway.Subscription.FindAsync(subscriber.GatewaySubscriptionId);

                if (sub != null)
                {
                    var plans = await _gateway.Plan.AllAsync();

                    var plan = plans?.FirstOrDefault(p => p.Id == sub.PlanId);
                    billingInfo.Subscription = new BillingInfo.BillingSubscription(sub, plan);
                }

                if (!billingInfo.Subscription.Cancelled && !billingInfo.Subscription.CancelAtEndDate &&
                    sub.NextBillingDate.HasValue)
                {
                    billingInfo.UpcomingInvoice = new BillingInfo.BillingInvoice(sub);
                }
            }

            return(billingInfo);
        }
Beispiel #17
0
        private async void cbCourses_SelectedIndexChanged(object sender, EventArgs e)
        {
            MCourse course;

            course = cbCourses.SelectedItem as MCourse;
            var courseID = course.CourseID;

            if (course.Name == "All courses")
            {
                await LoadList(null);
            }
            else
            {
                var request = new TransactionSearchRequest()
                {
                    CourseID = courseID
                };
                await LoadList(request);
            }
        }
Beispiel #18
0
        private async void cbUsers_SelectedIndexChanged(object sender, EventArgs e)
        {
            MUser user;

            user = cbUsers.SelectedItem as MUser;
            var userID = user.UserID;

            if (user.FullName == "All users")
            {
                await LoadList(null);
            }
            else
            {
                var request = new TransactionSearchRequest()
                {
                    UserID = userID
                };
                await LoadList(request);
            }
        }
        public void SearchForTransaction()
        {
            string             nonce   = Braintree.Test.Nonce.VisaCheckoutDiscover;
            TransactionRequest request = new TransactionRequest
            {
                Amount             = 1000M,
                PaymentMethodNonce = nonce
            };
            var transactionResult = gateway.Transaction.Sale(request);

            Assert.IsTrue(transactionResult.IsSuccess());

            var searchRequest = new TransactionSearchRequest().
                                Id.Is(transactionResult.Target.Id).
                                PaymentInstrumentType.Is("visa_checkout_card");

            var searchResult = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(1, searchResult.MaximumCount);
            Assert.AreEqual(searchResult.FirstItem.Id, transactionResult.Target.Id);
        }
        public async Task <TransactionSearchResponse> ExecuteAsync(TransactionSearchRequest request, CancellationToken token)
        {
            _logger.LogInformation($"Searching transactions for address {request.Address} in block {request.BlockNumber}");

            var getBlockByNumberRequest = _mapper.Map <ThirdPartyServices.Dtos.Infura.GetBlockByNumberRequest>(request);

            var getBlockByNumberResponse = await _ethereumService.GetBlockByNumberAsync(getBlockByNumberRequest, token);

            var ethereumTransactions = getBlockByNumberResponse.Result.Transactions.Where(x =>
                                                                                          x.From.Equals(request.Address, StringComparison.OrdinalIgnoreCase) ||
                                                                                          x.To.Equals(request.Address, StringComparison.OrdinalIgnoreCase));

            _logger.LogInformation($"Found {ethereumTransactions.Count()} for {request.Address} in block {request.BlockNumber}");

            var transactions = _mapper.Map <IEnumerable <Transaction> >(ethereumTransactions);

            _logger.LogInformation($"Search results mapped successfully");

            return(new TransactionSearchResponse {
                Transactions = transactions ?? new List <Transaction>()
            });
        }
Beispiel #21
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();
        }
        public void Search_OnSource()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Source.Is(TransactionSource.API);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Source.IncludedIn(TransactionSource.API, TransactionSource.CONTROL_PANEL);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Source.Is(TransactionSource.CONTROL_PANEL);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnPayPalFields()
        {
            var request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                PaymentMethodNonce = Nonce.PayPalOneTimePayment
            };
            var transactionResult = gateway.Transaction.Sale(request);
            Assert.IsTrue(transactionResult.IsSuccess());

            var searchRequest = new TransactionSearchRequest().
                Id.Is(transactionResult.Target.Id).
                PayPalPaymentId.StartsWith("PAY").
                PayPalAuthorizationId.StartsWith("SALE").
                PayPalPayerEmail.Is("*****@*****.**");

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnTextNodeOperators() {
            var request = new TransactionRequest
            {
                Amount = 1000M,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = "4111111111111111",
                    ExpirationDate = "05/2012",
                    CardholderName = "Tom Smith"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            var searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardholderName.StartsWith("Tom");

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);
            Assert.AreEqual(1, collection.MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardholderName.EndsWith("Smith");

            collection = gateway.Transaction.Search(searchRequest);
            Assert.AreEqual(1, collection.MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardholderName.Contains("m Sm");

            collection = gateway.Transaction.Search(searchRequest);
            Assert.AreEqual(1, collection.MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardholderName.IsNot("Tom Smith");

            collection = gateway.Transaction.Search(searchRequest);
            Assert.AreEqual(0, collection.MaximumCount);
        }
        public void Search_PaymentInstrumentTypeIsPayPal()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                PaymentMethodNonce = Nonce.PayPalOneTimePayment
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                PaymentInstrumentType.Is("PayPalDetail");

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(collection.FirstItem.PaymentInstrumentType, PaymentInstrumentType.PAYPAL_ACCOUNT);
        }
        public void Search_PaymentInstrumentTypeIsEuropeBankAccount()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                PaymentMethodNonce = Nonce.Transactable
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                PaymentInstrumentType.Is("EuropeBankAccountDetail");

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(0, collection.MaximumCount);
        }
        public void Search_OnStatus()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Status.Is(TransactionStatus.AUTHORIZED);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Status.IncludedIn(TransactionStatus.AUTHORIZED, TransactionStatus.GATEWAY_REJECTED);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Status.Is(TransactionStatus.GATEWAY_REJECTED);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnAllTextFields()
        {
            string creditCardToken = string.Format("cc{0}", new Random().Next(1000000).ToString());
            string firstName = string.Format("Tim{0}", new Random().Next(1000000).ToString());

            TransactionRequest request = new TransactionRequest
            {
                Amount = 1000M,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = "4111111111111111",
                    ExpirationDate = "05/2012",
                    CardholderName = "Tom Smith",
                    Token = creditCardToken
                },
                BillingAddress = new AddressRequest
                {
                    Company = "Braintree",
                    CountryName = "United States of America",
                    ExtendedAddress = "Suite 123",
                    FirstName = firstName,
                    LastName = "Smith",
                    Locality = "Chicago",
                    PostalCode = "12345",
                    Region = "IL",
                    StreetAddress = "123 Main St"
                },
                Customer = new CustomerRequest
                {
                    Company = "Braintree",
                    Email = "*****@*****.**",
                    Fax = "5551231234",
                    FirstName = "Tom",
                    LastName = "Smith",
                    Phone = "5551231234",
                    Website = "http://example.com"
                },
                Options = new TransactionOptionsRequest
                {
                    StoreInVault = true,
                    SubmitForSettlement = true
                },
                OrderId = "myorder",
                ShippingAddress = new AddressRequest
                {
                    Company = "Braintree P.S.",
                    CountryName = "Mexico",
                    ExtendedAddress = "Apt 456",
                    FirstName = "Thomas",
                    LastName = "Smithy",
                    Locality = "Braintree",
                    PostalCode = "54321",
                    Region = "MA",
                    StreetAddress = "456 Road"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;
            gateway.TestTransaction.Settle(transaction.Id);
            transaction = gateway.Transaction.Find(transaction.Id);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                BillingCompany.Is("Braintree").
                BillingCountryName.Is("United States of America").
                BillingExtendedAddress.Is("Suite 123").
                BillingFirstName.Is(firstName).
                BillingLastName.Is("Smith").
                BillingLocality.Is("Chicago").
                BillingPostalCode.Is("12345").
                BillingRegion.Is("IL").
                BillingStreetAddress.Is("123 Main St").
                CreditCardCardholderName.Is("Tom Smith").
                CreditCardExpirationDate.Is("05/2012").
                CreditCardNumber.Is(SandboxValues.CreditCardNumber.VISA).
                Currency.Is("USD").
                CustomerCompany.Is("Braintree").
                CustomerEmail.Is("*****@*****.**").
                CustomerFax.Is("5551231234").
                CustomerFirstName.Is("Tom").
                CustomerId.Is(transaction.Customer.Id).
                CustomerLastName.Is("Smith").
                CustomerPhone.Is("5551231234").
                CustomerWebsite.Is("http://example.com").
                OrderId.Is("myorder").
                PaymentMethodToken.Is(creditCardToken).
                ProcessorAuthorizationCode.Is(transaction.ProcessorAuthorizationCode).
                SettlementBatchId.Is(transaction.SettlementBatchId).
                ShippingCompany.Is("Braintree P.S.").
                ShippingCountryName.Is("Mexico").
                ShippingExtendedAddress.Is("Apt 456").
                ShippingFirstName.Is("Thomas").
                ShippingLastName.Is("Smithy").
                ShippingLocality.Is("Braintree").
                ShippingPostalCode.Is("54321").
                ShippingRegion.Is("MA").
                ShippingStreetAddress.Is("456 Road").
                User.Is("integration_user_public_id").
                CreditCardUniqueIdentifier.Is(transaction.CreditCard.UniqueNumberIdentifier);

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(1, collection.MaximumCount);
            Assert.AreEqual(transaction.Id, collection.FirstItem.Id);
        }
        public void Search_OnDisputeDate()
        {
            DateTime disputeDate = DateTime.Parse("2014-03-01");
            DateTime threeDaysEarlier = disputeDate.AddDays(-3);
            DateTime oneDayEarlier = disputeDate.AddDays(-1);
            DateTime oneDayLater = disputeDate.AddDays(1);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is("disputedtransaction").
                DisputeDate.Between(oneDayEarlier, oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is("2disputetransaction").
                DisputeDate.GreaterThanOrEqualTo(oneDayEarlier);

            Assert.AreEqual(2, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is("disputedtransaction").
                DisputeDate.LessThanOrEqualTo(oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is("disputedtransaction").
                DisputeDate.Between(threeDaysEarlier, oneDayEarlier);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnCreatedAtUsingLocalTime()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
            DateTime oneDayLater = DateTime.Now.AddDays(1);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreatedAt.Between(oneDayEarlier, oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnAmount()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = 1000M,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Amount.Between(500M, 1500M);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Amount.GreaterThanOrEqualTo(500M);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Amount.LessThanOrEqualTo(1500M);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                Amount.Between(500M, 900M);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnTransactionType()
        {
            string name = new Random().Next(1000000).ToString();
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010",
                    CardholderName = name
                },
                Options = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Transaction creditTransaction = gateway.Transaction.Credit(request).Target;

            Transaction saleTransaction = gateway.Transaction.Sale(request).Target;

            gateway.TestTransaction.Settle(saleTransaction.Id);
            Transaction refundTransaction = gateway.Transaction.Refund(saleTransaction.Id).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                CreditCardCardholderName.Is(name).
                Type.Is(TransactionType.CREDIT);

            Assert.AreEqual(2, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                CreditCardCardholderName.Is(name).
                Type.Is(TransactionType.CREDIT).
                Refund.Is(true);

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(1, collection.MaximumCount);
            Assert.AreEqual(refundTransaction.Id, collection.FirstItem.Id);

            searchRequest = new TransactionSearchRequest().
                CreditCardCardholderName.Is(name).
                Type.Is(TransactionType.CREDIT).
                Refund.Is(false);

            collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(1, collection.MaximumCount);
            Assert.AreEqual(creditTransaction.Id, collection.FirstItem.Id);
        }
        public void Search_OnCreatedUsing()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreatedUsing.Is(TransactionCreatedUsing.FULL_INFORMATION);

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(1, collection.MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreatedUsing.IncludedIn(TransactionCreatedUsing.FULL_INFORMATION, TransactionCreatedUsing.TOKEN);

            collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(1, collection.MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreatedUsing.Is(TransactionCreatedUsing.TOKEN);

            collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(0, collection.MaximumCount);
        }
Beispiel #34
0
        /// <inheritdoc />
        /// <summary>
        /// Gets the transactions.
        /// </summary>
        /// <param name="model">The model.</param>
        /// <returns></returns>
        public ResourceCollection <Transaction> GetTransactions(PaymentSettingsModel model)
        {
            TransactionSearchRequest request = new TransactionSearchRequest();

            return(GetGateway(model).Transaction.Search(request));
        }
        public void Search_OnCreditCardType()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardType.Is(CreditCardCardType.VISA);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardType.Is(transaction.CreditCard.CardType);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardType.IncludedIn(CreditCardCardType.VISA, CreditCardCardType.MASTER_CARD);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCardType.Is(CreditCardCardType.MASTER_CARD);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_PaymentInstrumentTypeIsApplePay()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                PaymentMethodNonce = Nonce.ApplePayVisa
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                PaymentInstrumentType.Is("ApplePayDetail");

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(collection.FirstItem.PaymentInstrumentType, PaymentInstrumentType.APPLE_PAY_CARD);
        }
        public void Search_OnSettledAt()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                },
                Options = new TransactionOptionsRequest
                {
                    SubmitForSettlement = true
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;
            gateway.TestTransaction.Settle(transaction.Id);
            transaction = gateway.Transaction.Find(transaction.Id);

            DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
            DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
            DateTime oneDayLater = DateTime.Now.AddDays(1);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                SettledAt.Between(oneDayEarlier, oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                SettledAt.GreaterThanOrEqualTo(oneDayEarlier);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                SettledAt.LessThanOrEqualTo(oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                SettledAt.Between(threeDaysEarlier, oneDayEarlier);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
Beispiel #38
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();
        }
        public void Search_OnMerchantAccountId()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                MerchantAccountId.Is(transaction.MerchantAccountId);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                MerchantAccountId.IncludedIn(transaction.MerchantAccountId, "badmerchantaccountid");

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                MerchantAccountId.Is("badmerchantaccountid");

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_PaymentInstrumentTypeIsCreditCard()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                PaymentInstrumentType.Is("CreditCardDetail");

            ResourceCollection<Transaction> collection = gateway.Transaction.Search(searchRequest);

            Assert.AreEqual(collection.FirstItem.PaymentInstrumentType,PaymentInstrumentType.CREDIT_CARD);
        }
Beispiel #41
0
        /// <summary>
        ///     Gather all revenue date during a month/year combination.
        /// </summary>
        /// <remarks>
        ///     Separate the incoming data string into the month and year component.
        ///     Check if any live event took place during the month in question.
        ///         If so, add their combined revenue to the data model.
        ///     Search the financial gateways for membership renewals payments.
        ///         Add any matches to the relevant gold, silver or bronze revenue totals in the model.
        ///     Search the database for any accepted private session requested that had been paid for.
        ///         Add any matches to the private fee count, and add the total revenue to the model.
        ///     Search for any class cancellation fines settled during the month in question.
        ///         Add the total of any fines to the viewmodel.
        ///     Instantiate the model and return it.
        /// </remarks>
        /// <param name="selectedData">A <see cref="string"/> containing a numeric month and year</param>
        /// <returns></returns>
        public RevenueReportModel GetRevenueData(string selectedData)
        {
            int year  = int.Parse(selectedData.Substring(0, 4));
            int month = int.Parse(selectedData.Substring(5, 2));
            RevenueReportModel model;

            //Create ViewModel
            //Add Data to Sending Model
            using (_db)
            {
                //Get Event Revenue
                var events = _db.LiveEvents
                             .Where(e => e.EventDate.Month == month && e.EventDate.Year == year)
                             .ToList();

                float eventRevenueTotal = 0;
                foreach (var show in events)
                {
                    eventRevenueTotal = eventRevenueTotal + show.EventRevenue;
                }

                //Get Membership Revenue
                DateTime startDate = new DateTime(year, month, 1);
                DateTime endDate   = new DateTime(year, month, DateTime.DaysInMonth(year, month));

                var bronzeRequest = new TransactionSearchRequest().SettledAt.Between(startDate, endDate).Amount.Is(40);
                var silverRequest = new TransactionSearchRequest().SettledAt.Between(startDate, endDate).Amount.Is(55);
                var goldRequest   = new TransactionSearchRequest().SettledAt.Between(startDate, endDate).Amount.Is(70);

                ResourceCollection <Transaction> bResults = PaymentGateways.Gateway.Transaction.Search(bronzeRequest);
                var bFeesCollected = bResults.Ids.Count;
                var bTotal         = bFeesCollected * 40;
                ResourceCollection <Transaction> sResults = PaymentGateways.Gateway.Transaction.Search(silverRequest);
                var sFeesCollected = sResults.Ids.Count;
                var sTotal         = sFeesCollected * 55;
                ResourceCollection <Transaction> gResults = PaymentGateways.Gateway.Transaction.Search(goldRequest);
                var gFeesCollected = gResults.Ids.Count;
                var gTotal         = gFeesCollected * 70;

                //Get Private Session Revenue
                var pFeesCollected = 0;
                foreach (var payment in _db.Payments.Where(p => p.PaymentDate.Month == month && p.PaymentDate.Year == year).ToList())
                {
                    if (payment.PaymentDescription.Equals("Private Session Booking Fee") && payment.PaymentSettled)
                    {
                        pFeesCollected++;
                    }
                }
                var privateTotal = pFeesCollected * 30;

                //Get Fine Revenue
                var fineRequest = new TransactionSearchRequest().SettledAt.Between(startDate, endDate).Amount.Is(30).Refund.Is(1.5);
                ResourceCollection <Transaction> fineResults = PaymentGateways.Gateway.Transaction.Search(fineRequest);
                var    finesCollected = fineResults.Ids.Count;
                double fineTotal      = finesCollected * 1.5;

                model = new RevenueReportModel
                {
                    BronzeFeesCollected = bTotal,
                    CurrentDate         = new DateTime(year, month, 1),
                    Events                 = events.ToList(),
                    FinesCollected         = fineTotal,
                    GoldFeesCollected      = gTotal,
                    NoBronzeMemberships    = bFeesCollected,
                    NoCancellationFines    = finesCollected,
                    NoGoldMemberships      = gFeesCollected,
                    NoPrivateSessions      = pFeesCollected,
                    NoSilverMemberships    = sFeesCollected,
                    PrivateFeesCollected   = privateTotal,
                    SilverFeesCollected    = sTotal,
                    TotalEventRevenue      = eventRevenueTotal,
                    TotalMembershipRevenue = bTotal + sTotal + gTotal,
                    TotalOtherRevenue      = privateTotal + fineTotal,
                    TotalMonthRevenue      = eventRevenueTotal + bTotal + sTotal + gTotal + privateTotal + fineTotal
                };
            }
            return(model);
        }
Beispiel #42
0
 public IList <Model.Transaction> GetAll([FromQuery] TransactionSearchRequest request)
 {
     return(_service.GetAll(request));
 }
        public void Search_OnCreditCardCustomerLocation()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Target;

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCustomerLocation.Is(CreditCardCustomerLocation.US);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCustomerLocation.IncludedIn(CreditCardCustomerLocation.US, CreditCardCustomerLocation.INTERNATIONAL);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                CreditCardCustomerLocation.Is(CreditCardCustomerLocation.INTERNATIONAL);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
 public void Search_ReturnsErrorOnTimeout()
 {
   TransactionSearchRequest searchRequest = new TransactionSearchRequest().
       Amount.Is(-5);
   gateway.Transaction.Search(searchRequest);
 }
Beispiel #45
0
        public JsonResult AjaxHandler([ModelBinder(typeof(TransactionSearchDataTablesBinder))] TransactionSearchRequest param, int acctId)
        //public JsonResult AjaxHandler([ModelBinder(typeof(DataTablesBinder))] IDataTablesRequest param, int acctId, DateTime fDate, DateTime tDate, decimal fAmount, decimal tAmount)
        {
            IQueryable <Transaction> filteredTransactions = db.Transactions.AsQueryable();

            var      user        = db.Users.Single(u => u.UserName == User.Identity.Name);
            var      userId      = User.Identity.GetUserId();
            DateTime defaultDate = DateTime.MinValue;

            param.eDate          = param.eDate == DateTime.MinValue ? DateTime.MaxValue : param.eDate;
            filteredTransactions = filteredTransactions.Where(t => t.AccountId == acctId);

            // if date ranges were entered
            if (param.sDate != defaultDate || param.eDate != defaultDate)
            {
                filteredTransactions = filteredTransactions
                                       .Where(t => t.Date >= param.sDate.Value && t.Date <= param.eDate.Value);
            }

            // if amount ranges were entered
            if (param.sAmt != 0)
            {
                filteredTransactions = filteredTransactions
                                       .Where(t => t.Amount >= param.sAmt && t.Amount <= param.eAmt);
            }


            var search = param.Search.Value;

            if (!string.IsNullOrEmpty(search))
            {
                filteredTransactions = filteredTransactions
                                       .Where(t => t.Description.Contains(search) ||
                                              t.Category.Name.Contains(search) ||
                                              t.UpdateByUser.Name.Contains(search)
                                              );
            }

            var column = param.Columns.FirstOrDefault(r => r.IsOrdered == true);

            if (column != null)
            {
                if (column.SortDirection == Column.OrderDirection.Descendant)
                {
                    switch (column.Data)
                    {
                    case "Date": filteredTransactions = filteredTransactions.OrderByDescending(t => t.Date);
                        break;

                    case "Description": filteredTransactions = filteredTransactions.OrderByDescending(t => t.Description);
                        break;

                    case "Category": filteredTransactions = filteredTransactions.OrderByDescending(t => t.Category.Name);
                        break;

                    case "Amount": filteredTransactions = filteredTransactions.OrderByDescending(t => t.Amount);
                        break;

                    case "Reconciled": filteredTransactions = filteredTransactions.OrderByDescending(t => t.Reconciled);
                        break;

                    case "UpdateBy": filteredTransactions = filteredTransactions.OrderByDescending(t => t.UpdateByUser.Name);
                        break;
                    }
                }
                else
                {
                    switch (column.Data)
                    {
                    case "Date": filteredTransactions = filteredTransactions.OrderBy(t => t.Date);
                        break;

                    case "Description": filteredTransactions = filteredTransactions.OrderBy(t => t.Description);
                        break;

                    case "Category": filteredTransactions = filteredTransactions.OrderBy(t => t.Category.Name);
                        break;

                    case "Amount": filteredTransactions = filteredTransactions.OrderBy(t => t.Amount);
                        break;

                    case "Reconciled": filteredTransactions = filteredTransactions.OrderBy(t => t.Reconciled);
                        break;

                    case "UpdateBy": filteredTransactions = filteredTransactions.OrderBy(t => t.UpdateByUser.Name);
                        break;
                    }
                }
            }
            var urlHelper = new UrlHelper(Request.RequestContext);
            var result    = filteredTransactions.Skip(param.Start).Take(param.Length).ToList().Select(t => new TransactionViewModel()
            {
                Date        = t.Date.Date.ToString("d"),
                Description = "<a href=\"" + urlHelper.RouteUrl("TransactionEdit", new { acctId = acctId, id = t.Id }) + "\">" + t.Description + "</a>",
                Amount      = t.Amount,
                Category    = t.Category.Name,
                Reconciled  = t.Reconciled == true ? "Yes" : "No",
                UpdateBy    = t.UpdateByUser != null ? t.UpdateByUser.Name : ""
                              //Delete = "<a href=\"" + urlHelper.RouteUrl("TransactionDelete", new { id = t.Id }) + "\">" + "Delete" + "</a>"
            });

            return(Json(new DataTablesResponse(param.Draw, result, filteredTransactions.Count(), db.Transactions.Count()), JsonRequestBehavior.AllowGet));
        }
        public void Search_OnProcessorDeclinedAt()
        {
            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.DECLINE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010"
                }
            };

            Transaction transaction = gateway.Transaction.Sale(request).Transaction;

            DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
            DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
            DateTime oneDayLater = DateTime.Now.AddDays(1);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                ProcessorDeclinedAt.Between(oneDayEarlier, oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                ProcessorDeclinedAt.GreaterThanOrEqualTo(oneDayEarlier);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                ProcessorDeclinedAt.LessThanOrEqualTo(oneDayLater);

            Assert.AreEqual(1, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                ProcessorDeclinedAt.Between(threeDaysEarlier, oneDayEarlier);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);
        }
        public void Search_OnAuthorizationExpiredStatus()
        {
            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Status.Is(TransactionStatus.AUTHORIZATION_EXPIRED);

            ResourceCollection<Transaction> results = gateway.Transaction.Search(searchRequest);

            Assert.IsTrue(results.MaximumCount > 0);
            Assert.AreEqual(TransactionStatus.AUTHORIZATION_EXPIRED, results.FirstItem.Status);
        }
        public void Search_OnAuthorizationExpiredAt()
        {
            DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
            DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
            DateTime oneDayLater = DateTime.Now.AddDays(1);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                AuthorizationExpiredAt.Between(threeDaysEarlier, oneDayEarlier);

            Assert.AreEqual(0, gateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                AuthorizationExpiredAt.Between(oneDayEarlier, oneDayLater);

            var results = gateway.Transaction.Search(searchRequest);
            Assert.IsTrue(results.MaximumCount > 0);
            Assert.AreEqual(TransactionStatus.AUTHORIZATION_EXPIRED, results.FirstItem.Status);
        }
 public void Search_ReturnsErrorOnTimeout()
 {
     TransactionSearchRequest searchRequest = new TransactionSearchRequest().
         Amount.Is(-5);
     Assert.Throws<DownForMaintenanceException>(() => gateway.Transaction.Search(searchRequest));
 }
Beispiel #50
0
 /// <summary>
 ///
 /// </summary>
 public TransactionSearchResponse Search(long refKey, TransactionSearchRequest transactionSearchRequest)
 {
     return(_apiController.Create <TransactionSearchResponse>(refKey, "transactions/search", transactionSearchRequest));
 }
        public void Search_OnGatewayRejectedAt()
        {
            BraintreeGateway processingRulesGateway = new BraintreeGateway
            {
                Environment = Environment.DEVELOPMENT,
                MerchantId = "processing_rules_merchant_id",
                PublicKey = "processing_rules_public_key",
                PrivateKey = "processing_rules_private_key"
            };

            TransactionRequest request = new TransactionRequest
            {
                Amount = SandboxValues.TransactionAmount.AUTHORIZE,
                CreditCard = new TransactionCreditCardRequest
                {
                    Number = SandboxValues.CreditCardNumber.VISA,
                    ExpirationDate = "05/2010",
                    CVV = "200"
                }
            };

            Transaction transaction = processingRulesGateway.Transaction.Sale(request).Transaction;

            DateTime threeDaysEarlier = DateTime.Now.AddDays(-3);
            DateTime oneDayEarlier = DateTime.Now.AddDays(-1);
            DateTime oneDayLater = DateTime.Now.AddDays(1);

            TransactionSearchRequest searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                GatewayRejectedAt.Between(oneDayEarlier, oneDayLater);

            Assert.AreEqual(1, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                GatewayRejectedAt.GreaterThanOrEqualTo(oneDayEarlier);

            Assert.AreEqual(1, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                GatewayRejectedAt.LessThanOrEqualTo(oneDayLater);

            Assert.AreEqual(1, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);

            searchRequest = new TransactionSearchRequest().
                Id.Is(transaction.Id).
                GatewayRejectedAt.Between(threeDaysEarlier, oneDayEarlier);

            Assert.AreEqual(0, processingRulesGateway.Transaction.Search(searchRequest).MaximumCount);
        }