public void ListFilteredOrders_WithFilterAndOrdering()
        {
            IQueryOrders           queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>();
            CompletedOrderResponse first          = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(200);
            CompletedOrderResponse second         = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(300);

            var orders = queryInterface.ListFilteredOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                           LevelUpTestConfiguration.Current.MerchantLocationId, 1, 1,
                                                           (x => x.OrderIdentifier == first.OrderIdentifier || x.OrderIdentifier == second.OrderIdentifier),
                                                           ((x, y) => y.Total - x.Total));

            Assert.AreEqual(orders.Count, 2);
            Assert.IsTrue(orders[0].OrderIdentifier == second.OrderIdentifier);
            Assert.IsTrue(orders[1].OrderIdentifier == first.OrderIdentifier);
        }
        public void ProposedOrderWithDiscountAndGiftCard_ShouldSucceed()
        {
            int availableDiscountCents = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerQrData);

            const int giftCardAmountToUseInCents = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(giftCardAmountToUseInCents);

            const int taxAmountInCents = 100;

            // Make sure that gift card, credit card, and discount(if available) will all be requried as part of this test payment.
            int costOfItemInCents = availableDiscountCents + giftCardAmountToUseInCents + taxAmountInCents + 500;

            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();
            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                costOfItemInCents,
                                                                costOfItemInCents,
                                                                taxAmountInCents,
                                                                0, null, null, null, null, true, null);

            Assert.AreEqual(proposedOrder.DiscountAmountCents, availableDiscountCents);
            int taxAmountAfterDiscountApplied = (taxAmountInCents * (costOfItemInCents - proposedOrder.DiscountAmountCents)) / costOfItemInCents;

            var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                   proposedOrder.ProposedOrderIdentifier,
                                                                   costOfItemInCents,
                                                                   costOfItemInCents,
                                                                   taxAmountAfterDiscountApplied,
                                                                   0,
                                                                   proposedOrder.DiscountAmountCents,
                                                                   null, null, null, null, true, null);

            Assert.AreEqual(completedOrder.GiftCardTipAmount, 0);
            Assert.AreEqual(completedOrder.GiftCardTotalAmount, giftCardAmountToUseInCents);
            Assert.AreEqual(completedOrder.GiftCardTipAmount, 0);
            Assert.AreEqual(completedOrder.TipAmount, 0);
            Assert.AreEqual(completedOrder.SpendAmount, costOfItemInCents);

            ICreateRefund refundClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>();

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                     completedOrder.OrderIdentifier);
        }
        internal static CompletedOrderResponse PlaceOrderAtTestMerchantWithTestConsumer(int total = 100)
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();

            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();
            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                total, total, 0, 0, null, null, null, null, true, null);

            return(orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                     LevelUpTestConfiguration.Current.MerchantLocationId,
                                                     LevelUpTestConfiguration.Current.ConsumerQrData,
                                                     proposedOrder.ProposedOrderIdentifier,
                                                     total, total, 0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, true, null));
        }
        public void CreateDetachedRefund()
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();

            const int refundAmountCents = 50;

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(refundAmountCents);

            ICreateDetachedRefund refundInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateDetachedRefund>();
            var refundData = new DetachedRefundRequestBody(LevelUpTestConfiguration.Current.MerchantLocationId,
                                                           LevelUpTestConfiguration.Current.ConsumerQrData,
                                                           refundAmountCents);
            var refund = refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData);

            Assert.AreEqual(refund.CreditAmountCents, refundAmountCents);
        }
        public void GetLoyalty()
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();

            ILookupUserLoyalty loyaltyClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>();
            var initialLoyalty = loyaltyClient.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                          LevelUpTestConfiguration.Current.MerchantId);

            Assert.AreEqual(initialLoyalty.MerchantId, LevelUpTestConfiguration.Current.MerchantId);

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer();

            var finalLoyalty = loyaltyClient.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                        LevelUpTestConfiguration.Current.MerchantId);

            Assert.AreEqual(finalLoyalty.OrdersCount, initialLoyalty.OrdersCount + 1);
        }
示例#6
0
        public void GetMerchantOrderDetails()
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();

            IQueryMerchantData queryClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryMerchantData>();

            var ordered = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(1000);

            var queriedOrderDetails = queryClient.GetMerchantOrderDetails(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantId,
                ordered.OrderIdentifier);

            Assert.AreEqual(queriedOrderDetails.OrderIdentifier, ordered.OrderIdentifier);
            Assert.AreEqual(queriedOrderDetails.SpendAmount, ordered.SpendAmount);
            Assert.AreEqual(queriedOrderDetails.TipAmount, ordered.TipAmount);
            Assert.AreEqual(queriedOrderDetails.Total, ordered.Total);
        }
        private List <OrderDetailsResponse> GetEveryOrderForTestMerchant()
        {
            IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>();

            var retval = new List <OrderDetailsResponse>();

            int  currentPage       = 1;
            bool areThereMorePages = true;

            while (areThereMorePages)
            {
                var orders = queryInterface.ListOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                       LevelUpTestConfiguration.Current.MerchantLocationId, currentPage, currentPage, out areThereMorePages);
                retval.AddRange(orders);
                currentPage++;
            }
            return(retval);
        }
示例#8
0
        public void UpdateUserShoudSucceed()
        {
            UpdateUserRequestBody request = new UpdateUserRequestBody(LevelUpTestConfiguration.Current.ConsumerId)
            {
                BornAt = DateTime.UtcNow.Date.AddYears(-25)
            };

            var client = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IModifyUser>();
            var user   = client.UpdateUser(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, request);

            Assert.IsNotNull(user);
            Assert.AreEqual(user.BornAt, request.BornAt);

            request.BornAt = DateTimeOffset.UtcNow.Date;
            user           = client.UpdateUser(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, request);

            Assert.IsNotNull(user);
            Assert.IsTrue(user.BornAt.HasValue);
            Assert.AreEqual(user.BornAt, request.BornAt);
        }
        [Ignore] // Braintree enforces a 50-cards-per-user restriction, so we can't keep adding/removing cards for the test user.
        public void CreateCreditCards()
        {
            ICreateCreditCards  createInterface  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateCreditCards>();
            IDestroyCreditCards destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyCreditCards>();
            IQueryCreditCards   queryInterface   = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryCreditCards>();

            CreditCard created = createInterface.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                  ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);

            List <CreditCard> creditCards = new List <CreditCard>(queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken));

            Assert.AreEqual(creditCards.FindAll(x => x.Id == created.Id).Count, 1);

            destroyInterface.DeleteCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, created.Id);

            creditCards = new List <CreditCard> (queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken));
            Assert.AreEqual(creditCards.FindAll(x => x.Id == created.Id).Count, 0);

            // Note: The card won't actually be deleted in the cleanup for this test, just deactivated.  AFAIK cards cannot be deleted via
            // the api, and they just languish in a deactivated state.  As a result, the sandbox merchant account that is used for integration
            // tests may wind up with a bunch of old credit card entries.
        }
示例#10
0
        [Ignore] // Braintree enforces a 50-cards-per-user restriction, so we can't keep adding/removing cards for the test user.
        public void DestroyCard()
        {
            IQueryCreditCards   queryClient   = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryCreditCards>();
            IDestroyCreditCards destroyClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyCreditCards>();
            ICreateCreditCards  createClient  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateCreditCards>();

            var toCreate = createClient.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                         ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);

            var cards = queryClient.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            Assert.AreEqual(cards.Count, 1);
            Assert.AreEqual(cards[0].Active, true);
            Assert.AreEqual(cards[0].Id, toCreate.Id);

            destroyClient.DeleteCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, toCreate.Id);

            cards = queryClient.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);
            Assert.AreEqual(cards.Count, 0);

            createClient.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                          ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);
        }
示例#11
0
        public void GetMerchantFundedGiftCardCredit()
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            IRetrieveMerchantFundedGiftCardCredit creditInterface =
                ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();

            var credit = creditInterface.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData);

            Assert.AreEqual(0, credit.TotalAmount);

            const int creditAmountCents = 1000;

            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(creditAmountCents);

            credit = creditInterface.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData);

            Assert.AreEqual(creditAmountCents, credit.TotalAmount);

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
        }
        [Ignore] // Braintree enforces a 50-cards-per-user restriction, so we can't keep adding/removing cards for the
                 // test user.  This test requires adding/removing cards.
        public void QueryCreditCards()
        {
            IQueryCreditCards   queryInterface   = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryCreditCards>();
            ICreateCreditCards  createInterface  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateCreditCards>();
            IDestroyCreditCards destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyCreditCards>();

            var existingCards = queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            foreach (var card in existingCards)
            {
                destroyInterface.DeleteCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, card.Id);
            }

            Assert.AreEqual(queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken).Count, 0);

            createInterface.CreateCreditCard(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                             ClientModuleIntegrationTestingUtilities.SandboxIntegrationTestCreditCard);

            var newCards = queryInterface.ListCreditCards(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            Assert.AreEqual(newCards.Count, 1);
            Assert.AreEqual(newCards[0].State.ToLower(), "active");
            Assert.AreEqual(newCards[0].Promoted, true);
        }
示例#13
0
        public void CreateRefundForNonExistantOrder()
        {
            ICreateRefund refundInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>();

            refundInterface.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, "aaa");
        }