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);
        }