question

asifjavaid105 avatar image
asifjavaid105 asked vahobabaho sent

How to initialize clover printer using Clover remote pay SDK android

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.

Clover Android SDKPrintClover StationRemote Pay Android
10 |2000

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

0 Answers

·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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

Welcome to the
Clover Developer Community