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();
        }
コード例 #2
0
        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, null);

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

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                     proposedOrder.ProposedOrderIdentifier);
        }
コード例 #3
0
        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);
        }
        public void ProposedOrderWithBadQrCode_ShouldThrow()
        {
            IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>();

            orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                            LevelUpTestConfiguration.Current.MerchantLocationId, "bad_qr_code", 10, 10, 0, 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, 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, null);

            Assert.AreEqual(completedOrder.TipAmount, tipAmountCents);

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

            refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, completedOrder.OrderIdentifier);
        }
        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>();
            var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                                LevelUpTestConfiguration.Current.MerchantLocationId,
                                                                LevelUpTestConfiguration.Current.ConsumerWithNoLinkedPaymentQrData,
                                                                spendAmount, spendAmount, 0, 0, null, null, null, null, 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, null);

            Assert.Fail("Failed to throw a LevelUpAPIException for an order with no partial auth and a spend amount " +
                        "greater than the user's available credit.");
        }
        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, 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, 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 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);
        }
コード例 #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);
        }
コード例 #10
0
        public void GetMerchantFundedGiftCardCreditWithInvalidQRCode()
        {
            IRetrieveMerchantFundedGiftCardCredit creditInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IRetrieveMerchantFundedGiftCardCredit>();

            creditInterface.GetMerchantFundedGiftCardCredit(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                                            LevelUpTestConfiguration.Current.MerchantLocationId,
                                                            "LU_invalid_qr_code");
        }
        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));
        }
コード例 #12
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);
        }
        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());
        }
        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, null);

            return(proposedOrder.DiscountAmountCents);
        }
        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());
        }
        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]);
        }
コード例 #17
0
        public void CreateGiftCardValue_NegativeAmount()
        {
            const int valueToAdd = -50;

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

            createInterface.GiftCardAddValue(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken,
                                             LevelUpTestConfiguration.Current.MerchantId,
                                             LevelUpTestConfiguration.Current.MerchantLocationId,
                                             LevelUpTestConfiguration.Current.ConsumerQrData,
                                             valueToAdd);
        }
コード例 #18
0
        public void CreateUser_WillFailIfEmailIsNotUnique()
        {
            CreateUserRequestBodyUserSection request = new CreateUserRequestBodyUserSection(
                LevelUpTestConfiguration.Current.ConsumerUserFirstName,
                LevelUpTestConfiguration.Current.ConsumerUserLastInitial,
                LevelUpTestConfiguration.Current.MerchantEmailAddress,
                "password");

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

            client.CreateUser(LevelUpTestConfiguration.Current.ClientId, request);
        }
コード例 #19
0
        [Ignore]    // 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);
        }
        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);
        }
        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));
        }
        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);
        }
        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);
        }
        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 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);
        }
コード例 #27
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);
        }
コード例 #29
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.
        }