Void Request
1. Perform a void transaction
// Build the void transaction
private static final int VOID_REQUEST_CODE = 4;
private void startVoid() {
// Build the void request
MyPOSVoid voidEx = MyPOSVoid.builder()
.STAN(27)
.authCode("VISSIM")
.dateTime("180129123753")
//.voidLastTransactionFlag(true) // this may void last transaction initialized by this terminal
.build();
// Start the void transaction
MyPOSAPI.openVoidActivity(MainActivity.this, voidEx, VOID_REQUEST_CODE, true);
}
2. Handle the result
The same as with the payment, in your calling Activity, override the onActivityResult method to handle the result of the void request:
@Override
ovoid onActivityResult(int requestCode, int resultCode, Intent data) {
o if (requestCode == VOID_REQUEST_CODE) {
o// The transaction was processed, handle the response
oif (resultCode == RESULT_OK) {
o// Something went wrong in the Payment core app and the result couldn't be returned properly
oif (data == null) {
oToast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
oreturn;
o}
oint transactionResult = data.getIntExtra("status", TransactionProcessingResult.TRANSACTION_FAILED);
oToast.makeText(this, "Void transaction has completed. Result: " + transactionResult, Toast.LENGTH_SHORT).show();
o// TODO: handle each transaction response accordingly
oif (transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS) {
o// Transaction is successful
o}
o} else {
o// The user cancelled the transaction
oToast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
o}
o}
}