private void AddThenDestroyGiftCardValue(int giftCardAmountToAdd, int giftCardAmountToDelete, string QrCode, string merchantToken)
        {
            IDestroyGiftCardValue destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyGiftCardValue>();

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(giftCardAmountToAdd);

            var destroyed = destroyInterface.GiftCardDestroyValue(merchantToken,
                                                                  LevelUpTestConfiguration.Current.MerchantId,
                                                                  QrCode,
                                                                  giftCardAmountToDelete);

            Assert.AreEqual(destroyed.AmountRemovedInCents, giftCardAmountToDelete);
            Assert.AreEqual(destroyed.PreviousGiftCardAmountInCents, giftCardAmountToAdd);
            Assert.AreEqual(destroyed.NewGiftCardAmountInCents, giftCardAmountToAdd - giftCardAmountToDelete);

            IRetrieveMerchantFundedGiftCardCredit queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();
            var loyalty = queryInterface.GetMerchantFundedGiftCardCredit(
                ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                LevelUpTestConfiguration.Current.MerchantLocationId,
                LevelUpTestConfiguration.Current.ConsumerQrData);

            Assert.AreEqual(loyalty.TotalAmount, giftCardAmountToAdd - giftCardAmountToDelete);

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();
        }
Exemple #2
0
        public void ProposedOrderWithNoPartialAuth_ShouldThrow_ForInsufficientCredit()
        {
            int giftCardAmount = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount(giftCardAmount);

            var discountCredit = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData);

            int spendAmount = (1000 + giftCardAmount + discountCredit);


            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                    LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                    LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                    spendAmount, spendAmount, 0, 0, null, null, null, null, false, false, null);

                var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                       LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                       LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                       proposedOrder.ProposedOrderIdentifier,
                                                                       spendAmount, spendAmount, 0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, false, false, null);
            });
        }
Exemple #3
0
        public void ProposedOrderWith10PercentTip_ShouldSucceed()
        {
            const int spendAmountCents = 10;
            const int tipAmountCents   = 1; // 10%

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

            var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerQrDataWith10PercentTip,
                                                                   proposedOrder.ProposedOrderIdentifier,
                                                                   spendAmountCents, spendAmountCents,
                                                                   0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, true, false, null);

            Assert.AreEqual(completedOrder.TipAmount, tipAmountCents);

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

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, completedOrder.OrderIdentifier);
        }
        public void CreateRefundForUnFinalizedProposedOrder()
        {
            int availableDiscountCents = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerQrData);

            const int giftCardAmountToUseInCents = 1000;

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

            const int taxAmountInCents  = 100;
            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, false, null);

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

            Assert.Throws <LevelUpApiException>(() =>
            {
                refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                         proposedOrder.ProposedOrderIdentifier);
            });
        }
Exemple #5
0
        public void ProposedOrderWithPartialAuth_ShouldSucceed()
        {
            int giftCardAmount = 1000;

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount();
            ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerWithNoLinkedPaymentUserAccount(giftCardAmount);

            var credit = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData);

            int spendAmount = (1000 + giftCardAmount + credit);


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

            Assert.AreEqual(proposedOrder.DiscountAmountCents, credit);

            var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                   proposedOrder.ProposedOrderIdentifier,
                                                                   spendAmount, spendAmount, 0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, true, false, null);

            Assert.AreEqual(completedOrder.SpendAmount, credit + giftCardAmount);
            Assert.AreNotEqual(completedOrder.SpendAmount, spendAmount);

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

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, completedOrder.OrderIdentifier);
        }
        public void CreateGiftCardValue()
        {
            const int valueToAdd = 1000;

            ICreateGiftCardValue  createInterface  = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>();
            ILookupUserLoyalty    loyaltyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>();
            IDestroyGiftCardValue destroyInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IDestroyGiftCardValue>();

            Loyalty initialLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                                 LevelUpTestConfiguration.Current.MerchantId);

            var createdGiftCard = createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                   LevelUpTestConfiguration.Current.MerchantId,
                                                                   LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                   LevelUpTestConfiguration.Current.ConsumerQrData,
                                                                   valueToAdd);

            Assert.AreEqual(createdGiftCard.AmountAddedInCents, valueToAdd);

            Loyalty postAdditionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                                      LevelUpTestConfiguration.Current.MerchantId);

            Assert.AreEqual(postAdditionLoyalty.PotentialCreditAmount - initialLoyalty.PotentialCreditAmount, valueToAdd);

            // Cleanup
            destroyInterface.GiftCardDestroyValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                  LevelUpTestConfiguration.Current.MerchantId, LevelUpTestConfiguration.Current.ConsumerQrData, valueToAdd);

            Loyalty postDestructionLoyalty = loyaltyInterface.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                                         LevelUpTestConfiguration.Current.MerchantId);

            Assert.AreEqual(postDestructionLoyalty.PotentialCreditAmount, initialLoyalty.PotentialCreditAmount);
        }
Exemple #7
0
        public void CreateFails_WhenQrCodeIsInvalid()
        {
            const string invalidQRCode = "LU02000ROETEST_BAD_QR_DATA_D40200A0LU";

            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();

            const int refundAmountCents = 50;

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(refundAmountCents);

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

            try
            {
                refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData);
                Assert.Fail("Expected LevelUpApiException on refund with bad Qr data but did not catch it!");
            }
            catch (LevelUpApiException) { }

            // Cleanup, refund the order.
            refundData = new DetachedRefundRequestBody(LevelUpTestConfiguration.Current.MerchantLocationId,
                                                       LevelUpTestConfiguration.Current.ConsumerQrData,
                                                       refundAmountCents);
            refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData);
        }
Exemple #8
0
        public void GetLocationDetails()
        {
            IQueryMerchantData queryClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryMerchantData>();
            var locationDetails            = queryClient.GetLocationDetails(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                            LevelUpTestConfiguration.Current.MerchantLocationId);

            Assert.AreEqual(locationDetails.MerchantId, LevelUpTestConfiguration.Current.MerchantId);
        }
Exemple #9
0
        public void ListManagedLocations()
        {
            IQueryMerchantData queryClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryMerchantData>();
            var locations = queryClient.ListManagedLocations(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken);

            Assert.IsTrue(locations.Count > 0);
            Assert.AreEqual(locations.Count(x => x.LocationId == LevelUpTestConfiguration.Current.MerchantLocationId), 1);
        }
        public void GetPaymentToken()
        {
            IRetrievePaymentToken client = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrievePaymentToken>();
            var paymentToken             = client.GetPaymentToken(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            Assert.IsNotNull(paymentToken);
            Assert.IsTrue(LevelUpTestConfiguration.Current.ConsumerQrData.Contains(paymentToken.Data));
        }
        public void GetLocationDetails()
        {
            IQueryUser queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryUser>();

            var locationData = queryInterface.ListUserAddresses(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken);

            Assert.IsTrue(locationData.Count > 0);
            Assert.IsNotNull(locationData.Where(x => x.StreetAddress == "101 Arch Street").DefaultIfEmpty(null).FirstOrDefault());
        }
        public void CreateRefundForNonExistantOrder()
        {
            ICreateRefund refundInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                refundInterface.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, "aaa");
            });
        }
Exemple #13
0
        public void ListOrders()
        {
            CompletedOrderResponse created = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer();

            IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>();
            var          orders         = queryInterface.ListOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                    LevelUpTestConfiguration.Current.MerchantLocationId, 1, 3);

            Assert.IsNotNull(orders.Where(x => x.OrderIdentifier == created.OrderIdentifier).DefaultIfEmpty(null).FirstOrDefault());
        }
Exemple #14
0
        internal static int GetAvailableDiscountCredit(string qrData)
        {
            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();

            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                qrData, int.MaxValue, int.MaxValue, 0, 0, null, null, null, null, true, false, null);

            return(proposedOrder.DiscountAmountCents);
        }
Exemple #15
0
        public void ProposedOrderWithBadQrCode_ShouldThrow()
        {
            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                LevelUpTestConfiguration.Current.MerchantLocationId, "bad_qr_code", 10, 10, 0, 0);
            });
        }
Exemple #16
0
        public void GetMerchantFundedGiftCardCreditWithInvalidQRCode()
        {
            IRetrieveMerchantFundedGiftCardCredit creditInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                creditInterface.GetMerchantFundedGiftCardCredit(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                "LU_invalid_qr_code");
            });
        }
        public void GetUser()
        {
            IQueryUser queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryUser>();

            var userData = queryInterface.GetUser(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken,
                                                  LevelUpTestConfiguration.Current.ConsumerId);

            Assert.AreEqual(userData.FirstName, LevelUpTestConfiguration.Current.ConsumerUserFirstName);
            Assert.AreEqual(userData.LastName.ToLower().ToCharArray()[0],
                            LevelUpTestConfiguration.Current.ConsumerUserLastInitial.ToLower().ToCharArray()[0]);
        }
Exemple #18
0
        public void ListFilteredOrders_WithFilter()
        {
            IQueryOrders           queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>();
            CompletedOrderResponse first          = ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(200);

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(300);  // ensure that there is at least one other order that the filter will ignore.

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

            Assert.AreEqual(orders.Count, 1);
            Assert.IsTrue(orders.First().OrderIdentifier == first.OrderIdentifier);
        }
Exemple #19
0
        [Test]    // Shouldn't keep making a bunch of sandbox users, at least by default
        public void CreateUserShouldSucceed()
        {
            var client = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IModifyUser>();

            // generate a new email via a guid
            string uniqueEmail = string.Format("{0}[email protected]", Guid.NewGuid().ToString("N"));

            var user = client.CreateUser(LevelUpTestConfiguration.Current.ClientId, "john", "doe", uniqueEmail, "password");

            Assert.IsNotNull(user);
            Assert.AreEqual(user.FirstName, "john");
            Assert.AreEqual(user.Email, uniqueEmail);
        }
Exemple #20
0
        public void ListFilteredOrders_WithOrdering()
        {
            IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>();

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(200);
            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(300);

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

            var copy = new List <OrderDetailsResponse>(orders);

            Assert.IsTrue(copy.OrderByDescending((x => x.Total)).SequenceEqual(orders));
        }
Exemple #21
0
        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 CreateGiftCardValue_NegativeAmount()
        {
            const int valueToAdd = -50;

            ICreateGiftCardValue createInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateGiftCardValue>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                 LevelUpTestConfiguration.Current.MerchantId,
                                                 LevelUpTestConfiguration.Current.MerchantLocationId,
                                                 LevelUpTestConfiguration.Current.ConsumerQrData,
                                                 valueToAdd);
            }, "Failed to throw exception for a negative gift card value.");
        }
Exemple #23
0
        public void CreateUser_WillFailIfEmailIsNotUnique()
        {
            CreateUserRequestBodyUserSection request = new CreateUserRequestBodyUserSection(
                LevelUpTestConfiguration.Current.ConsumerUserFirstName,
                LevelUpTestConfiguration.Current.ConsumerUserLastInitial,
                LevelUpTestConfiguration.Current.MerchantEmailAddress,
                "password");

            var client = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IModifyUser>();

            Assert.Throws <LevelUpApiException>(() =>
            {
                client.CreateUser(LevelUpTestConfiguration.Current.ClientId, request);
            });
        }
Exemple #24
0
        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, false, 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, false, 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);
        }
Exemple #25
0
        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, false, 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, false, null));
        }
Exemple #26
0
        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);
        }
Exemple #28
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);
        }
Exemple #29
0
        private List <OrderDetailsResponse> GetFirstThreePagesOfOrdersForTestMerchant()
        {
            IQueryOrders queryInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IQueryOrders>();

            var retval = new List <OrderDetailsResponse>();

            int  currentPage       = 1;
            bool areThereMorePages = true;

            while (areThereMorePages && currentPage < 4)
            {
                var orders = queryInterface.ListOrders(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                       LevelUpTestConfiguration.Current.MerchantLocationId, currentPage, currentPage, out areThereMorePages);
                retval.AddRange(orders);
                currentPage++;
            }
            return(retval);
        }
Exemple #30
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);
        }