Integration Issues
This page summarizes common issues when integrating SUNBAY payment system.
SDK Related
What to do if SDK installation fails?
Java SDK
# Check Maven configuration
mvn dependency:tree | grep sunbay
# Clean cache and reinstall
mvn clean install -UNode.js SDK
# Clean cache
npm cache clean --force
# Reinstall
npm install @sunbay/sunbay-nexus-sdkPython SDK
# Reinstall
pip install sunbay-nexus-sdkHow to resolve SDK version conflicts?
- Check dependency versions
- Upgrade to latest version
- Exclude conflicting dependencies
<!-- Maven exclude dependencies -->
<dependency>
<groupId>com.sunmi</groupId>
<artifactId>sunbay-nexus-sdk-java</artifactId>
<version>1.0.8</version>
<exclusions>
<exclusion>
<groupId>conflicting-group</groupId>
<artifactId>conflicting-artifact</artifactId>
</exclusion>
</exclusions>
</dependency>How to check SDK version?
Java
<!-- Check in pom.xml -->
<dependency>
<groupId>com.sunmi</groupId>
<artifactId>sunbay-nexus-sdk-java</artifactId>
<version>1.0.8</version>
</dependency>Node.js
npm list @sunbay/sunbay-nexus-sdkPython
pip show sunbay-nexus-sdkLocal Integration
What if Tapro app is not installed?
Solution:
- Download Tapro from app store
- Or download APK from SUNBAY official website
- Install and retry connection
What to do if terminal connection fails?
App-to-App Mode:
- Confirm Tapro is installed and running
- Check app permissions
- Restart both apps
Cable Mode:
- Check cable connection
- Confirm driver is installed
- Check serial port configuration
LAN Mode:
- Confirm devices are on same network
- Check firewall settings
- Test connectivity with ping
What to do if device discovery fails?
LAN Mode Device Discovery:
- Check Network Connection
# Ping terminal IP
ping 192.168.1.100
# Check port
telnet 192.168.1.100 8080- Check Firewall
- Allow UDP broadcast (port 8888)
- Allow TCP connection (port 8080)
- Manual IP Configuration
- If automatic discovery fails, you can manually specify terminal IP address in SDK configuration
- Refer to the corresponding platform’s SDK documentation for specific configuration methods
What if serial port cannot be opened?
Windows:
- Check COM port in Device Manager
- Confirm driver is installed correctly
- Check if port is occupied by other programs
Linux:
# View serial port devices
ls -l /dev/ttyUSB*
# Add user to dialout group
sudo usermod -a -G dialout $USER
# Re-login for permissions to take effectCloud Integration
What to do if connection times out?
Check Network Connection:
# Test API connectivity
curl -I https://open.sunbay.us
# Check DNS resolution
nslookup open.sunbay.usAdjust Timeout Settings:
// Java SDK
NexusClient client = new NexusClient.Builder()
.apiKey(apiKey)
.baseUrl("https://open.sunbay.us")
.connectTimeout(30000) // 30 seconds
.readTimeout(60000) // 60 seconds
.build();What to do if SSL certificate verification fails?
Causes:
- System time incorrect
- Missing root certificates
- Using self-signed certificate
Solutions:
- Sync System Time
# Linux/Mac
sudo ntpdate -u time.nist.gov
# Windows
w32tm /resync- Update Root Certificates
# Ubuntu/Debian
sudo apt-get update
sudo apt-get install ca-certificates
# CentOS/RHEL
sudo yum update ca-certificates- Import Certificate to Java
# Download certificate
openssl s_client -connect open.sunbay.us:443 -showcerts
# Import to Java keystore
keytool -import -alias sunbay -file sunbay.crt \
-keystore $JAVA_HOME/jre/lib/security/cacertsWhat to do about request rate limiting?
Error Code: S04 - Interface call frequency exceeded
Solutions:
-
Reduce Request Frequency
- Reduce concurrent requests
- Increase request intervals
- Use queue to control request frequency
-
Handle Rate Limit Errors
catch (SUNBAYBusinessException e) {
if ("S04".equals(e.getCode())) {
// Rate limit exceeded, wait then retry
Thread.sleep(1000); // Wait 1 second
// Retry request
}
}- Contact Technical Support to Increase Limit
Data Format
What to do if JSON parsing error occurs?
Common Causes:
- Incorrect JSON format
- Character encoding issues
- Special characters not escaped
Debugging Methods:
// Print raw response
console.log('Raw response:', responseText);
// Validate JSON format
try {
const data = JSON.parse(responseText);
} catch (e) {
console.error('JSON parse error:', e.message);
console.error('Invalid JSON:', responseText);
}Use Online Tools for Validation:
What to do if amount format is wrong?
Correct Amount Format:
// ✅ Correct - Use smallest currency unit (cents)
SaleAmount amount = SaleAmount.builder()
.orderAmount(10000) // 100.00 USD = 10000 cents
.priceCurrency("USD")
.build();
// ❌ Wrong - Using decimal
.orderAmount(100) // Wrong: This represents 1.00 USD, not 100.00 USDAmount Conversion:
// Dollars to cents
int amountInCents = (int) Math.round(amountInDollars * 100);
// Cents to dollars
double amountInDollars = amountInCents / 100.0;What to do if date/time format is wrong?
Use ISO 8601 Format:
// ✅ Correct
"2025-01-08T10:30:00Z"
"2025-01-08T10:30:00+08:00"
// ❌ Wrong
"2025/01/08 10:30:00"
"01-08-2025 10:30:00"JavaScript Example:
// Generate ISO 8601 format
const timestamp = new Date().toISOString();
// Parse ISO 8601 format
const date = new Date('2025-01-08T10:30:00Z');Environment Configuration
How to switch between test/production environments?
SDK Configuration:
// Test and production environments use the same baseUrl
NexusClient client = new NexusClient.Builder()
.apiKey(apiKey) // Use test or production environment API Key
.baseUrl("https://open.sunbay.us") // Default value, can be omitted
.build();Use Environment Variables:
# .env file
SUNBAY_API_KEY=your_api_keyHow to configure log level?
Java:
// logback.xml
<logger name="com.sunmi.sunbay.nexus" level="DEBUG"/>Node.js:
const { NexusClient } = require('@sunbay/sunbay-nexus-sdk');
const client = new NexusClient({
apiKey: apiKey,
baseUrl: 'https://open.sunbay.us',
// SDK uses standard logging library, log level can be controlled via environment variables
});Python:
import logging
logging.basicConfig(level=logging.DEBUG)Debugging Tips
How to view requests and responses?
Enable Debug Logging:
SDK uses standard logging libraries; you can configure log level through logging framework:
Java:
<!-- logback.xml -->
<logger name="com.sunmi.sunbay.nexus" level="DEBUG"/>Node.js:
// Use environment variable
process.env.DEBUG = 'sunbay:*';Python:
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('sunbay_nexus_sdk').setLevel(logging.DEBUG)Use Packet Capture Tools:
- Charles Proxy
- Fiddler
- Wireshark
How to test Webhook?
Use Local Tunnel Tools:
# ngrok
ngrok http 3000
# Get public URL
https://abc123.ngrok.ioUse Webhook Testing Tools:
How to simulate different payment scenarios?
Sandbox environment simulates different payment scenarios through test amounts, no need to use specific test card numbers:
// Successful payment: Use any non-special amount (e.g., 100)
amount: 100
// Card declined: Use test amount 8888
amount: 8888
// Insufficient balance: Use test amount 8887
amount: 8887
// Transaction timeout: Use test amount 7777
amount: 7777See Test Scenarios for details
Performance Optimization
How to improve request speed?
- Use Connection Pool
// Configure connection pool
HttpClient httpClient = HttpClient.newBuilder()
.connectTimeout(Duration.ofSeconds(10))
.build();- Enable HTTP/2
HttpClient client = HttpClient.newBuilder()
.version(HttpClient.Version.HTTP_2)
.build();- Use CDN
- Use nearby API endpoints
- Enable gzip compression
- Batch Operations
- Merge multiple query requests
- Use batch query interface
How to reduce memory usage?
- Release Resources Promptly
// NexusClient implements AutoCloseable
try (NexusClient client = new NexusClient.Builder()
.apiKey(apiKey)
.build()) {
// Use client
} // Auto-close- Reuse Client Instances
// Create once, reuse globally (recommended)
NexusClient client = new NexusClient.Builder()
.apiKey(apiKey)
.build();
// Reuse same instance throughout application lifecycle