Batch request

An overview of the Batch request message for Android.

Overview

👉 The Batch request is used to either open a new batch (‘group’ of transactions) or to close an active batch in the ‘viva.com | Terminal’ application. This is especially useful for reporting purposes.

On Android devices (Tap-on-Phone), a batch remains open for 48 hours before automatically being closed and a new one being started (unless the user ends it manually before this time)

The client app must implement a mechanism to send messages using Android intents and URI calls and to receive the result in a custom URI callback.

Batch request

For a typical Batch request, the client app must provide the following information:

Field Description Example Required Card terminal support Max Length Type
scheme The Viva's custom URL scheme, the host and the version. 'vivapayclient://pay/v1' 'viva.com | Terminal' application for Android
merchantKey The merchant's key. For successful validation, should not be empty.
Deprecated: you may pass any value
'SG23323424EXS3' 'viva.com | Terminal' application for Android
appId The client app ID. For successful validation, should not be empty. 'com.example.myapp' 'viva.com | Terminal' application for Android
action Batch. 'batch' 'viva.com | Terminal' application for Android
callback The URI callback that will handle the result. For successful validation, should not be empty. 'mycallbackscheme://result' 'viva.com | Terminal' application for Android
command Specifies the request action.
  • “open” to create a new batch

  • “close” to close the batch
‘open’ 'viva.com | Terminal' application for Android
batchId For “open“ command this parameter is not used.

For “close“ command, if this parameter is provided, Android POS tries to close the batch with this specific UUID. (Optional)
‘d3fdc9c5-2975-4612-bf52-8c43cd2eb1ba’ 'viva.com | Terminal' application for Android No limit (auto-populated with 36 random characters)
batchName For “open“ command, if this parameter is provided it will be used as the batch name. If no value is provided, the batch will be named automatically. (Optional)

For “close“ command, if this parameter is provided, it will be used in order to find an open batch with this name. (Optional)
‘20230401999999’ 'viva.com | Terminal' application for Android

For “close” command, if neither “batchId” nor “batchName” are provided the command will be applied in the current active batch.

If a new batch is opened before the previously opened one is closed, the old one shall be closed and the new one will be opened.

In order to open a new batch, the above information elements must create a URI call, i.e.

String reqStr = "vivapayclient://pay/v1"
		+ "?merchantKey="MY_MERCHANT_KEY"
		+ "&appId=com.example.myapp"
		+ "&action=batch"
		+ "&callback=mycallbackscheme://result"
		+ "&command=open"
		+ "&batchName=20230401999999";

Intent payIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(reqStr));
payIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
payIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(payIntent);

In order to close an active batch, the above information elements must create a URI call, i.e.

String reqStr = "vivapayclient://pay/v1"
		+ "?merchantKey="MY_MERCHANT_KEY"
		+ "&appId=com.example.myapp"
		+ "&action=batch"
		+ "&callback=mycallbackscheme://result"
		+ "&command=close";

Intent payIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(reqStr));
payIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
payIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
startActivity(payIntent);

Batch response

After executing a batch request, the ‘viva.com | Terminal’ application responds with a batch response result to indicate if the batch request has been successful or not

The result is received as a URI in the callback activity intent:

Uri result = getIntent().getData();

The table below summarizes the contents of an approved response.

Field Description Example Card terminal support
callback The URI callback that will handle the result. 'mycallbackscheme://result' 'viva.com | Terminal' application for Android
status The status of the transaction. 'success' 'viva.com | Terminal' application for Android
message A string containing information about the transaction status. 'Batch successfully created!' 'viva.com | Terminal' application for Android
action Batch. 'batch' 'viva.com | Terminal' application for Android
command Specifies the request action.

“open” to create a new batch

“close” to close the batch
‘open’ 'viva.com | Terminal' application for Android
batchId The UUID of the batch that the command was applied on. ‘d3fdc9c5-2975-4612-bf52-8c43cd2eb1ba’ 'viva.com | Terminal' application for Android
batchName The name of the batch that the command was applied on. 20230401999999 'viva.com | Terminal' application for Android

A batch response result for opening a batch looks as follows:

A batch response result for closing a batch looks as follows:

Key to card terminal product categories

To understand the icons used on the above tables, see the below table.

Product category Terminal models Icon
Android Card Terminals Android Card Terminal Ethernet, Android Card Terminal 4G, Mobile Card Terminal Plus, Mobile Card Terminal. Android Card Terminals
'viva.com | Terminal' application for Android Mini Card Reader, Pocket Card Terminal connected via Bluetooth or USB to the 'viva.com | Terminal' application for Android. Android Card Terminals
Linux Card Terminals Countertop, IM20, S900, S800, D200. Linux Card Terminals

Get Support

If you would like to integrate with Viva, or if you have any queries about our products and solutions, please see our Contact & Support page to see how we can help!