/// <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(); }
private static void ApplyDiscountToPOS(ProposedOrderResponse proposedOrderResponse) { Console.WriteLine("Discount to apply: " + toDollarString(proposedOrderResponse.DiscountAmountCents)); // Here is where you would submit the discount to your POS system. }