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 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);
        }
        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 #4
0
        public void ListOrdersWithPaging()
        {
            ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount();

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer();
            var initialOrders = GetFirstThreePagesOfOrdersForTestMerchant();

            ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer();
            var currentOrders = GetFirstThreePagesOfOrdersForTestMerchant();

            Assert.IsTrue(currentOrders.ElementAt(0).OrderIdentifier != initialOrders.ElementAt(0).OrderIdentifier);
            Assert.IsTrue(currentOrders.ElementAt(1).OrderIdentifier == initialOrders.ElementAt(0).OrderIdentifier);
        }
Exemple #5
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 #6
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);
        }
Exemple #7
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));
        }
        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 #9
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 #10
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();
        }