Hi Floks,
I am integrating clover remote pay android SDK to print an receipt using kotlin code. Here is my code. The problem is after calling cloverConnector.initializeConnection(), we are not getting any response in CloverConnectorLister which results in unable to make a print request.
Here is article I am following.
https://docs.clover.com/dev/docs/creating-custom-receipts
Please suggest.
private class TestListener(cloverConnector: ICloverConnector?, context: Context) : DefaultCloverConnectorListener(cloverConnector) { var mContext: Context = context override fun onConfirmPaymentRequest(request: ConfirmPaymentRequest) { } override fun onDeviceReady(merchantInfo: MerchantInfo) { super.onDeviceReady(merchantInfo) Log.d("ShiftViewModel", "device ready") Toast.makeText(mContext, "ShiftViewModel onDeviceReady ready", Toast.LENGTH_LONG).show(); val rpr = RetrievePrintersRequest() cloverConnector?.retrievePrinters(rpr) //connected() } override fun onRetrievePrintersResponse(response: RetrievePrintersResponse) { var printers = response.printers if (printers != null) { printer = printers.get(0) Toast.makeText(mContext, "ShiftViewModel Printer ready", Toast.LENGTH_LONG).show(); } } } fun getUSBConfiguration(context: Context): CloverDeviceConfiguration { return USBCloverDeviceConfiguration(context, "com.cloverconnector.java.simple.sample:2.0.0") } private fun connected() { //runOnUiThread { textConnect.setText(R.string.connection_successful) } } fun connectPrinter(context: Context) { // Default to using USB Pay Display, comment the line below if you would like to use a // network connection and Secure Network Pay Display. val deviceConfiguration = getUSBConfiguration(context) cloverConnector = CloverConnector(deviceConfiguration) // Uncomment the below line (and comment the line above) if you would like to use a network connection and Secure // Network Pay Display. See the instructions in the README if you need more information. //cloverConnector = new CloverConnector(getNetworkConfiguration("ip-address", 12345)); cloverConnector?.addCloverConnectorListener(TestListener(cloverConnector, context)) cloverConnector?.initializeConnection() Toast.makeText(context, "ShiftViewModel Printer initializing", Toast.LENGTH_LONG).show(); }
We are calling connectPrinter() method however, its not initializing and we are unable to proceed. Please suggest.
Thank you.
Asif.