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()); }
/// <summary> /// This is an example console application that walks through how one might use the LevelUp C# SDK /// to place an order in the LevelUp sandbox platform. /// </summary> static void Main(string[] args) { #region Parse Arguments if (args.Length != 5) { PrintUsageString(); return; } int locationId; if (!Int32.TryParse(args[3], out locationId)) { PrintUsageString(); return; } string merchantUserName = args[0]; string merchantPassword = args[1]; string apiKey = args[2]; string customersQrCode = args[4]; #endregion // Step 1: Authenticate string accessToken = Authenticate(merchantUserName, merchantPassword, apiKey); // Step 2: Add items to your order List <Item> itemsToOrder = CreateAFewExampleItems(); // Step 3: Propose the order to the LevelUp platform. Find out how much discount credit to apply ProposedOrderResponse proposedOrder = ProposedOrder(accessToken, locationId, customersQrCode, itemsToOrder); // Step 4: Apply the discount credit on your POS ApplyDiscountToPOS(proposedOrder); // Step 5: Figure out the tax on your POS int taxInCents = CalculateTaxOnCheck(itemsToOrder, proposedOrder.DiscountAmountCents); // Step 6: Complete the order with the LevelUp platform. The consumer's account is charged. CompletedOrderResponse completedOrder = CompleteOrder(accessToken, locationId, customersQrCode, proposedOrder.ProposedOrderIdentifier, proposedOrder.DiscountAmountCents, taxInCents, itemsToOrder); // Step 7: Apply the LevelUp payment & giftcard amount on your POS ApplyPayment(completedOrder); // Step 8: (cleanup) Refund the order RefundOrder(accessToken, completedOrder.OrderIdentifier); Console.WriteLine("Order Complete! Check out the code to see how it's done."); Console.ReadLine(); }
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_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); }
private static void ApplyPayment(CompletedOrderResponse response) { // Here is where you would submit the Levelup payment to your POS system. }