Take payment


Once initialization is completed, you can start using the myPOS SDK Android to accept card payments.

Variant 1. Payment via internal SDK activity: Amount and transaction reference are optional parameters and can be set as null.

 mPOSHandler.openPaymentActivity(
        MainActivity.this /*activity*/,
        REQUEST_CODE_MAKE_PAYMENT /*requestCode*/,
        "10.50" /*amount*/,
        UUID.randomUUID().toString()/*transaction reference*/
);

Variant 2. Payment via direct SDK method: Transaction reference is optional parameter and can be set as null.

mPOSHandler.purchase(
	"10.50" /*amount*/, 
	UUID.randomUUID().toString() /*transaction reference*/, 
	POSHandler.RECEIPT_PRINT_AUTOMATICALLY /*receipt configuration*/ );
	);

 

Handle payment result


Variant 1. Payment via internal SDK activity:

protected void onActivityResult(int requestCode, int resultCode, Intent data){
    	if( requestCode == REQUEST_CODE_MAKE_PAYMENT && resultCode == RESULT_OK) {
        		TransactionData transactionData = data.getParcelableExtra(POSHandler.INTENT_EXTRA_TRANSACTION_DATA);
        		// Handle the response here
    	}
}

Variant 2. Payment via direct SDK method:

mPOSHandler.setPOSInfoListener(new POSInfoListener() {
    @Override
    public void onPOSInfoReceived(final int command, final int status, final String description) {
        // Handle the response here
    }

    @Override
    public void onTransactionComplete(final TransactionData transactionData) {
        // Handle the response here
    }
});

See POS Info statuses for more information

 

Refund


With refund host application could initiate a refund transaction to the customers’ card account with the specified amount.

Variant 1. Refund via internal SDK activity: Amount and transaction reference are optional parameters and can be set as null.

 mPOSHandler.openPaymentActivity(
        MainActivity.this /*activity*/,
        REQUEST_CODE_MAKE_REFUND /*requestCode*/,
        "10.50" /*amount*/,
        UUID.randomUUID().toString()/*transaction reference*/
);

Variant 2. Refund via direct SDK method: Transaction reference is optional parameter and can be set as null.

mPOSHandler.purchase(
	"10.50" /*amount*/, 
	UUID.randomUUID().toString() /*transaction reference*/, 
	POSHandler.RECEIPT_PRINT_AUTOMATICALLY /*receipt configuration*/ );
	);

 

Handle refund result


Variant 1. Refund via internal SDK activity:

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
    	if( requestCode == REQUEST_CODE_MAKE_REFUND && resultCode == RESULT_OK) {
        		TransactionData transactionData = data.getParcelableExtra(POSHandler.INTENT_EXTRA_TRANSACTION_DATA);
        		// Handle the response here
    	}
}

Variant 2. Refund via direct SDK method:

mPOSHandler.setPOSInfoListener(new POSInfoListener() {
    @Override
    public void onPOSInfoReceived(final int command, final int status, final String description) {
        // Handle the response here
    }

    @Override
    public void onTransactionComplete(final TransactionData transactionData) {
        // Handle the response here
    }
});

See POS Info statuses for more information

 

Reprint last receipt


With this method host application could request reprint of last transaction slip.

mPOSHandler.reprintReceipt();

 

Print random receipt


Check if the connected myPOS device has a printer hardware:

mPOSHandler.hasPrinter()

Printing an external receipt is performed by passing a ReceiptData object to the printReceipt() method

ReceiptData receiptData = new ReceiptData();
receiptData.addLogo(1 /*Logo index*/);
receiptData.addEmptyRow();
receiptData.addRow(
	"HEAD" /*text*/, 
	ReceiptData.Align.CENTER, /* Enum align setting (LEFT, CENTER, RIGHT) */
	ReceiptData.FontSize.DOUBLE /* Enum font size setting (SINGLE, DOUBLE) */
	);
mPOSHandler.printReceipt(receiptData);