Skip to content

Python 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

bash
pip install requests

Quick Start

python
from stablepay_client import StablePayClient
import time

# Create client
client = StablePayClient(
    base_url="https://api.paystablecoin.global",
    merchant_id="1000",
    api_key="your-api-key",
    api_secret="your-api-secret"
)

# Create order
order_request = {
    "merchantOrderId": f"M_ORD_{int(time.time() * 1000)}",
    "orderAmount": {
        "value": "99.99",
        "currency": "USD"
    },
    "expiresAt": "2025-12-31T23:59:59Z",
    "returnUrl": "https://yoursite.com/payment/success",
    "paymentMethod": {
        "supportedCurrencies": ["USDT", "USDC"],
        "preferredChain": "TRON"
    }
}

response = client.create_order(order_request)
print(response)

# Query order
order = client.query_order(f"M_ORD_{int(time.time() * 1000)}")
print(order)

Complete Example

See examples/python/stablepay_client.py for the complete SDK implementation.

Key Features:

  • Automatic signature calculation
  • Support for POST (create) and GET (query) operations
  • Built-in error handling
  • Uses requests library

Run Example:

bash
cd examples/python
python stablepay_client.py

Released under the MIT License.