This migration involves significant architectural changes. We recommend testing thoroughly in your development environment before deploying to production.
Overview of Changes
The new architecture separates the concerns of direct terminal communication (handled by the Terminal H2H SDK) and payment session management (handled by the Terminal API (H2H)). This provides a more unified approach for different terminal providers and better integration with the Xendit In-Person Payment platform. Key Changes:- SDK Consolidation: The
XenBriTerminalSDK is replaced by theTerminal H2H SDK, which acts as a common interface for various terminal providers (e.g.,TerminalBRI). - API for Payment Sessions: Instead of direct
saleIntentcalls from the SDK, payment sessions are now managed via the Terminal API (H2H). - Simplified Connection Management: Device registration and connection state observation are now handled more uniformly through
TerminalH2H. - Unified Error Handling: Error codes are standardized across the Terminal H2H SDK.
Migration Steps
Update SDK Dependencies
Remove the old New Dependencies (to add):Also, ensure your project’s
Xen BRI SDK dependency and add the new Terminal H2H SDK dependencies in your module’s build.gradle file.Old Dependency (to remove):build.gradle or settings.gradle has the maven local repository:Initialize the SDK
The initialization process changes from New Initialization:
XenBriTerminal.initialize() to TerminalApp.initialize() and TerminalH2H.addProvider().Old Initialization:Client Key: Note that for the Terminal API (H2H), you will need an
API_KEY from the Xendit In-Person Payment team, which is different from the CLIENT_KEY used in the SDK initialization. The TerminalApp.initialize still uses a CLIENT_KEY.TerminalMode: The
XenTerminalMode enum is replaced by TerminalMode. Use TerminalMode.INTEGRATION for testing with physical terminals and TerminalMode.LIVE for production. TerminalMode.SIMULATION is no longer available directly in the TerminalApp.initialize method; instead, you would create payment sessions with appropriate simulation parameters via the Terminal API (H2H) if needed.Register Terminal Devices
Instead of New Device Registration:Registration errors (such as authentication failures) are emitted through
XenBriTerminal.useWifi() or XenBriTerminal.useBluetooth(), you now register devices using TerminalH2H.registerDevices().Old Device Connection (Example for WiFi):observeError. For obtaining TID and IP address for BRI terminals, continue using the BRI FMS App for TID and the ECRLink app for IP address.Create Payment Transactions
The New Payment Creation (High-Level Flow):
saleIntent method is replaced by a two-step process:- Create a Payment Session via Terminal API (H2H): Your backend (or a direct API call from your app if applicable) initiates a payment session with the Xendit’s Payment Terminal API (H2H).
- The SDK will then handle the interaction with the physical terminal to process the payment based on the created session.
- Your Application/Backend (using Terminal API (H2H)):
- Make a POST request to
/v1/terminal/sessionsto create a payment session. - Endpoint:
https://terminal-dev.xendit.co(Development) orhttps://terminal.xendit.co(Live) - Headers:
Content-Type: application/jsonAuthorization: Basic <Base64Encode(API_KEY:)>Idempotency-key: A unique key for preventing duplicate requests.
- Request Body Example:
- Make a POST request to
- The API will return a
payment_session_id. The Terminal H2H SDK on the terminal device, observing the commands from the API, will then initiate the payment process on the physical terminal.
- Terminal H2H SDK (Observing Connection and Error States):
The Terminal H2H SDK will automatically process the payment command received from the API for the registered terminal. Your app can observe the connection and error states to react to the payment flow.
Handle Optional Methods
The New (using Terminal API (H2H)‘s Push Operation Command - only supported for Indonesia’s BRI terminals):Your application/backend would make a POST request to The Terminal H2H SDK would then receive this command and execute the print operation.New (using Terminal API (H2H)‘s Push Operation Command - only supported for Indonesia’s BRI terminals):Your application/backend would make a POST request to New (using Terminal API (H2H)‘s Void a Payment):Your application/backend would make a POST request to
Method: POST
Headers:
Terminal H2H SDK provides new methods for these operations, often correlating with the Terminal API (H2H)‘s “Push Operation Command” functionality.Reprint Receipt
Old:/v1/terminal/commands.Settlement
Old:/v1/terminal/commands.Cancel Payment (Void Transaction)
Old:/v1/terminal/payments/:payment_id/void.Path: /v1/terminal/payments/:payment_id/voidMethod: POST
Headers:
Content-Type: application/jsonAuthorization: Basic <Base64Encode(API_KEY:)>
payment_id would be obtained from the response of the “Create Payment Session” or “Get Payment Session Detail” API calls.Observe Connection and Error States
The methods for observing connection and error states have been updated in the Terminal H2H SDK.New:The connection states (The
Observing Connection State
Old:CONNECTED, DISCONNECTED, UNKNOWN, CONNECTING, CONNECTING_FAILED, UNSUPPORTED, UNREACHABLE) are similar but are now part of TerminalH2H and tied to a specific TerminalDevice.Observing Error State
Old: Error handling was integrated into thesaleIntent callback.New: A dedicated observeError method is available.Error Data Structure and Error Codes have been standardized and are detailed in the Terminal H2H SDK for Android (Kotlin) documentation. Review these to update your error handling logic accordingly.Troubleshooting and Kiosk Mode
The troubleshooting section regarding “Unresponsive EDC Machine” and “No Response from SDK on EDC payment completion” remains relevant and similar in concept.For Kiosk mode, the recommendation to enable “POS only mode” by providing Terminal IDs to the Xendit EDC team remains valid. This ensures transactions are initiated via the SDK/API and not directly on the terminal.
Summary of Key Changes for BRI Terminals
| Feature / Method | Old Xen BRI SDK (0.3.1) | New Terminal H2H SDK (1.0.0) + Terminal API (H2H) |
|---|---|---|
| SDK Dependency | implementation("co.xendit:xen_edc_sdk-android:0.3.0") | implementation("co.xendit.terminal:h2h-android:<latest_version>")implementation("co.xendit.terminal:core-android:<latest_version>")implementation("co.xendit.terminal:id-bri-android:<latest_version>") |
| SDK Initialization | XenBriTerminal.initialize(context, CLIENT_KEY, XenTerminalMode.MODE) | TerminalApp.initialize(context, CLIENT_KEY, TerminalMode.MODE)TerminalH2H.addProvider(TerminalBRI) |
| Device Connection | XenBriTerminal.useWifi(TID, IP)XenBriTerminal.useBluetooth(context, TID) | TerminalH2H.registerDevices(devices = listOf(TerminalDevice(id = TID, ipAddress = IP, active = true)), restart = true) |
| Create Payment | XenBriTerminal.saleIntent(...) | API Call: POST /v1/terminal/sessions to create a payment session.SDK: Handles the initiated session automatically. |
| Void Payment | XenBriTerminal.cancelPaymentIntent(...) | API Call: POST /v1/terminal/payments/:payment_id/void |
| Reprint Receipt | XenBriTerminal.printReceiptIntent(...) | API Call: POST /v1/terminal/commands with command: PRINT_RECEIPT (Indonesia only) |
| Settlement | XenBriTerminal.settlementIntent(...) | API Call: POST /v1/terminal/commands with command: SETTLE (Indonesia only) |
| Observe Connection State | XenBriTerminal.observeConnection(...) | TerminalH2H.observeConnection(..., terminalDevice) |
| Observe Error State | Part of saleIntent callback | TerminalH2H.observeError(...) |
| Simulation Mode | XenTerminalMode.SIMULATION | Not directly in initialize. Use Terminal API (H2H) for testing with real terminals in test mode. |