Void Transactions with myPOS Smart SDK

The Void Request feature allows you to cancel a previously approved transaction using its STAN, authorization code, and timestamp, or by referencing the last transaction directly.

Step 1: Perform Void Transaction

To start a void transaction, build a MyPOSVoid request using either the transaction identifiers or by setting a flag to void the last 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);
   }

You can either specify a specific transaction using STAN, authCode, and dateTime, or set .voidLastTransactionFlag(true) to void the most recent one.

Step 2: Handle the Void Result

Handle the result of the void operation in your onActivityResult() method just like other transactions.

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

Tip: Voiding a transaction is only possible within the allowed timeframe by the acquirer. For best practices, void immediately when errors or cancellations occur in the same session.