Java Integration
REPLACE EXAMPLE CREDENTIALS
The code examples below use placeholder values. You MUST replace them with your actual credentials:
"your-api-key"→ Your actual API Key from merchant portal"your-api-secret"→ Your actual API Secret from merchant portal"1000"→ Your actual Merchant ID from registration
Dependencies (Maven)
xml
<dependencies>
<!-- Jackson for JSON -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.15.2</version>
</dependency>
</dependencies>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
</properties>Quick Start
java
// Create client
StablePayClient client = new StablePayClient(
"https://api.paystablecoin.global",
"1000", // Merchant ID
"your-api-key",
"your-api-secret"
);
// Create order
Map<String, Object> orderRequest = new HashMap<>();
orderRequest.put("merchantOrderId", "M_ORD_" + System.currentTimeMillis());
orderRequest.put("orderAmount", Map.of(
"value", "99.99",
"currency", "USD"
));
orderRequest.put("expiresAt", "2025-12-31T23:59:59Z");
orderRequest.put("returnUrl", "https://yoursite.com/payment/success");
orderRequest.put("paymentMethod", Map.of(
"supportedCurrencies", List.of("USDT", "USDC"),
"preferredChain", "TRON"
));
String response = client.createOrder(orderRequest);
System.out.println(response);
// Query order
String queryResult = client.queryOrder("M_ORD_" + System.currentTimeMillis());
System.out.println(queryResult);Complete Example
See examples/java/StablePayClient.java for the complete SDK implementation.
Key Features:
- Automatic signature calculation
- Support for POST (create) and GET (query) operations
- Built-in error handling
- Uses Java 11+ HttpClient
Run Example:
bash
cd examples/java
mvn clean compile
mvn exec:java -Dexec.mainClass="com.stablepay.merchant.sdk.StablePayClient"Related Documentation
- Signature Algorithm - Learn signature calculation principles
- API Reference - View all available endpoints
- Security Best Practices - Learn secure integration recommendations