Skip to main content

Atom NEXT API Reference

Version History

VersionDateAuthorNotes
v1.0.02026-03-23Tim LINInitial version.
v1.0.12026-05-09chengxiAdd restful method and change connectionType method.

Table of Contents

Overview

Atom NEXT provides threeintegration layers:

  • Recommended: use the AtomNext helper class (AIDL by default, with optional NET socket mode or restful mode)
  • Low-level: bind directly to IAtomNext.aidl

All requests and results use Android Bundle. Results are returned asynchronously through callbacks.


1) Initialize

AtomNext.me(context).init(param, listener)

  • Success callback: AtomNextListener.onSuccess()
  • Failure callback: AtomNextListener.onError(errorCode)

2) Start a transaction

AtomNext.me(context).transact(params, transactionListener)

  • Completion callback: TransactionListener.onTransactionResult(resultBundle)
  • Interactive callback: TransactionListener.onInteractiveCallback(callbackBundle) (optional)

3) Release

AtomNext.me(context).release()


init(param: Bundle?, listener: AtomNextListener): Unit

Initializes Atom NEXT connectivity.

Syntax

  • AtomNext.me(context).init(param, listener)

Parameters

  • param (Bundle?): optional initialization bundle.
    • connectionType (Int): 0 (AIDL, default) or 1 (Socket) or 2 (Restful)
    • remoteIp (String): required when connectionType=1 or connectionType=2
    • remotePort (Int): optional when connectionType=1 or connectionType=2, default 5000
  • listener (AtomNextListener): initialization callbacks.

Returns

  • Unit (asynchronous result via callbacks).

Throws

  • No direct exception is exposed by this helper method.

Callbacks

  • onSuccess(): initialization completed.
  • onError(error: Int): initialization failed or service disconnected.

Notes

  • In AIDL mode, service binding target is atomnext-api-service in package com.landiglobal.atomnext.
  • In NET mode, connectivity errors are reported through onError.

transact(params: Bundle, listener: TransactionListener): Unit

Starts a transaction request.

Syntax

  • AtomNext.me(context).transact(params, listener)

Parameters

  • params (Bundle): transaction input bundle; must include transName.
  • listener (TransactionListener): transaction callbacks.

Returns

  • Unit (asynchronous result via onTransactionResult).

Throws

  • No direct exception is exposed by this helper method.

Callbacks

  • onTransactionResult(result: Bundle): final transaction result.
  • onInteractiveCallback(result: Bundle): Bundle?: optional interactive callback for two-way interaction.

Notes

  • If initialization is not completed, callback returns result = ERROR_INITIALIZE.
  • AIDL mode forwards to remote IAtomNext.transact(...).
  • NET mode converts Bundle to JSON and sends via socket.

release(): Unit

Releases resources.

Syntax

  • AtomNext.me(context).release()

Parameters

  • None.

Returns

  • Unit.

Throws

  • No direct exception is exposed by this helper method.

Notes

  • In AIDL mode, the client calls remote finalize(Bundle()).
  • The client unbinds the service and clears local service reference state.

API Methods (AIDL Layer)

initialize(in Bundle bundle, IBinder appBinder, TransactionListener listener): void

Initializes the remote Atom NEXT service.

Syntax

  • void initialize(in Bundle bundle, IBinder appBinder, TransactionListener listener)

Parameters

  • bundle: initialization bundle
  • appBinder: caller binder token
  • listener: AIDL transaction listener
    • onTransactionFinished(in Bundle result): init result callback
    • onInteractiveCallback(in Bundle callback): Bundle: optional interactive callback

Returns

  • void (asynchronous initialization result is returned through onTransactionFinished).

Throws

  • RemoteException (at caller side, as part of Binder IPC contract).

finalize(in Bundle bundle): void

Finalizes and releases service-side resources for the caller.

Syntax

  • void finalize(in Bundle bundle)

Parameters

  • bundle: finalize options bundle (currently not consumed by implementation).

Returns

  • void.

Throws

  • RemoteException (at caller side, as part of Binder IPC contract).

transact(in Bundle bundle, TransactionListener listener): void

Starts a transaction on service side and returns asynchronous result through listener.

Syntax

  • void transact(in Bundle bundle, TransactionListener listener)

Parameters

  • bundle: transaction request bundle.
  • listener: callback listener for final/interactive responses.

Returns

  • void (transaction result is asynchronous).

Throws

  • RemoteException (at caller side, as part of Binder IPC contract).

Service binding info (AIDL):

  • action: atomnext-api-service
  • package: com.landiglobal.atomnext

Bundle Keys (KeyConst)

All keys below are literal values used in Android Bundle.

Init Bundle

KeyTypeRequiredDescription
connectionTypeIntNoConnection type: 0=AIDL (default), 1=SOCKET, 2=RESTFUL
remoteIpStringConditionalRequired when connectionType=1 or connectionType=2
remotePortIntNoserver port, default 5000 when connectionType=1 or 9000 when connectionType=2

Transaction Request Bundle

KeyTypeRequiredDescription
transNameStringYesTransaction name; see InvokeTransName values below
amountStringConditionalTransaction amount (usually 12-digit numeric string). Validation depends on transaction type
customizedTraceNoStringNoThird-party custom trace number
additionalPrintDataStringNoAdditional print data
merchantIdStringNoMerchant ID; if absent/invalid, implementation selects first available merchant
maskedCardNoBooleanNoWhether PAN in callback should be masked; default true
oldTraceNoStringConditionalOriginal trace number (used by void-related flows)
oldReferenceNoStringConditionalOriginal reference number (used by refund flow)
oldAuthCodeStringConditionalOriginal authorization code
oldDateStringConditionalOriginal transaction date (MMdd)
oldVoucherNoStringConditionalOriginal voucher number
needManagerPwdBooleanNoWhether manager password is required for invoke transaction

Result Bundle

KeyTypeAlways PresentDescription
resultIntYesResult code; see Error Codes
errorMsgStringNoError description when failed
amountStringNoTransaction amount
traceNoStringNoTransaction trace number
voucherNoStringNoVoucher number
referenceNoStringNoReference number
authCodeStringNoAuthorization code
cardNoStringNoCard number (masked/unmasked based on maskedCardNo)
cardOrgStringNoCard organization
acquirerIdentifierStringNoAcquirer identifier
batchNoStringNoBatch number
terminalIdStringNoTerminal ID
merchantIdStringNoMerchant ID
merchantNameStringNoMerchant name
dateStringNoDate (MMdd)
timeStringNoTime (HHmmss)
balanceStringNoBalance result (for balance inquiry)
merchantInfoListArrayList<Bundle>NoMerchant info list (for TRANS_GET_MERCHANT_INFO_LIST)

transName Values (InvokeTransName)

Use the exact string values below:

ValueMeaningTypical Required Keys
CONSUMESaletransName, amount
VOIDVoid saletransName, oldTraceNo (typical)
BALANCEBalance inquirytransName
SETTLESettlementtransName
MANAGEManagement menutransName
REFUNDRefundtransName (often with one of amount / oldReferenceNo / oldDate)
LOGINSign-intransName
REPRINTReprinttransName
INIT_PRINTPrinter initializationtransName
PARAMETERTerminal parameterstransName
SYSTEM_PASSWORDSystem administrator passwordtransName
QUERY_MENUTransaction query menutransName
SCAN_SALEScan saletransName, amount
SCAN_VOIDScan voidtransName
SCAN_REFUNDScan refundtransName (often with amount)
AUTHPre-authorizationtransName, amount
AUTH_VOIDPre-auth voidtransName
AUTH_COMPLETEPre-auth completion (request)transName
AUTH_SETTLEMENTPre-auth settlement (notification)transName
AUTH_COMPLETE_VOIDPre-auth completion voidtransName, oldTraceNo (typical)
SCAN_AUTH_VOIDScan pre-auth voidtransName
SCAN_AUTH_COMPLETE_VOIDScan pre-auth completion voidtransName
TRANS_GET_MERCHANT_INFO_LISTGet merchant info listtransName

Validation Matrix (Current Implementation)

Validation rules are implemented in InvokeController.checkOnBeforeStartTrans().

Rule ItemApplies ToValidation RuleError Code on Failure
transNameAll transactionsMust be non-empty and in supported InvokeTransName listERROR_OTHER
amount formatCONSUME, AUTH, SCAN_SALE, REFUND, SCAN_REFUND (when present)Must match ^[0-9]{12}$ERROR_INVALID_AMOUNT
amount > 0CONSUME, AUTH, SCAN_SALE, REFUND, SCAN_REFUND (when present)Must be greater than zeroERROR_INVALID_AMOUNT
amount max limitAny transaction with amount presentMust pass checkAmountValidERROR_INVALID_AMOUNT
oldTraceNo formatVOID, AUTH_COMPLETE_VOID (when present)Must match ^[0-9]{6}$ERROR_ORIGINAL_TRANS_NOT_EXIST
oldReferenceNo formatREFUND (when present)Must match `^[0-9a-z
oldDate formatREFUND (when present)Must match ^[0-9]{4}$ (MMdd)ERROR_INVALID_OLD_DATE
oldDate validityREFUND (when present)Must be a valid calendar date in MMddERROR_INVALID_OLD_DATE

Implementation notes:

  • Most key validations are validate-if-present; transaction business flow may still require additional fields.
  • TRANS_GET_MERCHANT_INFO_LIST returns merchantInfoList on success.

Result Callback Fields

Common

Always check:

  • result: result code
  • errorMsg: error description on failure (may be empty)

Error Codes (Errors)

NameValue
SUCCESS0
ERROR_OTHER-1
ERROR_INITIALIZE-2
ERROR_SELF_DETECTING-3
ERROR_CANCELLED-4
ERROR_TIMEOUT-5
ERROR_PARAM-6
ERROR_SAVING_DATA-7
ERROR_COMMUNICATION-8
ERROR_ORIGINAL_TRANS_NOT_EXIST-9
ERROR_REFUND_AMOUNT_EXCEED-10
ERROR_INVALID_AMOUNT-11
ERROR_INVALID_OLD_REF_NO-12
ERROR_INVALID_OLD_DATE-13
ERROR_INVALID_OUT_TRACE_NO-14
ERROR_BIND_FAIL0x01
ERROR_SERVICE_DIED0x02
ERROR_REMOTE_EXCEPTION0x03
ERROR_SERVER_CONNECTION0x04
ERROR_SERVER_DISCONNECTED0x05

Kotlin Example

val initBundle = Bundle().apply {
putInt("connectionType", 0) // 0:AIDL, 1:NET
}

AtomNext.me(context).init(initBundle, object : AtomNextListener {
override fun onSuccess() {
val params = Bundle().apply {
putString("transName", "CONSUME")
putString("amount", "000000001000")
putBoolean("maskedCardNo", true)
}
AtomNext.me(context).transact(params, object : TransactionListener {
override fun onTransactionResult(result: Bundle) {
val code = result.getInt("result")
val error = result.getString("errorMsg")
// handle by result code
}
})
}

override fun onError(error: Int) {
// initialization failure handling
}
})

Best Practices

  • Wait for init() success callback before calling transact()
  • Always check result; never assume success
  • Pass only fields required by the current transaction
  • Keep masked PAN by default (maskedCardNo=true)
  • Call release() when your component is destroyed or no longer needs Atom NEXT

External Call Examples (Non-AIDL)

These examples demonstrate how external clients (e.g., a Windows PC or another Android device) can interact with Atom NEXT services over the network.

1. RESTful API Example (CURL)

The RESTful service listens for POST requests. In Windows CMD, you must escape double quotes with a backslash \".

Transaction Request (Consume)

  • URL: http://{DEVICE_IP}:5000/api/v1/transact
  • Method: POST
  • Body: JSON
curl -X POST http://172.26.110.38:9000/api/v1/transact ^
-H "Content-Type: application/json" ^
-d "{\"transName\": \"CONSUME\", \"amount\": \"000000001000\"}"

Initialization

  • URL: http://{DEVICE_IP}:5000/api/v1/init
curl -X POST http://172.26.110.38:9000/api/v1/init -H "Content-Type: application/json" -d "{}"

2. Socket Example (Kotlin/JVM)

The Socket service expects a JSON string. The connection is typically closed by the server after the response is sent.

import java.net.Socket
import java.io.InputStream
import java.io.OutputStream

fun callSocketTransaction(ip: String, port: Int) {
try {
Socket(ip, port).use { socket ->
val output: OutputStream = socket.getOutputStream()
val input: InputStream = socket.getInputStream()

// 1. Prepare Request JSON
val requestJson = """
{
"transName": "CONSUME",
"amount": "000000001000",
"maskedCardNo": true
}
""".trimIndent()

// 2. Send Data
output.write(requestJson.toByteArray(Charsets.UTF_8))
output.flush()

// 3. Read Response
val buffer = ByteArray(4096)
val bytesRead = input.read(buffer)
if (bytesRead != -1) {
val responseJson = String(buffer, 0, bytesRead, Charsets.UTF_8)
println("Response from POS: ${responseJson}")
}
}
} catch (e: Exception) {
e.printStackTrace()
}
}

3. RESTful Example (Android/Kotlin)

This standard implementation uses HttpURLConnection. In a real production app, consider using libraries like OkHttp or Retrofit.

import java.io.OutputStreamWriter
import java.net.HttpURLConnection
import java.net.URL
import java.util.Scanner

fun callRestApi(ip: String, port: Int, transName: String, amount: String) {
Thread {
try {
val url = URL("http://${ip}:${port}/api/v1/transact")
val conn = url.openConnection() as HttpURLConnection
conn.requestMethod = "POST"
conn.setRequestProperty("Content-Type", "application/json")
conn.doOutput = true
conn.connectTimeout = 5000
conn.readTimeout = 65000 // Transactions may take time

// 1. Send Request
val jsonInput = "{\"transName\": \"${transName}\", \"amount\": \"${amount}\"}"
conn.outputStream.use { os ->
OutputStreamWriter(os, "UTF-8").use { writer ->
writer.write(jsonInput)
writer.flush()
}
}

// 2. Read Response
val responseCode = conn.responseCode
val responseStream = if (responseCode == HttpURLConnection.HTTP_OK) {
conn.inputStream
} else {
conn.errorStream
}

Scanner(responseStream, "UTF-8").useDelimiter("\\A").use { s ->
val result = if (s.hasNext()) s.next() else ""
println("HTTP Response (${responseCode}): ${result}")
}

} catch (e: Exception) {
e.printStackTrace()
}
}.start()
}

Protocol Notes

  • Encoding: All JSON strings should be encoded in UTF-8.
  • Port Management: Default ports are configured via ThirdPartyApiServer. Standard is 5000.
  • Timeouts: Ensure your client has a sufficient timeout (at least 60 seconds) as financial transactions involve hardware interaction and user input.