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