Understanding the cryptocurrency payment flow is essential for building a reliable integration. This guide walks through each stage from invoice creation to final confirmation.
Payment Lifecycle Overview
βββββββββββββββ ββββββββββββββββ βββββββββββββββ βββββββββββββ
β Create βββββΆβ Customer βββββΆβ Blockchain βββββΆβ Webhook β
β Payment β β Pays β β Confirms β β Sent β
βββββββββββββββ ββββββββββββββββ βββββββββββββββ βββββββββββββ
PENDING PENDING CONFIRMED CONFIRMED
Stage 1: Payment Creation
When a customer checks out, your server creates a payment:
POST /api/merchant/v1/payments
{
"amount": "50.00",
"currency": "USDT",
"network": "TRON",
"tokenStandard": "TRC20",
"metadata": {
"product": "Premium Plan",
"customer_id": "cust_abc"
}
}
The API returns a unique TRON address:
{
"paymentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "pending",
"amount": "50.00",
"currency": "USDT",
"network": "TRON",
"tokenStandard": "TRC20",
"generatedAddress": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"expiresAt": "2025-01-15T10:30:00.000Z"
}
Stage 2: Payment Page
Display a clear payment interface:
Important UX Considerations
Stage 3: Blockchain Monitoring
Once the customer sends USDT:
During this time, you can poll for status:
GET /api/merchant/v1/payments/a1b2c3d4-e5f6-7890-abcd-ef1234567890
Stage 4: Webhook Notification
When confirmed, we send a webhook:
{
"id": "evt_a1b2c3d4_1705320600000",
"type": "payment.confirmed",
"createdAt": "2025-01-15T10:10:00.000Z",
"data": {
"paymentId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "confirmed",
"amount": "50.00",
"currency": "USDT",
"network": "TRON",
"expectedAmount": "50.00",
"receivedAmount": "50.00",
"netAmount": "49.50",
"feeAmount": "0.50",
"txHash": "a1b2c3d4...",
"generatedAddress": "TQn9Y2khEsLJW1ChVWFMSMeRDow5KcbLSE",
"confirmations": 19,
"metadata": { "product": "Premium Plan", "customer_id": "cust_abc" }
}
}
Handling Edge Cases
Underpayment
If the customer sends less than required:
underpaidpayment.underpaid eventreceivedAmount, expectedAmount, and underpaidAmount fields show detailsOverpayment
If the customer sends more:
overpaidpayment.overpaid eventreceivedAmount, expectedAmount, and overpaidAmount fields show detailsExpiration
After 30 minutes without sufficient payment:
expiredpayment.expired eventFee Calculation
Fees are calculated at payment creation:
fee_amount = (amount * fee_percent / 100) + fixed_fee
net_amount = amount - fee_amount
Example with 1% + $0.30: