Skip to Content

Local Integration

Local integration refers to POS applications communicating directly with Tapro applications through Taplink SDK to implement localized payment processing. This document introduces how to start local integration development.

Solution Description: For connection principles and mode comparison of local integration, please refer to Solution Overview.

Development Preparation

1. Obtain Development Credentials

Before starting integration, you need to obtain necessary development credentials first. For detailed steps, please refer to Pre-Development Preparation Documentation.

Brief process:

  1. Contact SUNBAY to obtain Copilot account
  2. Log in to Copilot portal to create payment application
  3. Obtain application credentials (including sandbox and production environments):
    • App ID: Application unique identifier
    • Merchant ID: Merchant ID
    • Secret Key: Key for signature verification

2. Configure Tapro Application (Based on Connection Mode)

Before starting integration, ensure that the payment terminal has Tapro application installed.

Configure Tapro application according to your chosen connection mode:

App-to-App Mode

No need to configure Taplink Configuration. Taplink SDK will automatically detect and connect to Tapro application on the same device.

Cable Mode (Physical Cable Connection)

  1. Open Tapro application and enter settings page
  2. Enable Taplink Configuration switch
  3. Select the corresponding connection method in Cable option:
    • VSP: Virtual Serial Port
    • RS232: Physical Serial Port
    • AOA: Android Open Accessory
Taplink Configuration Cable Mode Setup

LAN Mode (Local Area Network Connection)

  1. Open Tapro application and enter settings page
  2. Enable Taplink Configuration switch
  3. Enable LAN switch (Local Area Network connection)
Taplink Configuration LAN Mode Setup

Connection Mode Selection Guide:

  • App-to-App: POS application and Tapro application on the same Android device, simplest and fastest
  • Cable: Requires physical cable connection, high stability, suitable for fixed deployment scenarios
  • LAN: Connect via local area network, high flexibility, suitable for scenarios where POS and terminal are separated

3. Download SDK

Before starting integration, you need to obtain necessary development credentials first. For detailed steps, please refer to Pre-Development Preparation Documentation.

Brief process:

  1. Contact SUNBAY to obtain Copilot account
  2. Log in to Copilot portal to create payment application
  3. Obtain application credentials (including sandbox and production environments):
    • App ID: Application unique identifier
    • Merchant ID: Merchant ID
    • Secret Key: Key for signature verification

3. Download SDK

Visit SDK Download Page to download Taplink SDK (supports Android, .NET, Java and other platforms).

4. Configure Permissions

Apply for required transaction permissions for your application in Copilot portal:

Transaction TypeRequired PermissionDescription
Salepayment.saleSale transaction permission
Pre-authorizationpayment.authPre-authorization and pre-authorization completion permission
Refundpayment.refundRefund transaction permission
Voidpayment.voidVoid transaction permission
Tip Adjustmentpayment.tip_adjustTip adjustment permission
Querypayment.queryTransaction query permission
Batch Closepayment.batch_closeBatch close permission

Important: Some APIs require completing sandbox environment test acceptance to obtain production environment usage permission. For detailed process, please refer to Sandbox Environment Testing Documentation.

Integration Process

Basic Steps

Regardless of which integration mode is chosen, the basic integration process is consistent:

  1. Initialize SDK

    • Configure App ID, Merchant ID, Secret Key
    • Specify connection mode (APP_TO_APP / CABLE / LAN)
  2. Establish Connection

    • App-to-App: Automatically detect and connect to Tapro application
    • Cable mode: Detect physical connection and establish communication
    • LAN mode: Enter IP and port (first time) or automatically connect (subsequent)
  3. Initiate Transaction

    • Create transaction request (sale, refund, void, etc.)
    • Call SDK to execute transaction
    • Process transaction results and callbacks
  4. Disconnect

    • Disconnect when application exits
    • Release resources

Security Authentication

Important: All authentication and security verification are automatically handled by Taplink SDK, developers only need to provide correct credentials.

SDK automatically handles the following security mechanisms:

  • Connection Authentication: Use App ID and Secret Key for identity verification
  • Message Signing: HMAC-SHA256 signature verification to prevent data tampering
  • Transport Encryption: LAN mode uses TLS 1.2+ encrypted transmission
  • Permission Verification: Check if application has corresponding transaction permissions

Developers need to note:

  • Never hardcode secretKey in code
  • Use secure methods to store credentials (such as Android Keystore)
  • Regularly rotate credentials in production environment
  • Ensure application has correctly configured required permissions

Error Code Reference

Error Code Range Description

Taplink SDK uses a segmented error code design, with each range corresponding to different error types for quick problem identification.

Note: Error code 100 indicates operation success and is a success response code, not an error code. Other codes 20x-39x are error codes.

Error Code Segments

Error Code RangeError TypeDescription
100Success ResponseOperation successful (not an error code)
20xInitialization ErrorSDK initialization related issues
21xConnection State/FailureConnection state management and connection failures
23xLocal Mode Connection FailureSame-device APP_TO_APP mode connection issues
24xLAN Mode Connection FailureLAN mode network connection issues
25xUSB Mode Connection FailureCABLE mode cable connection issues
30xTransaction Processing ErrorTransaction parameters, sending, status and other issues

Complete Error Code List

Error CodeError CategoryError DescriptionSolutiontransactionRequestId Retry Rule
100SuccessOperation successfulNo action needed-
201Initialization ErrorSDK not initializedCall TaplinkSDK.init() to initialize SDK-
202Initialization ErrorSDK service exceptionRestart application-
203Initialization ErrorTapro initialization failedReconnect-
211Connection State ErrorConnection already exists, no need to reconnectNo need to reconnect-
212Connection State ErrorDevice not connectedCall connect() first to establish connection-
213Connection State ErrorConnection disconnectedCall connect() again-
214Connection FailureUnable to establish connectionCheck network or device status and retry-
221Connection FailureAuthentication failedCheck if appId and secretKey are correct-
231Local Mode Connection FailureTapro app not installedInstall Tapro app-
232Local Mode Connection FailureUnable to connect to TaproRestart Tapro app or device-
241LAN Mode Connection FailureUnable to connect to serverCheck network connection and firewall settings-
242LAN Mode Connection FailureUnable to discover serverManually enter server IP address-
251USB Mode Connection FailureCable not connectedConnect USB cable or serial cable-
252USB Mode Connection FailureUSB permission deniedAuthorize app to use USB device-
253USB Mode Connection FailureUSB connection timeoutReconnect USB cable-
254USB Mode Connection FailureUSB protocol not supportedUse auto-detect mode or contact technical support-
255USB Mode Connection FailureSerial device not readyReconnect serial cable-
301Transaction Processing ErrorMissing required parametersCheck required parameters like amount, transaction typeCan retry
302Transaction Processing ErrorData format errorCheck if parameter format meets API documentation requirementsCan retry
303Transaction Processing ErrorUnsupported transaction typeCheck transaction type parameter (SALE/REFUND/VOID etc.)Can retry
304Transaction Processing ErrorRequest send failedCheck network connection and retryCan retry
305Transaction Processing ErrorTransaction in progressWait for current transaction to completeCan retry
306Transaction Processing ErrorResponse timeoutQuery transaction status first, confirm before retryQuery first
307Transaction Processing ErrorTransaction failedCheck parameters and retry with new IDMust use new ID
308Transaction Processing ErrorTransaction processingQuery transaction status first, confirm before retryQuery first
309Transaction Processing ErrorTransaction terminatedDo not retryDo not retry
310Transaction Processing ErrorInsufficient balanceNotify user of insufficient balance, retry with new IDMust use new ID
311Transaction Processing ErrorIncorrect passwordPrompt user to re-enter password, retry with new IDMust use new ID

Retry Rule Legend:

  • Can retry = Can retry with the same transactionRequestId (safe)
  • Query first = Need to query transaction status before deciding
  • Must use new ID = Must use a new transactionRequestId (prevent duplicate charges)
  • Do not retry = Transaction terminated, should not retry
  • - = Not applicable (connection errors or non-transaction errors, transactionRequestId not involved)

Error Code Quick Reference

Initialization Issues

Error CodeIssueQuick Solution
201SDK not initializedCall TaplinkSDK.init()
202SDK service exceptionRestart application
203Tapro initialization failedReconnect

Connection Issues

Error CodeIssueQuick Solution
211-213Connection state errorCheck connection state, call connect() again
214, 221Connection failureCheck network/device/authentication parameters
231-232Local mode connection failureInstall Tapro app or restart device
241-242LAN mode connection failureCheck network and IP address
251-255USB mode connection failureCheck cable connection and USB permissions

Transaction Issues

Error CodeIssueQuick SolutionRetry Rule
301-305Parameter/send errorCheck parameters and network✅ Can use same ID
306Response timeoutQuery status first⚠️ Query then decide
307-311, 399Transaction failedReview details and reinitiate❌ Must use new ID

Best Practices

1. Idempotency Handling

Use unique transactionRequestId for each transaction to ensure transaction idempotency.

Important: Except for query interfaces which can be retried, other transaction interfaces (sale, refund, void, etc.) cannot be retried to avoid duplicate payments. If transaction times out or fails, should first call query interface to confirm transaction status, then decide on subsequent operations.

2. Timeout Handling

  • Set reasonable connection timeout (recommended 10 seconds)
  • After transaction timeout, do not retry directly, first call query interface to confirm transaction status
  • Decide whether to initiate new transaction based on query results (using new transactionRequestId)

3. Error Handling

  • Catch and handle all exceptions
  • Provide clear user prompts
  • Record error logs for easy troubleshooting

4. Log Recording

  • Enable detailed logs in development environment
  • Disable detailed logs in production environment
  • Record key business operations

Complete Sample Project

For complete sample project code, please visit GitHub repository: taplink-sdk-android-demo 

This sample project includes:

  • Complete SDK integration example
  • Implementation of various transaction types (sale, refund, void, pre-authorization, etc.)
  • Connection management and error handling
  • UI interaction example
  • Best practice reference
Last updated on