pay
The pay API is called by the POS to create a payment request. Ensure that the payment terminal is ready to receive payment requests before calling this API.
Method signature
When calling this method, please use the following standard method signature format.
fun pay(
payRequest: PayRequest,
options: RequestOptions? = null,
callBack: PayResultListener? = null
)Parameters
Parameter name | Type | Required | Description |
payRequest | Yes | Indicates the object that contains the parameters for creating a payment request. | |
options | No | Indicates the object that contains optional parameters in the API requests. | |
callBack | No | The callback that is used to return the query result. See callback for details. |
callback
Parameter name | Type | Required | Description |
result | No | Indicates the result of the payment. |
Return values
Parameter name | Type | Required | Description |
result | Yes | The result of the API call. | |
paymentId | String | Yes | The unique ID that is defined by a POS provider to identify a payment and consistent with the paymentId in transaction reports. |
paymentReceipt | No | The receipt information that is provided to merchants and buyers after the payment is successful.
copy |
Result codes
resultCode | resultStatus | resultMessage | Further action |
|
| Success. | No action is required. |
|
| A general business failure occurred. Do not retry. | Contact Antom Technical Support to troubleshoot the issue. |
|
| The data format is invalid. | Contact Antom Technical Support to troubleshoot the issue. |
|
| The public key pairing failed. | Contact Antom Technical Support to troubleshoot the issue. |
PARAM_ILLEGAL |
| Parameter names or values do not meet the specified requirements. The result message can vary according to the specific error encountered. | Check whether the request parameters, including the header parameters and body parameters, are correct and valid. |
|
| The payment terminal is not logged in. | Log in to the payment terminal. |
PAYMENT_METHOD_NOT_SUPPORT |
| The payment method is not supported. | Select another payment method. |
|
| The payment terminal is busy. | Try again later. |
|
| The payment failed. | Call the inquryPayment API to query the final payment status. or manually check the payment status on the payment terminal and manually update the payment status on the POS. If the above-mentioned methods do not work, contact Antom Technical Support to troubleshoot the issue. |
|
| The USB connection failed. |
|
|
| Response timeout. | Check whether the payment terminal app is active. If not, activate it again. |
|
| The API call failed, which is caused by unknown reasons. | Call the inquryPayment API with the paymentRequestId to query the final payment status. |
|
| Failed to decrypt the data returned by the payment terminal. | Contact Antom Technical Support to troubleshoot the issue. |
|
| The message format is invalid. | Contact Antom Technical Support to troubleshoot the issue. |
Samples
The following sample code shows how to call the pay API:
PaymentManager.pay(
request,
RequestOptions(120000L),
object : PayResultListener {
override fun result(result: PayResultData) {
findViewById<TextView>(R.id.tv_response).post {
findViewById<TextView>(R.id.tv_response).text = result.toString()
}
}
}
)The following code shows a sample of the response:
{
"result":{
"resultCode": "SUCCESS",
"resultStatus": "S",
"resultMessage": "Success."
},
"paymentId": "201906081140108001001888202003XXXXX",
"paymentReceipt":{
"cashierReceipt": "{\"acquirerMerchantId\":\"0000000001XXXXX\",\"acquirerProcessTime\":\"2025-05-13T13:19:51Z\",\"acquirerTerminalId\":\"911XXXXX\",\"aid\":\"A00000000XXXXX\",\"applicationCryptogram\":\"5AC388057A1XXXXX\",\"applicationLabel\":\"VISA CREDIT\",\"approvalCode\":\"0XXXXX\",\"cardBrand\":\"VISA\",\"cardNo\":\"47617300000XXXXX\",\"cvm\":\"NO_CVM\",\"posEntryMode\":\"CONTACTLESS\",\"rrn\":\"2827948XXXXX\",\"tvr\":\"00000XXXXX\"}",
"customerReceipt": "{\"acquirerMerchantId\":\"0000000001XXXXX\",\"acquirerProcessTime\":\"2025-05-13T13:19:51Z\",\"acquirerTerminalId\":\"911XXXXX\",\"aid\":\"A00000000XXXXX\",\"applicationCryptogram\":\"5AC388057A1XXXXX\",\"applicationLabel\":\"VISA CREDIT\",\"approvalCode\":\"0XXXXX\",\"cardBrand\":\"VISA\",\"cardNo\":\"47617300000XXXXX\",\"cvm\":\"NO_CVM\",\"posEntryMode\":\"CONTACTLESS\",\"rrn\":\"2827948XXXXX\",\"tvr\":\"00000XXXXX\"}"
}
}