As an example of integration, please use the sample app provided in our GitHub repository as a reference

 

Installation


Add the repository to your gradle dependencies:

allprojects {
    repositories {
        mavenCentral()
  }
}

Add the dependency to a module:

implementation 'com.mypos:slavesdk:2.1.0'

 

Initialization


Initialize the MyPos components in your app:

public class SampleApplication extends Application {

private POSHandler  mPOSHandler;

@Override
public void onCreate() {
	super.onCreate();
	POSHandler.setCurrency(Currency.EUR);
 	mPOSHandler = POSHandler.getInstance();
}

Optional settting for default receipt configuration is avaibale:

POSHandler.setDefaultReceiptConfig(POSHandler.RECEIPT_PRINT_ONLY_MERCHANT_COPY);

If set the default receipt configuration can be removed:

POSHandler.clearDefaultReceiptConfig();

Optional setting for the language of the receipts is avaibale(default is Language.ENGLISH):

POSHandler.setLanguage(Language.GERMAN);

isTerminalBusy() returns boolean to check if an operation is being performed at the moment:

POSHandler.getInstance().isTerminalBusy();

 

Connect to terminal


Choose connection type:

POSHandler.setConnectionType(ConnectionType.BLUETOOTH);
POSHandler.getInstance().connectDevice(context);

If the connection type is set to BLUETOOTH, ensure that the needed permissions are given in order to discover available Bluetooth devices.

if (POSHandler.getInstance().checkPermissions(context)) {
    // continue...
} else {
    // permissions request is sent...
}

 

Handle permissions result:

@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
   if (requestCode == POSHandler.PERMISSIONS_REQUEST_CODE) {
       // check permissions result...
   }
}

 

Attach connection listener


mPOSHandler.setConnectionListener(new ConnectionListener() {
    @Override
    public void onConnected(final BluetoothDevice device) {
        // handle connected event here
    }
});

 

 

Attach pos ready listener

mPOSHandler.setPOSReadyListener(new POSReadyListener() {
    @Override
    public void onPOSReady() {
        // now you can start a transaction
    }
});

 

Send E-Receipt

In case you want to use email/phone receipt you have to choose POSHandler.RECEIPT_E_RECEIPT receipt configuration.

The following listener will be fired immediately after a transaction is approved:

POSHandler.getInstance().setPOSCredentialsListener(new POSCredentialsListener() {
    @Override
    public void askForCredentials(final CredentialsListener listener) {
	listener.onCredentialsSet("email@example.com"); // instead of email you can pass a phone number
    }
});