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(); }
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); }
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 ListAllOrders() { // Note: the integration test merchant may accrue a lot of orders -- this will // retrieve all of them, which may become a problem if we are running the // integration tests frequently? ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); var initialOrders = GetEveryOrderForTestMerchant(); ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(); var currentOrders = GetEveryOrderForTestMerchant(); Assert.IsTrue(currentOrders.Count == initialOrders.Count + 1); }
public void ProposedOrderWithDiscountAndGiftCard_ShouldSucceed() { int availableDiscountCents = ClientModuleIntegrationTestingUtilities.GetAvailableDiscountCredit(LevelUpTestConfiguration.Current.ConsumerQrData); const int giftCardAmountToUseInCents = 1000; ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); ClientModuleIntegrationTestingUtilities.AddGiftCardCreditOnConsumerUserAccount(giftCardAmountToUseInCents); const int taxAmountInCents = 100; // Make sure that gift card, credit card, and discount(if available) will all be requried as part of this test payment. int costOfItemInCents = availableDiscountCents + giftCardAmountToUseInCents + taxAmountInCents + 500; IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>(); var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, costOfItemInCents, costOfItemInCents, taxAmountInCents, 0, null, null, null, null, true, null); Assert.AreEqual(proposedOrder.DiscountAmountCents, availableDiscountCents); int taxAmountAfterDiscountApplied = (taxAmountInCents * (costOfItemInCents - proposedOrder.DiscountAmountCents)) / costOfItemInCents; var completedOrder = orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, proposedOrder.ProposedOrderIdentifier, costOfItemInCents, costOfItemInCents, taxAmountAfterDiscountApplied, 0, proposedOrder.DiscountAmountCents, null, null, null, null, true, null); Assert.AreEqual(completedOrder.GiftCardTipAmount, 0); Assert.AreEqual(completedOrder.GiftCardTotalAmount, giftCardAmountToUseInCents); Assert.AreEqual(completedOrder.GiftCardTipAmount, 0); Assert.AreEqual(completedOrder.TipAmount, 0); Assert.AreEqual(completedOrder.SpendAmount, costOfItemInCents); ICreateRefund refundClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateRefund>(); refundClient.RefundOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, completedOrder.OrderIdentifier); }
internal static CompletedOrderResponse PlaceOrderAtTestMerchantWithTestConsumer(int total = 100) { ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); IManageProposedOrders orderClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <IManageProposedOrders>(); var proposedOrder = orderClient.CreateProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, total, total, 0, 0, null, null, null, null, true, null); return(orderClient.CompleteProposedOrder(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, proposedOrder.ProposedOrderIdentifier, total, total, 0, 0, proposedOrder.DiscountAmountCents, null, null, null, null, true, null)); }
public void CreateDetachedRefund() { ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); const int refundAmountCents = 50; ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(refundAmountCents); ICreateDetachedRefund refundInterface = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ICreateDetachedRefund>(); var refundData = new DetachedRefundRequestBody(LevelUpTestConfiguration.Current.MerchantLocationId, LevelUpTestConfiguration.Current.ConsumerQrData, refundAmountCents); var refund = refundInterface.CreateDetachedRefund(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpMerchantAccessToken, refundData); Assert.AreEqual(refund.CreditAmountCents, refundAmountCents); }
public void GetLoyalty() { ClientModuleIntegrationTestingUtilities.RemoveAnyGiftCardCreditOnConsumerUserAccount(); ILookupUserLoyalty loyaltyClient = ClientModuleIntegrationTestingUtilities.GetSandboxedLevelUpModule <ILookupUserLoyalty>(); var initialLoyalty = loyaltyClient.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(initialLoyalty.MerchantId, LevelUpTestConfiguration.Current.MerchantId); ClientModuleIntegrationTestingUtilities.PlaceOrderAtTestMerchantWithTestConsumer(); var finalLoyalty = loyaltyClient.GetLoyalty(ClientModuleIntegrationTestingUtilities.SandboxedLevelUpUserAccessToken, LevelUpTestConfiguration.Current.MerchantId); Assert.AreEqual(finalLoyalty.OrdersCount, initialLoyalty.OrdersCount + 1); }
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); }
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(); }