Terminal C2C SDK for Android (Kotlin)
The Terminal C2C SDK is a convenience wrapper around the Terminal C2C API. For providers other than BRI and NTT, you can call the Terminal C2C API directly without the SDK. BRI and NTT terminals require either the Gateway App or the C2C SDK as a pre-install.
TerminalC2C is a singleton object that provides both synchronous (suspend) and asynchronous methods for payment operations. It handles HTTP communication with the Terminal Gateway, request serialization, response parsing, and comprehensive error handling.
Version information
v1.2.1 — 13-May-2026
v1.2.1 — 13-May-2026
What’s new:
- Activity Lifecycle Management: Introduced
TerminalActivityLifecycleObserverinterface for reusable activity lifecycle tracking, intent queuing, and dispatch logic - Enhanced Provider App Launching: Refactored Atom and SHC provider app launchers with improved background app launch handling
- Launch Failure Notifications: Added notification mechanism to prompt users when provider app launch fails while app is in background
- Callback Interface: New
TerminalAppLauncherCallbackinterface for custom handling of provider app launch failures - Improved Maintainability: Centralized lifecycle and launcher logic for better extensibility across different application contexts
v1.2.0 — 8-May-2026
v1.2.0 — 8-May-2026
What’s new:
- Device Connection Observability: Added
observeConnection()andconnectionState()APIs to monitor real-time connection state changes (CONNECTING, CONNECTED, DISCONNECTED, CONNECTING_FAILED) - Error State Observability: Added
observeError()anderrorState()APIs to track terminal errors in real-time with device context - Connection Testing: New
testDeviceConnection()method to verify terminal reachability before making requests
v1.1.3 — 26-Apr-2026
v1.1.3 — 26-Apr-2026
What’s new:
- Fixed casting issue on C2C request payload to improve compatibility and prevent runtime errors.
View all versions
View all versions
v1.1.1 — 23-Apr-2026
v1.1.1 — 23-Apr-2026
What’s new:
- Added Cashup provider support for Indonesian terminals
v1.0.0 — 19-Feb-2026
v1.0.0 — 19-Feb-2026
What’s new:
- Added SHC provider support for Malaysian terminals
- Added multiple-provider support enabling apps to handle different terminal types simultaneously
- Enhanced TerminalDevice configuration with provider-specific methods
- Improved terminal selection for apps managing multiple Terminal devices
The SDK follows semantic versioning. Breaking changes will bump the major version number.
Installation
Follow these steps to add the Terminal C2C Android SDK to your project.Configure Gradle settings
Add
mavenCentral() to your Gradle configuration so Gradle can resolve the SDK artifacts.- Modern Approach (Recommended)
- Old Android Project
Add Maven Central to your Gradle settings file:
Verify
mavenCentral() is available in the repository list used by your app module.Add dependencies
Add the required dependencies to your
build.gradle.kts or build.gradle file:Provider-specific dependencies are optional and enable convenient helper methods for creating
TerminalDevice instances. Include only the dependencies for providers you plan to use.Sync your project to download the dependencies.
Getting Started
Before starting, you’ll need an In-Person Payment CLIENT_KEY from the Xendit In-Person Payment team. You will also need the terminal IP address and Terminal ID (TID).Step 1: Initialize Terminal App
Initialize the Terminal App with your client key:Step 2: Add Terminal Providers
For Share Commerce (SHC) and Cashup terminals, make sure the Gateway app is installed on the device. If it is missing, install it from the Gateway download page or contact inpersonpayments@xendit.co for assistance.
- BRI Indonesia
- NTT Thailand
- Cashup Indonesia
- SHC Malaysia
- Multiple Providers
build.gradle.kts
BRI provider supports timeout configuration for card and QR transactions, and provides enhanced transaction retry capabilities.
Provider dependencies are optional. You can use the generic
TerminalDevice.create() method without adding provider-specific dependencies. Provider frameworks enable access to specialized helper methods like TerminalDevice.bri(), TerminalDevice.ntt(), and TerminalDevice.cashup().Step 3: Configure Terminal Device
Set up your terminal device configuration using the Terminal ID (TID) and IP address:- Generic Method
- Provider-Specific Methods
- Multiple Terminal Devices
Use the generic
create method (available without provider dependencies):Configuring App for Terminal Device
- Cashup Indonesia
- SHC Malaysia
When running your application on a Terminal device, additional configuration is required to enable the terminal to communicate with the Cashup payment system. Follow these steps:
Configure AndroidManifest.xml
Add the Cashup result activity to your
AndroidManifest.xml file:AndroidManifest.xml
Configure Application Class
Choose one of the following approaches to configure your Application class:
- Extend TerminalApplication
- Use TerminalAppLauncherCallback
Make your
Application class extend TerminalApplication and configure the Cashup provider launcher:Application.kt
Don’t forget to register your custom
Application class in the AndroidManifest.xml:AndroidManifest.xml
Your app is now configured to run on Cashup Terminal devices and can communicate with the Cashup payment system.
Supported Payment Methods by Provider
- BRI Terminals
- Cashup Terminals
- NTT Terminals
- SHC Terminals
When using
co.xendit.terminal:id-bri-android dependency:| Payment Method | Description | Code Example |
|---|---|---|
| Insert Card | Chip card transactions | BRIPaymentMethod.insertCard |
| Contactless | Tap-to-pay transactions | BRIPaymentMethod.contactless |
| QRIS | QR code payments | BRIPaymentMethod.qris |
| Brizzi | E-money card payments | BRIPaymentMethod.brizzi |
BRI terminals support both physical card payments and digital payment methods popular in Indonesia.
API Usage
Create Payment
Process a payment transaction using the TerminalC2C singleton:Simulation Testing
Use simulation mode to validate your integration without connecting to a physical terminal.Disable simulation (
TerminalC2C.isSimulation = false and isSimulation = false) before running against real hardware. Use the special simulation amounts (400508 decline, 400509 unavailable, 400711 cancel) documented in the quickstart to trigger test scenarios.Cancel Payment
Cancel an ongoing payment transaction:Print Receipt
Trigger receipt printing on the terminal:Perform Settlement
Initiate a settlement (batch close) process:Get Transaction History
Retrieve transaction history from the terminal:Async API Usage
For interoperability with Java or callback-based code, use the async methods:Create Payment (Async)
Cancel Payment (Async)
Print Receipt (Async)
Perform Settlement (Async)
Get History (Async)
Configuration and Management
Test Device Connection
Check if the terminal device is reachable before making requests:Observe Error State (Flow)
Listen for error updates using Kotlin Flow:Observe Connection State (Flow)
Monitor connection state changes:Observe Error and Connection with Callbacks
For callback-based observation (Java interoperability):Error Handling
TerminalException
The SDK throwsTerminalException for terminal-specific errors:
Error Structure
Troubleshooting
Common Issues and Solutions
Cannot Connect to Terminal Gateway
Cannot Connect to Terminal Gateway
Problem: SDK cannot reach the Terminal Gateway service.Solution:
- Verify Terminal Gateway service is running locally
- Check the terminal device IP address is correct
- Verify network connectivity between your app and gateway
No Terminal Device Provided
No Terminal Device Provided
Problem: Error indicating no terminal device is configured.Solution: Set a default terminal device before making requests:
Authentication Failed
Authentication Failed
Problem: Requests fail with authentication errors.Solutions:
- Verify TerminalApp is initialized with correct client key
- Check terminal ID matches the configured device
- Ensure client key has Terminal C2C permissions
Network Errors
Network Errors
Problem: Network-level errors when communicating with gateway.Solutions:
- Check network connectivity
- Verify firewall settings allow connections to gateway port
- Ensure Terminal Gateway service is accessible
- Check terminal device IP address is reachable
Best Practices
Error Handling
Always implement comprehensive error handling:Device Management
Set up terminal device once during app initialization:Coroutine Scope Management
Use appropriate coroutine scopes for async operations:Finding Terminal Information
- BRI Terminals
- NTT Terminals
- Cashup Terminals
- Atom Terminals
Screenshots and UI layouts may vary by firmware or app version. Refer to the latest vendor documentation if the interface differs from these instructions.







