Working with terminals
Learn how to integrate with physical terminals, build your own POS, or use deep links to trigger payments.
Overview
Reservepay API allows you to accept in-person payments using physical hardware. You can integrate with terminals in two ways:
- Build your own Point of Sale (POS) system that communicates directly with our Terminal API.
- Use our terminal app on your device and trigger actions via deep links from your own mobile application.
Direct API integration
If you are building your own POS software, you can use the Reservepay Terminal API to manage device connections and the Reservepay Merchant API to trigger payments on those devices.
1. Connect a device
First, bind your physical device to a terminal defined in your dashboard.
curl -X POST https://api.reservepay.com/terminals/connect-device \
-H "Content-Type: application/json" \
-d '{
"merchant_id": "mer_686790162102",
"terminal_id": "trm_U4vfjCFwwK",
"device_id": "550e8400-e29b-41d4-a716-446655440000"
}'
2. Start a payment
To trigger a payment on a connected terminal, use the start-payment-on-terminal endpoint from the Merchant API.
curl -X POST https://api.reservepay.com/merchants/start-payment-on-terminal \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"terminal_id": "trm_U4vfjCFwwK",
"amount": 1000,
"currency": "THB",
"payment_method": "CARD"
}'
3. Receive real-time events (SSE)
To receive real-time updates from the terminal (such as payment completion or status changes), your POS should listen to our Server-Sent Events (SSE) stream.
Connect to the following endpoint using your device_id:
https://rt.reservepay.com/terminals/550e8400-e29b-41d4-a716-446655440000
Currently, the stream supports the following events:
start_terminal_payment: Triggered when a payment is initiated on the terminal.abort_terminal_payment: Triggered when a payment process is cancelled.
Example using JavaScript:
const deviceId = '550e8400-e29b-41d4-a716-446655440000';
const eventSource = new EventSource(`https://rt.reservepay.com/terminals/${deviceId}`);
eventSource.onmessage = (event) => {
const data = JSON.parse(event.data);
console.log('Received terminal event:', data);
};
eventSource.addEventListener('start_terminal_payment', (event) => {
const data = JSON.parse(event.data);
console.log('Payment started:', data);
});
eventSource.addEventListener('abort_terminal_payment', (event) => {
const data = JSON.parse(event.data);
console.log('Payment aborted:', data);
});
eventSource.onerror = (error) => {
console.error('SSE connection failed:', error);
};
Mobile app integration (deep links)
For a simpler integration, you can use the Reservepay Terminal app and trigger actions using our custom URL scheme: reservepay-terminal://. A payment started this way can report its result back to your app in two ways:
- Start for a result (Android). Open the link with
startActivityForResult. Terminal returns the result withsetResultand closes, so the customer lands back on your screen. - Callback URL (iOS and Android). Add a
callback_urlto the link. When the payment ends, Terminal opens that URL with the result as query parameters.
Both use the same link and return the same fields. If you use neither, Terminal still takes the payment but sends nothing back.
Start a payment
reservepay-terminal://start-payment?amount=1100¤cy=THB&payment_method=PROMPTPAY&external_id=POS20261110174105123
| Parameter | Required | Description |
|---|---|---|
amount |
Yes | Amount in the smallest currency unit, as a positive whole number. 1100 is 11.00 THB. |
currency |
Yes | ISO 4217 code, for example THB. |
payment_method |
No | A payment method enabled for the terminal, for example PROMPTPAY, ALIPAY, WECHAT, CARD_PRESENT or NTT_APP. Case-insensitive. If you leave it out, the cashier picks the method on Terminal. |
external_id |
No | Your reference for this payment, such as an order or invoice number. It's returned with the result and becomes the payment's external_id in Reservepay, so it follows the external ID format and must be unique: use a new external_id for every payment attempt. |
callback_url |
No | Where Terminal sends the result when you don't start it for a result. Must be a custom app scheme with ://, for example myposapp://payment-result. Web (http, https) and system schemes are refused. |
Terminal handles one payment at a time. A link that arrives while a payment is in progress, or while the result of a previous linked payment is still on screen, gets no result (in the second case Terminal returns that previous result first). Wait for the result of the first payment before you send the next link.
What the cashier sees
Terminal skips the amount screen and opens the payment straight away:
| Link | Terminal opens |
|---|---|
With payment_method |
That payment method's screen, for example the PromptPay QR or the card reader prompt. |
Without payment_method |
Select payment method, with your amount already filled in. If the cashier goes back from there, the result is USER_CANCELLED. |
| Invalid, or Terminal not set up | An error message. The result is FAILED with invalid_request or terminal_not_ready. |
When the payment ends, Terminal shows its result screen. If you start Terminal for a result or send a callback_url, that screen has a link that takes the cashier straight back to your app with the result: Back to merchant app when started for a result, or Back to {merchant name} with a callback_url (the merchant name set up for the terminal in your Reservepay Dashboard). Without either, the cashier returns to your app on their own.
Get the result: start for a result (Android)
Open the link with startActivityForResult (or registerForActivityResult) and read the result in your activity:
const val PAY_REQUEST = 1001
val uri = Uri.parse(
"reservepay-terminal://start-payment?amount=1100¤cy=THB&payment_method=PROMPTPAY&external_id=POS20261110174105123"
)
startActivityForResult(Intent(Intent.ACTION_VIEW, uri), PAY_REQUEST)
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data)
if (requestCode != PAY_REQUEST) return
if (resultCode != Activity.RESULT_OK || data == null) {
// The cashier left Terminal before it finished: look the payment up by your external_id.
return
}
val status = data.getStringExtra("status") // SUCCESSFUL, FAILED, EXPIRED or USER_CANCELLED
val paymentId = data.getStringExtra("payment_id")
}
- Don't add
FLAG_ACTIVITY_NEW_TASK(or any other flag). Terminal must open in your app's task to be able to return the result. With that flag, Android answersRESULT_CANCELEDimmediately. - Every result field is a
Stringextra (see Result fields). RESULT_CANCELEDwith no extras means the cashier left Terminal before it reached the payment screen, so no result was reported. Once Terminal is on the payment screen, leaving givesUSER_CANCELLEDinstead. Either way, look the payment up by yourexternal_idif you need to be sure.- If more than one app on the device handles
reservepay-terminal://, you can callsetPackage("com.reservepay.terminal")on the intent to skip the app chooser.
Get the result: callback URL (iOS and Android)
Add callback_url to the link and open it as usual (openURL on iOS, startActivity on Android):
reservepay-terminal://start-payment?amount=1100¤cy=THB&payment_method=PROMPTPAY&external_id=POS20261110174105123&callback_url=myposapp%3A%2F%2Fpayment-result
When the payment ends, Terminal opens your callback URL with the result fields added as query parameters. Any parameters already on your URL are kept:
myposapp://payment-result?status=SUCCESSFUL&external_id=POS20261110174105123&payment_id=pay_01JD3K8M2N4P6Q8R&payment_session_id=pse_01JD3K8KZ5V7W9X1&amount=1100¤cy=THB&payment_method=PROMPTPAY&terminal_id=trm_U4vfjCFwwK&ref2=014567890123&created_at=1794482950&captured_at=1794483000
- Register the scheme in your app (an
intent-filteron Android,CFBundleURLTypeson iOS). On Android, theintent-filtermust include theandroid.intent.category.BROWSABLEcategory, as for any link opened from outside your app. Let the activity that started the payment receive the callback, withlaunchModesingleTop, so your existing screen is reused instead of a new one being stacked. - If your app starts Terminal for a result and also sends
callback_url, only thesetResultresult is sent. - The callback is a URL, so any app could open it with made-up values. Confirm the payment as described in Confirm the payment before you fulfill the order.
Result fields
All values are strings. A field is left out when it has no value, so only status is guaranteed. If a field you need is missing, look the payment up with find-payment.
status is what Terminal showed on its result screen:
status |
Meaning |
|---|---|
SUCCESSFUL |
The payment went through. |
FAILED |
The payment failed, or the request was refused before it started. See error_code. |
EXPIRED |
The customer didn't pay the QR code in time. |
USER_CANCELLED |
The cashier cancelled, or left before the payment finished. When payment_id is present, a QR code may still be paid until it expires, so confirm the payment before you treat it as unpaid. |
| Field | When | Description |
|---|---|---|
status |
Always | See the table above. |
external_id |
When you sent one | Your external_id, unchanged. |
payment_id |
When a payment was created | The Reservepay payment ID, for example pay_01JD3K8M2N4P6Q8R. Use it with find-payment. |
payment_session_id |
When a payment was created | The payment session ID. |
amount |
When you sent one | The requested amount, in the smallest currency unit. |
currency |
When you sent one | The requested currency. |
payment_method |
When known | The method actually used, or the one the cashier picked. If the payment didn't start, the value you sent. |
terminal_id |
When the terminal is set up | The Reservepay terminal that took the payment, for example trm_U4vfjCFwwK. |
error_code |
FAILED |
Why it failed. See Error codes. |
error_message |
FAILED |
A short, human-readable detail for your logs. It may change, so don't branch on it. |
ref2 |
SUCCESSFUL, when available |
The payment's ref2 in Reservepay, the same value find-payment returns. |
created_at |
SUCCESSFUL QR (for example PROMPTPAY) and NTT_APP payments, when available |
When the payment was created, as a Unix timestamp in seconds, for example 1794482950. |
authorized_at |
SUCCESSFUL QR and CARD_PRESENT payments, when available |
When the payment was authorized, as a Unix timestamp in seconds. |
captured_at |
SUCCESSFUL QR and CARD_PRESENT payments, when available |
When the payment was captured, as a Unix timestamp in seconds, for example 1794483000. |
approval_code |
SUCCESSFUL CARD_PRESENT and NTT_APP payments |
The card authorization code. |
masked_card_no |
SUCCESSFUL CARD_PRESENT and NTT_APP payments |
The masked card number, for example 411111******1111. |
card_network |
SUCCESSFUL CARD_PRESENT and NTT_APP payments |
Lowercase, for example visa or mastercard. |
Example: PromptPay
status=SUCCESSFUL
external_id=POS20261110174105123
payment_id=pay_01JD3K8M2N4P6Q8R
payment_session_id=pse_01JD3K8KZ5V7W9X1
amount=1100
currency=THB
payment_method=PROMPTPAY
terminal_id=trm_U4vfjCFwwK
ref2=014567890123
created_at=1794482950
captured_at=1794483000
Example: card present
status=SUCCESSFUL
external_id=POS20261110174105124
payment_id=pay_01JD3KC2D4F6G8H0
payment_session_id=pse_01JD3KC1T3V5X7Z9
amount=1100
currency=THB
payment_method=CARD_PRESENT
terminal_id=trm_U4vfjCFwwK
approval_code=A1B2C3
masked_card_no=411111******1111
card_network=visa
ref2=631612345678
authorized_at=1794482998
captured_at=1794483000
Example: declined card
status=FAILED
external_id=POS20261110174105125
payment_id=pay_01JD3KF5H7J9K1M3
payment_session_id=pse_01JD3KF4W6Y8A0C2
amount=1100
currency=THB
payment_method=CARD_PRESENT
terminal_id=trm_U4vfjCFwwK
error_code=declined
error_message=Payment was declined
Error codes
Each code says what to do next. After a FAILED result, retry with a new external_id.
error_code |
Meaning | What to do |
|---|---|---|
invalid_request |
The link is missing amount or currency, amount, external_id or callback_url is invalid, or the terminal doesn't support currency. |
Fix the link. |
duplicate_ref |
A payment with this external_id already exists. |
Use a new external_id, or look the earlier payment up by its external_id. |
terminal_not_ready |
Terminal isn't connected to a merchant yet. | Set the terminal up first (see Setup a terminal). |
payment_method_unavailable |
payment_method isn't enabled for this terminal or isn't supported on this device. |
Send another method, or leave payment_method out. |
declined |
The card, its issuer or the payment network declined the payment, or a QR payment failed. | Ask the customer for another card or method. |
server_error |
Reservepay returned an error, including a request it refused (for example an amount it doesn't accept). | Retry with a new external_id. If it keeps happening, contact Reservepay with the payment_id if there is one. |
network_error |
Terminal got no answer from Reservepay. If this happened while a card was being charged, Terminal tries to undo the charge. | Check the device's connection. Confirm the payment by external_id before you retry with a new one. |
terminal_error |
The device, its card reader or the card terminal app failed or timed out. | Ask the cashier to check the device. If a card terminal app timed out, the payment may still have gone through, so confirm it before you retry. |
Confirm the payment
status is what Terminal showed on screen. Before you fulfill the order, confirm the payment on your server with find-payment (by payment_id, or by your external_id) or with the payment_completed webhook. Do the same whenever the result is missing, for example after RESULT_CANCELED. Key your records on payment_id rather than external_id: if the cashier retries a card on the same screen, the payment that succeeds is created with a new external_id chosen by Terminal, while the result still echoes yours. A payment's status in Reservepay can still change after Terminal shows it, for example when the bank confirms late (see Payment lifecycle).
Setup a terminal
To quickly configure a terminal on a new device:
reservepay-terminal://setup-terminal?merchant_id=mer_686790162102&terminal_id=trm_U4vfjCFwwK
Terminal management
You can manage your terminals, view their connection status, and update their configuration through the Terminals section in your Reservepay Dashboard.
Dive deeper into these advanced integration topics to unlock Reservepay's full potential with our in-depth guides.
Issue refunds, void transactions before they settle, and reverse authorizations when needed.
Read the guideSeparate authorization from capture to hold funds without charging. Perfect for pre-orders or reservations
Read the guideBuild your own POS, or work with our app by sending commands or using deep links.
Read the guideBuild profiles by attaching customer data. Gain insights, reduce fraud risk, and create experiences that drive loyalty.
Read the guideSend payouts to your primary bank account or to your contacts via bank account, mobile number or national ID.
Read the guideStay informed about payment events with real-time webhooks. Automate your order processing, and more...
Read the guideFilter payments and payouts, export CSVs, read balance holds, and reconcile daily statements.
Read the guideLook up what each Reservepay failure code means when a payment is declined.
Read the guideNo account yet?
Start integrating all these amazing features into your app or website by creating your own merchant account today. It's free to sign up and only takes a few minutes to get started.
