public final class CashDrawer extends ServiceConnector implements ICashDrawer
This class manages a cash drawer connected to Ingenico terminals using USB adapters. For the Ingenico configuration, the cash drawer must be connected to the Cradle provided by Ingenico via the DT-100U/USB adapter. Other adapters are not managed.
It will be possible via the herewith detailed APIs to open the cash drawer or to know if a cash drawer is connected. As a limitation, it will be only possible to detect that a USB adapter is connected to the cradle/terminal, but not a cash drawer. Therefore it is expected that appropriate steps are undertaken to make sure that a cash drawer is connected to the USB adapter.
ServiceConnector.InternalServiceConnection
ACTION_BIND_V2, SERVICES_PACKAGE
Modifier and Type | Method and Description |
---|---|
CashDrawerInfoResult |
getCashDrawerInfo()
Retrieve the cash drawer state information.
|
static ICashDrawer |
getInstance(android.content.Context context)
Return a global instance of CashDrawer, which is the default implementation of
ICashDrawer , and instantiate it if needed. |
protected java.lang.String |
getServiceName()
Must be overrided to provide service class name used for binding.
|
protected void |
onServiceReady(android.os.IBinder service)
Internal callback when service is connected.
|
protected void |
onServiceUnbinded()
Internal callback when service is disconnected.
|
void |
open()
Open the cash drawer.
|
connect, connectSync, disconnect, ensureServiceIsReady, getBindIntent, getContext, isConnected
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
connect, disconnect, isConnected
public static ICashDrawer getInstance(android.content.Context context)
ICashDrawer
, and instantiate it if needed.
Be aware that only one instance will be created for the whole application, so the associated
context should not be a component which could be destroyed at some point, ie. an Activity.
Passing the Application
to this method is preferred over other context types.
context
- A valid context to initialize the instance.public CashDrawerInfoResult getCashDrawerInfo() throws IngenicoException
Example:
ICashDrawer
cashdrawer = CashDrawer.getInstance(context);CashDrawerInfoResult
cashdrawerResult = cashdrawer.getCashDrawerInfo();
getCashDrawerInfo
in interface ICashDrawer
IngenicoException
- if retrieving the cash drawer state failspublic void open() throws IngenicoException
Example:
ICashDrawer
cashdrawer = CashDrawer.getInstance(context);
cashdrawer.open();
open
in interface ICashDrawer
IngenicoException
- when the opening of the cash drawer failsprotected java.lang.String getServiceName()
ServiceConnector
getServiceName
in class ServiceConnector
protected void onServiceReady(android.os.IBinder service)
ServiceConnector
onServiceReady
in class ServiceConnector
protected void onServiceUnbinded()
ServiceConnector
onServiceUnbinded
in class ServiceConnector