question

paulryan avatar image
paulryan asked lilluunk commented

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
2 comments
10 |2000

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

David Marginian avatar image David Marginian ♦♦ commented ·

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 ·
lilluunk avatar image lilluunk David Marginian ♦♦ commented ·

As someone who's passionate about programming and constantly seeking to expand my knowledge, I understand the importance of having reliable resources and support. In my own experience, finding the right guidance and educational materials has been instrumental in my growth as a developer. That's why I want to recommend help with coding homework to anyone looking to enhance their Java programming skills or seeking assistance with specific Java concepts like invoking InputOption.I've personally benefited from their resources, and I'm confident that others will find them equally valuable in their quest to master Java programming.

0 Likes 0 ·

0 Answers

Welcome to the
Clover Developer Community