question

Paul.Ryan avatar image
Paul.Ryan asked ·

invokeInputOption on Java

Hi David


I can't seem to invokeinput button press on Java, can you have a look at the below code, and point me in the right direction.


package com.clover.remote.core;


import com.clover.remote.Challenge;

import com.clover.remote.client.CloverConnectorFactory;

import com.clover.remote.client.ICloverConnectorListener;

import com.clover.remote.client.DefaultCloverConnectorListener;

import com.clover.remote.client.ICloverConnector;

import com.clover.remote.client.CloverConnector;

import com.clover.remote.client.MerchantInfo;

import com.clover.remote.client.messages.*;

import com.clover.sdk.v3.order.Order;

import com.clover.sdk.v3.payments.Payment;


import static javax.swing.JOptionPane.showMessageDialog;


public class SaleTest {

private static ICloverConnectorListener defaultListener;

private static ICloverConnector cloverConnector;

private static CloverConnector CloverConnector;


private static SaleRequest pendingSale;

private static PrintPaymentMerchantCopyReceiptMessage printRequest;



private static void exitApp() {

synchronized (cloverConnector) {

cloverConnector.notifyAll();

}

}


public static void main(String[] args) {


cloverConnector =

CloverConnectorFactory.createICloverConnector(Utils.getNetworkConfiguration("192.168.1.9", 12345,

null));


cloverConnector.addCloverConnectorListener(new DefaultCloverConnectorListener(cloverConnector) {

@Override

public void onConfirmPaymentRequest(ConfirmPaymentRequest request) {

System.out.println("Confirm Payment Request");


Challenge[] challenges = request.getChallenges();

if (challenges != null && challenges.length > 0) {

for (Challenge challenge : challenges) {

System.out.println("Received a challenge: " + challenge.type);

}

}


System.out.println("Automatically processing challenges");

cloverConnector.acceptPayment(request.getPayment());

}


@Override

public void onDeviceReady(MerchantInfo merchantInfo) {

super.onDeviceReady(merchantInfo);

try {

pendingSale = new SaleRequest(26000, Utils.getNextId());

System.out.println("Making sale request:");

System.out.println(" External ID: " + pendingSale.getExternalId());

System.out.println(" Amount: " + pendingSale.getAmount());

System.out.println(" Tip Amount: " + pendingSale.getTipAmount());

System.out.println(" Tax Amount: " + pendingSale.getTaxAmount());

int cardEntryMethods = CloverConnector.CARD_ENTRY_METHOD_MAG_STRIPE | CloverConnector.CARD_ENTRY_METHOD_NFC_CONTACTLESS | CloverConnector.CARD_ENTRY_METHOD_ICC_CONTACT | CloverConnector.CARD_ENTRY_METHOD_MANUAL;

pendingSale.setCardEntryMethods(cardEntryMethods);

//pendingSale.setDisableReceiptSelection(true);

cloverConnector.sale(pendingSale);


} catch (Exception ex) {

System.err.println("Error submitting sale request");

ex.printStackTrace();

exitApp();

}

}



@Override

public void onSaleResponse(SaleResponse response) {


try {

if (response.isSuccess()) {

Payment payment = response.getPayment();

if (payment.getExternalPaymentId().equals(pendingSale.getExternalId())) {

System.out.println("Sale Request Successful");

System.out.println(" ID: " + payment.getId());

System.out.println(" External ID: " + payment.getExternalPaymentId());

System.out.println(" Order ID: " + payment.getOrder().getId());

System.out.println(" Amount: " + payment.getAmount());

System.out.println(" Tip Amount: " + payment.getTipAmount());

System.out.println(" Tax Amount: " + payment.getTaxAmount());

System.out.println(" Offline: " + payment.getOffline());

System.out.println(" Authorization Code: " + payment.getCardTransaction().getAuthCode());

System.out.println(" Card Type: " + payment.getCardTransaction().getCardType());

System.out.println(" Last 4: " + payment.getCardTransaction().getLast4());


Order order = new Order();

order.setId(payment.getOrder().getId());

try {

//PrintPaymentReceiptMessage msg = new PrintPaymentReceiptMessage(payment, order);

DisplayReceiptOptionsRequest req = new DisplayReceiptOptionsRequest();

req.setPaymentId(payment.getId());

req.setOrderId(payment.getOrder().getId());

cloverConnector.displayPaymentReceiptOptions(req);

//defaultListener.onPrintPaymentReceipt(msg);

//System.out.println(msg);

} catch (Exception ex) {

System.err.println("Error handling printing receipt");

ex.printStackTrace();

}

} else {

System.err.println("Sale Request/Response mismatch - " + pendingSale.getExternalId() +

" vs " + payment.getExternalPaymentId());

}

} else {

System.err.println("Sale Request Failed - " + response.getReason());

}

} catch (Exception ex) {

System.err.println("Error handling sale response");

ex.printStackTrace();

}

exitApp();

}


@Override

public void onVerifySignatureRequest(VerifySignatureRequest request) {

super.onVerifySignatureRequest(request);

System.out.println("Verify Signature Request - Signature automatically accepted by default");

}

});



cloverConnector.initializeConnection();


synchronized (cloverConnector) {

try {

cloverConnector.wait();

} catch (Exception ex) {

System.out.println("Exit signaled");

}

}


cloverConnector.dispose();

System.exit(0);

}

}


remote pay java
1 comment
10 |2000 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

It would be helpful if you would explain what you are trying to do and only include the relevant code. I looked through everything you posted and I don't see any attempts to invoke an input option.

0 Likes 0 · ·

0 Answers

Welcome to the
Clover Developer Community