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 an optional parameter and can be set as null.

            POSHandler.getInstance().purchase(PaymentParams.builder()
                    .productAmount("13.37")
                    .currency("EUR")
                    .tipAmount("1.55")
                    .receiptConfiguration(POSHandler.RECEIPT_PRINT_AUTOMATICALLY)
                    .operatorCode("1234")
                    .reference("asd123asd", ReferenceType.REFERENCE_NUMBER)
                    .preauthTransaction(false)
                    .motoTransaction(false)
                    .build());

 

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
    }
});

POSHandler.getInstance().setTransactionClearedListener(new PosTransactionClearedListener() {
    @Override
    public void onComplete(int phStatus) {
	// transaction is cleared and fully completed, terminal is ready for new operations
    }
});

See POS Info statuses for more information

 

Refund


With Refund, the 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.openRefundActivity(
        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 an optional parameter and can be set as null.

            POSHandler.getInstance().refund(RefundParams.builder()
                    .refundAmount("13.37")
                    .currency("EUR")
                    .receiptConfiguration(POSHandler.RECEIPT_PRINT_AUTOMATICALLY)
                    .motoTransaction(false)
                    .build());

 

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
    }
});

POSHandler.getInstance().setTransactionClearedListener(new PosTransactionClearedListener() {
    @Override
    public void onComplete(int phStatus) {
	// transaction is cleared and fully completed, terminal is ready for new operations
    }
});

See POS Info statuses for more information

 

Pre-authorization


Make a Pre-authorization via direct SDK method. This will lock the funds from the client's account until the pre-authorization is completed or cancelled.

            POSHandler.getInstance().purchase(PaymentParams.builder()
                    .productAmount("13.37")
                    .currency("EUR")
                    .tipAmount("1.55")
                    .receiptConfiguration(POSHandler.RECEIPT_PRINT_AUTOMATICALLY)
                    .operatorCode("1234")
                    .reference("asd123asd", ReferenceType.REFERENCE_NUMBER)
                    .preauthTransaction(true)
                    .motoTransaction(false)
                    .build());

 

Pre-authorization completion


Make a Pre-authorization completion via direct SDK method. This will take the funds from the client's account.

            POSHandler.getInstance().preAuthCompletion(PreauthorizationCompletionParams.builder()
                    .preauthorizationCode("1111")
                    .productAmount("13.37")
                    .build());

 

Pre-authorization cancellation


Make a Pre-authorization cancellation via direct SDK method. This will unlock the funds from the client's account and they can no longer be received with a Completion transaction.

            POSHandler.getInstance().preAuthCancellation(PreauthorizationCancellationParams.builder()
                    .preauthorizationCode("1111")
                    .build());

 

MO/TO payment


Make a MO/TO payment via direct SDK method.

            POSHandler.getInstance().purchase(PaymentParams.builder()
                    .productAmount("13.37")
                    .currency("EUR")
                    .tipAmount("1.55")
                    .receiptConfiguration(POSHandler.RECEIPT_PRINT_AUTOMATICALLY)
                    .operatorCode("1234")
                    .reference("asd123asd", ReferenceType.REFERENCE_NUMBER)
                    .preauthTransaction(false)
                    .motoTransaction(true)
                    .PAN("1234123412341234")
                    .expDate("1022")
                    .build());

 

MO/TO refund


Make a MO/TO refund via direct SDK method.

            POSHandler.getInstance().refund(RefundParams.builder()
                    .refundAmount("13.37")
                    .currency("EUR")
                    .receiptConfiguration(POSHandler.RECEIPT_PRINT_AUTOMATICALLY)
                    .motoTransaction(true)
                    .PAN("1234123412341234")
                    .expDate("1022")
                    .build());

 

Void


Void and reverse the last transaction via direct SDK method.

            POSHandler.getInstance().reversal(ReversalParams.builder()
                    .reason("enter reason text")
                    .build());

 

Reprint last receipt


With this method, the host application could request a reprint of the 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);