Void Transactions

The myPOS Glass SDK provides functionality to void a previously approved transaction. You can either void a specific transaction using its STAN and Auth Code or void the last transaction initiated by the terminal.

1. Perform a Void Transaction

Use the MyPOSVoid builder to create a void request. You must define a unique request code to handle the result later.

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

Note:

  • If you're voiding the last transaction, you can omit STAN, authCode, and dateTime by setting .voidLastTransactionFlag(true).
  • Use the correct format (yyMMddHHmmss) for the dateTime string when voiding by transaction details.

2. Handle the Void Result

Override the onActivityResult() method in your activity to process the result of the void operation:

@Override
	void onActivityResult(int requestCode, int resultCode, Intent data) {
	    if (requestCode == VOID_REQUEST_CODE) {
			// The transaction was processed, handle the response
			if (resultCode == RESULT_OK) {
				// Something went wrong in the Payment core app and the result couldn't be returned properly
				if (data == null) {
					Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
					return;
				}
				int transactionResult = data.getIntExtra("status", TransactionProcessingResult.TRANSACTION_FAILED);

				Toast.makeText(this, "Void transaction has completed. Result: " + transactionResult, Toast.LENGTH_SHORT).show();

				// TODO: handle each transaction response accordingly
				if (transactionResult == TransactionProcessingResult.TRANSACTION_SUCCESS) {
					// Transaction is successful
				}
			} else {
				// The user cancelled the transaction
				Toast.makeText(this, "Transaction cancelled", Toast.LENGTH_SHORT).show();
			}
		}
    }