Terminal H2H SDK for iOS (Swift)
The Terminal H2H SDK for iOS enables you to integrate secure payment processing directly into your iOS applications. Connect to physical payment terminals and process transactions seamlessly using our comprehensive Swift SDK.This SDK works alongside the Terminal API to provide a complete in-person payment solution. You’ll use the Terminal API to create payment sessions and the Terminal H2H SDK to interact with physical payment devices.
Version information
v1.0.0 — 19-Feb-2026
v1.0.0 — 19-Feb-2026
What’s new:
- Renamed class name
TerminalGatewaytoTerminalH2Hfor better consistency
v0.7.0 — 5-Dec-2025
v0.7.0 — 5-Dec-2025
What’s new:
- Fixed NTT payment method value mapping to ensure correct provider selection
- Updated BRI payment flow to validate transaction data before executing terminal actions
- Added timeout configuration for card and QR transactions to auto-cancel and retry stalled requests
- Added support to handle retry requests via
/v1/terminal/sessions/{id}/retryendpoint
v0.6.0 — 20-Nov-2025
v0.6.0 — 20-Nov-2025
What’s new:
- Added support for multiple concurrent device connections, enabling simultaneous transactions across different terminals
- [BRI] Fixed status value handling in void and cancel API responses for improved transaction status accuracy
v0.5.0 — 30-Oct-2025
v0.5.0 — 30-Oct-2025
What’s new:
- Introduced command ID handling for settlement operations
- Enhanced retry logic with configurable attempt counts
- Improved error handling and logging throughout the gateway service
v0.4.1 — 7-Oct-2025
v0.4.1 — 7-Oct-2025
Bug fixes and improvements:
- Fix data mapping for terminal responses
- [BRI] Enhanced status verification after transaction timeout for improved reliability
v0.4.0 — 13-May-2025
v0.4.0 — 13-May-2025
XenTerminal is the companion SDK to In-Person Payment Sessions API. This version provides core functionality for connecting to payment terminals and processing transactions.
The SDK follows semantic versioning. Breaking changes will bump the major version number.
Download
Download the Terminal H2H iOS SDK:Installation
Install the Terminal SDK by adding it as a framework in Xcode:Add framework to project
In Xcode, open your project and choose File → Add Package Dependencies… to start the package flow.

Import framework
- Click Add Local… when prompted.
- Browse to the extracted framework zip/location and select the package manifest.
- Ensure the correct target is selected, then click Add Package to finish.



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.Step 1: Initialize SDK
Import the SDK module and callTerminalApp.shared.initialize from your application entry point:
AppDelegate.swift
- Integration Mode
- Live Mode
Use
TerminalMode.integration for development and testing with physical terminals. Transactions are sent to Test Mode on the Xendit Dashboard.Step 2: Add Terminal Providers
Add the specific terminal providers you need for your integration:For Share Commerce (SHC), Cashup, and Atom terminals, you do not need to add a Terminal H2H provider. Those devices run terminal logic through the Gateway app installed on the hardware. If the app is missing, install it from the Gateway download page or contact inpersonpayments@xendit.co for help.
- BRI Provider (Indonesia)
- NTT Provider (Thailand)
- Multiple Providers
BRI provider supports timeout configuration for card and QR transactions, and provides enhanced transaction retry capabilities.
After adding providers, they will be available for use when registering terminal devices in the next step.
Step 3: Register Terminal Device
Create terminal device entries usingTerminalDevice.companion.create and register them with the gateway:
Step 4: Calling Terminal API
With Terminal H2H SDK configured, you can now process payments using the Terminal API. The SDK handles communication with physical terminals through the local gateway service.For complete API documentation including request/response formats, error handling, and advanced features, see the Terminal API (H2H) documentation.
You’re now ready to process payments using the Terminal H2H SDK integrated with Terminal API.
Optional Methods
Set Operation Timeout
Configure the maximum allowed time for operations to complete before the service cancels and retries the transaction:Restart Terminal Connection
Manage and restart terminal service connections:- Restart All Connections
- Restart Single Connection
Call the method without parameters to restart all connections and tasks:
Observing Connection State
Monitor Terminal connection status using theobserveEDCConnection method:
| Code | Description |
|---|---|
connected | Device connected to Terminal |
disconnected | Device disconnected to Terminal |
unknown | When no connection has been established yet |
connecting | Device requesting connection to Terminal |
connectingFailed | Device unable to connect with Terminal |
unsupported | Connection not supported |
unreachable | Ping failed; gateway marks device unreachable until it recovers |
Observing Error State
Monitor Terminal error states using theobserveError method:
Error Handling
Error Data Structure
All errors returned by the Terminal H2H SDK follow this structure:Error Codes Reference
| Error Code | HTTP Status | Description |
|---|---|---|
| INVALID_CREDENTIAL | 401 | Provided credentials are invalid or expired |
| INVALID_REQUEST | 400 | Request format or parameters are invalid |
| INTERNAL_SERVER_ERROR | 500 | Server-side error occurred during processing |
| UNKNOWN_ERROR | - | Unexpected error that does not map to a specific category |
| KEY_INVALID | -1 | API key is invalid or not authorized |
| AUTHENTICATION_FAILED | -21 | Terminal authentication failed - verify terminal ID and credentials |
| FAILED_TO_CONNECT | -4 | Unable to establish connection to terminal |
| NOT_CONNECTED | -3 | No active connection to any terminal device |
| TERMINAL_BUSY | -6 | Terminal is processing another transaction |
| SEND_FAILED | -2 | Failed to send data to the terminal device |
| UNSUPPORTED | -5 | Operation or platform not supported |
| ENCRYPTION_FAILED | -7 | Encryption key invalid or encryption process failed |
| DECLINED_BY_READER | N/A | Card or reader rejected the transaction; prompt customer to retry |
| PAYMENT_UNPAID | N/A | Payment still pending on terminal; confirm status before retrying |
| DUPLICATED | N/A | Duplicate command detected; generate a new order ID before retrying |
| CANCELLED | N/A | Action cancelled on the terminal or by the operator |
| TIMEOUT | N/A | Operation exceeded configured timeout window |
| NO_DATA_FOUND | N/A | Terminal cannot find the referenced transaction data |
| TID_NOT_SET | N/A | Terminal ID is missing in the gateway configuration |
| TID_NOT_MATCH | N/A | Terminal ID does not match the registered device |
Error Handling Best Practices
Implement comprehensive error handling for robust payment processing:Troubleshooting
Common Issues and Solutions
Unresponsive EDC Machine
Unresponsive EDC Machine
Problem: The EDC (Electronic Data Capture) machine becomes unresponsive or stops processing transactions.Solution:
- Restart the EDC machine by holding the power button and selecting “Restart”
- Wait for the device to fully boot up and reconnect
- Verify the terminal is back online using the connection monitoring features
Kiosk Mode Configuration
Kiosk Mode Configuration
Problem: Unexpected behaviors or unauthorized access to terminal functions.Solution:
- Ensure all transactions are initiated only through the SDK
- Contact the Xendit EDC team to enable POS-only mode for your Terminal IDs
- Configure terminal settings to disable manual transaction entry
No Response After Payment Completion
No Response After Payment Completion
Problem: EDC fails to send transaction results to the SDK after payment completion.Solution:
- Query the Payment Session using the Terminal API to retrieve the latest status
- Check network connectivity between the EDC and your application
- Verify the callback URL configuration in your payment session
- Implement retry logic for failed status updates
Transaction Stuck or Missing Callback After Receipt Printed
Transaction Stuck or Missing Callback After Receipt Printed
Problem: Transaction appears stuck or you don’t receive a callback after the terminal prints a receipt, indicating the transaction may be incomplete.Solution:
Call the Terminal API retry endpoint to request the app check the transaction status and redo the transaction if it’s incomplete:
This troubleshooting section applies only to BRI terminals.
The retry endpoint
/v1/terminal/sessions/{id}/retry instructs the app to verify the current transaction status with the terminal and automatically redo the transaction if it’s found to be incomplete.Connection Issues
Connection Issues
Problem: Unable to establish or maintain connection with terminal devices.Solutions:
- Check network connectivity: Ensure both devices are on the same network
- Verify IP addresses: Confirm terminal IP addresses are correct and accessible
- Firewall settings: Check if firewall is blocking the connection ports
- Terminal status: Ensure the terminal is powered on and in ready state
- SDK initialization: Verify client key and terminal configuration
Use the connection monitoring features to diagnose specific connection issues.
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.










