public static void testPaymentAndVoid(CloverConnector cloverConnector, TestConnectorListener connListener) { //BEGIN: Test Void SaleRequest paymentRequest = new SaleRequest(); paymentRequest.ExternalId = ExternalIDUtil.GenerateRandomString(13); paymentRequest.Amount = 1324; paymentRequest.TipAmount = 123; System.Console.WriteLine("Preparing To Test Sale: $" + paymentRequest.Amount * 100.00); System.Console.WriteLine("Press Any Key to Continue..."); System.Console.ReadKey(); //cloverConnector.Sales += paymentListener; cloverConnector.Sale(paymentRequest); while (!connListener.hasResponse) { System.Console.WriteLine("Waiting for paymentResponse"); System.Threading.Thread.Sleep(1000); } SaleResponse response = connListener.saleResponse; string paymentId = response.Payment.id; string orderId = response.Payment.order.id; string employeeId = response.Payment.employee.id; VoidPaymentRequest voidRequest = new VoidPaymentRequest(); voidRequest.OrderId = orderId; voidRequest.PaymentId = paymentId; voidRequest.EmployeeId = employeeId; voidRequest.VoidReason = VoidReason.USER_CANCEL.ToString(); cloverConnector.VoidPayment(voidRequest); while (!connListener.hasResponse) { System.Console.WriteLine("Waiting for voidResponse"); System.Threading.Thread.Sleep(1000); } VoidPaymentResponse voidResponse = connListener.voidPaymentResponse; System.Console.WriteLine(voidResponse.Result); //END: Test Void }
//////////////// Sale methods ///////////// private void PayButton_Click(object sender, EventArgs e) { PayButton.Enabled = false; StoreItems.Enabled = false; newOrderBtn.Enabled = false; SaleRequest request = new SaleRequest(); request.Amount = Store.CurrentOrder.Total; request.TipAmount = 0; cloverConnector.Sale(request); }
//////////////// Sale methods ///////////// private void Pay(POSCard card) { StoreItems.BringToFront(); StoreDiscounts.BringToFront(); SaleButton.Enabled = false; StoreItems.Enabled = false; newOrderBtn.Enabled = false; SaleRequest request = new SaleRequest(); request.ExternalId = ExternalIDUtil.GenerateRandomString(13); // Card Entry methods int CardEntry = 0; CardEntry |= ManualEntryCheckbox.Checked ? CloverConnector.CARD_ENTRY_METHOD_MANUAL : 0; CardEntry |= MagStripeCheckbox.Checked ? CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE : 0; CardEntry |= ChipCheckbox.Checked ? CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT : 0; CardEntry |= ContactlessCheckbox.Checked ? CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS : 0; request.CardEntryMethods = CardEntry; request.CardNotPresent = CardNotPresentCheckbox.Checked; request.Amount = Store.CurrentOrder.Total; request.TipAmount = 0; request.TaxAmount = Store.CurrentOrder.TaxAmount; if (!offlineDefault.Checked) { request.AllowOfflinePayment = offlineYes.Checked; } if (!approveOfflineDefault.Checked) { request.ApproveOfflinePaymentWithoutPrompt = approveOfflineYes.Checked; } if (card != null) { request.VaultedCard = new com.clover.sdk.v3.payments.VaultedCard(); request.VaultedCard.cardholderName = card.Name; request.VaultedCard.first6 = "" + card.First6; request.VaultedCard.last4 = "" + card.Last4; request.VaultedCard.expirationDate = card.Month + "" + card.Year; request.VaultedCard.token = card.Token; } if (Store.CurrentOrder.TippableAmount != Store.CurrentOrder.Total) { request.TippableAmount = Store.CurrentOrder.TippableAmount; } cloverConnector.Sale(request); }
public void Sale(SaleRequest request) { Send("/Sale", request); }
//////////////// Sale methods ///////////// private void PayButton_Click(object sender, EventArgs e) { StoreItems.BringToFront(); StoreDiscounts.BringToFront(); PayButton.Enabled = false; StoreItems.Enabled = false; newOrderBtn.Enabled = false; SaleRequest request = new SaleRequest(); request.Amount = Store.CurrentOrder.Total; request.TipAmount = 0; if(cloverConnector.Sale(request) < 0) { PaymentReset(); } }
public void Sale(SaleRequest request) { if (websocket != null) { SaleRequestMessage message = new SaleRequestMessage(); message.payload = request; websocket.Send(JsonUtils.serialize(message)); } }