Skip to main content

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.
The Terminal C2C SDK for Android enables you to integrate secure payment processing directly into your Android applications. This SDK provides a client-to-client communication interface that allows your POS system to interact with the Terminal Gateway over the local network.
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

What’s new:
  • Activity Lifecycle Management: Introduced TerminalActivityLifecycleObserver interface 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 TerminalAppLauncherCallback interface for custom handling of provider app launch failures
  • Improved Maintainability: Centralized lifecycle and launcher logic for better extensibility across different application contexts
What’s new:
  • Device Connection Observability: Added observeConnection() and connectionState() APIs to monitor real-time connection state changes (CONNECTING, CONNECTED, DISCONNECTED, CONNECTING_FAILED)
  • Error State Observability: Added observeError() and errorState() APIs to track terminal errors in real-time with device context
  • Connection Testing: New testDeviceConnection() method to verify terminal reachability before making requests
What’s new:
  • Fixed casting issue on C2C request payload to improve compatibility and prevent runtime errors.
What’s new:
  • Added Cashup provider support for Indonesian terminals
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.
1

Configure Gradle settings

Add mavenCentral() to your Gradle configuration so Gradle can resolve the SDK artifacts.
Verify mavenCentral() is available in the repository list used by your app module.
2

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:
Replace CLIENT_KEY with your actual client key from the Xendit dashboard.

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.
Required dependency:
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:
Use the generic create method (available without provider dependencies):
You can also specify a device per request instead of setting a default device.

Configuring App for Terminal Device

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:
1

Configure AndroidManifest.xml

Add the Cashup result activity to your AndroidManifest.xml file:
AndroidManifest.xml
The android:exported="true" attribute is required to allow the Cashup system to return results to your application.
2

Configure Application Class

Choose one of the following approaches to configure your Application class:
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.
3

Configure Receipt Printing

Control whether the terminal prints a receipt after a transaction:
This setting allows you to control the default receipt printing behavior for Cashup terminals.

Supported Payment Methods by Provider

When using co.xendit.terminal:id-bri-android dependency:
Payment MethodDescriptionCode Example
Insert CardChip card transactionsBRIPaymentMethod.insertCard
ContactlessTap-to-pay transactionsBRIPaymentMethod.contactless
QRISQR code paymentsBRIPaymentMethod.qris
BrizziE-money card paymentsBRIPaymentMethod.brizzi
BRI terminals support both physical card payments and digital payment methods popular in Indonesia.
Provider-specific payment enums require the corresponding provider dependency. They expose the exact string values expected by each terminal while keeping your code type-safe.
Replace the enum with the provider you integrate: CashupPaymentMethod, NTTPaymentMethod, or SHCPaymentMethod mirror the samples above.

API Usage

Create Payment

Process a payment transaction using the TerminalC2C singleton:
For non-coroutine environments, call TerminalC2C.createPaymentAsync which returns an ActionJob you can cancel if the UI is dismissed. The callback signature is (TerminalResult?, Throwable?).

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:
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)

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 throws TerminalException for terminal-specific errors:

Error Structure

Troubleshooting

For more recovery scenarios across H2H and C2C terminal flows, see the SDK Troubleshooting Guide.

Common Issues and Solutions

Problem: SDK cannot reach the Terminal Gateway service.Solution:
  1. Verify Terminal Gateway service is running locally
  2. Check the terminal device IP address is correct
  3. Verify network connectivity between your app and gateway
Problem: Error indicating no terminal device is configured.Solution: Set a default terminal device before making requests:
Problem: Requests fail with authentication errors.Solutions:
  1. Verify TerminalApp is initialized with correct client key
  2. Check terminal ID matches the configured device
  3. Ensure client key has Terminal C2C permissions
Problem: Network-level errors when communicating with gateway.Solutions:
  1. Check network connectivity
  2. Verify firewall settings allow connections to gateway port
  3. Ensure Terminal Gateway service is accessible
  4. Check terminal device IP address is reachable
Use network debugging tools to verify connectivity between your app and the Terminal Gateway service.

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

1

Find Terminal ID (TID)

Open the BRI FMS app on the terminal device and locate the Terminal ID in the device information section.
BRI terminal showing Terminal ID in FMS app
2

Find IP Address

Open the ECRLink app on the terminal and check the network settings for the IP address.
BRI terminal showing IP address in ECRLink app
Screenshots and UI layouts may vary by firmware or app version. Refer to the latest vendor documentation if the interface differs from these instructions.