📦 Node.js SDK & CLI
Use our official SDK for seamless integration with your Node.js applications
Authentication
All API requests require authentication using a JWT token in the Authorization header.
/api/auth/registerCreate a new merchant account.
Request Body
{
"email": "merchant@example.com",
"password": "SecurePassword123!",
"name": "My Business" // optional
}cURL Example
curl -X POST https://coinpayportal.com/api/auth/register \
-H "Content-Type: application/json" \
-d '{
"email": "merchant@example.com",
"password": "SecurePassword123!",
"name": "My Business"
}'Node.js Example
const response = await fetch('https://coinpayportal.com/api/auth/register', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
email: 'merchant@example.com',
password: 'SecurePassword123!',
name: 'My Business'
})
});
const data = await response.json();
console.log(data.token); // Save this token/api/auth/loginLogin to get an authentication token.
Request Body
{
"email": "merchant@example.com",
"password": "SecurePassword123!"
}Response
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
"merchant": {
"id": "merchant-123",
"email": "merchant@example.com",
"name": "My Business"
}
}/api/auth/meGet current authenticated merchant information.
cURL Example
curl https://coinpayportal.com/api/auth/me \ -H "Authorization: Bearer YOUR_TOKEN"
Response
{
"success": true,
"merchant": {
"id": "merchant-123",
"email": "merchant@example.com",
"name": "My Business",
"created_at": "2024-01-01T12:00:00Z"
}
}Subscriptions & Entitlements
CoinPay Portal offers two subscription tiers with different features and transaction limits. All subscription payments are processed using cryptocurrency.
Tip: View our pricing page for a visual comparison of plans and to upgrade your subscription.
Subscription Plans
- • Up to 100 transactions/month
- • All supported chains
- • Basic API access
- • Email support
- • Unlimited transactions
- • Priority support
- • Advanced analytics
- • Custom webhooks
/api/subscription-plansGet available subscription plans (public endpoint).
Response
{
"success": true,
"plans": [
{
"id": "starter",
"name": "Starter",
"description": "Perfect for testing and small projects",
"pricing": { "monthly": 0, "yearly": 0 },
"limits": { "monthly_transactions": 100, "is_unlimited": false },
"features": {
"all_chains_supported": true,
"basic_api_access": true,
"advanced_analytics": false,
"custom_webhooks": false,
"white_label": false,
"priority_support": false
}
},
{
"id": "professional",
"name": "Professional",
"pricing": { "monthly": 49, "yearly": 490 },
"limits": { "monthly_transactions": null, "is_unlimited": true },
"features": { ... }
}
]
}/api/entitlementsGet current merchant's entitlements, features, and usage.
cURL Example
curl https://coinpayportal.com/api/entitlements \ -H "Authorization: Bearer YOUR_TOKEN"
Response
{
"success": true,
"entitlements": {
"plan": {
"id": "starter",
"name": "Starter",
"description": "Perfect for testing and small projects",
"price_monthly": 0
},
"features": {
"all_chains_supported": true,
"basic_api_access": true,
"advanced_analytics": false,
"custom_webhooks": false,
"white_label": false,
"priority_support": false
},
"usage": {
"transactions_this_month": 45,
"transaction_limit": 100,
"transactions_remaining": 55,
"is_unlimited": false
},
"status": "active"
}
}/api/subscriptions/checkoutCreate a crypto payment for subscription upgrade.
Request Body
{
"plan_id": "professional",
"billing_period": "monthly", // or "yearly"
"blockchain": "ETH" // BTC, BCH, ETH, POL, SOL
}cURL Example
curl -X POST https://coinpayportal.com/api/subscriptions/checkout \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"plan_id": "professional",
"billing_period": "monthly",
"blockchain": "ETH"
}'Response
{
"success": true,
"payment": {
"id": "pay_abc123",
"payment_address": "0x1234...5678",
"amount": 49,
"currency": "USD",
"blockchain": "ETH",
"expires_at": "2024-01-15T12:00:00Z"
},
"plan": {
"id": "professional",
"name": "Professional",
"billing_period": "monthly",
"price": 49
},
"instructions": "Send exactly $49 worth of ETH to the payment address..."
}/api/subscriptions/statusGet current subscription status.
Response
{
"success": true,
"subscription": {
"planId": "professional",
"status": "active",
"startedAt": "2024-01-01T00:00:00Z",
"endsAt": "2024-02-01T00:00:00Z",
"isActive": true,
"daysRemaining": 15
}
}/api/subscriptions/statusCancel subscription (access continues until end of billing period).
Response
{
"success": true,
"message": "Subscription cancelled. You will retain access until the end of your billing period.",
"subscription": {
"planId": "professional",
"status": "cancelled",
"endsAt": "2024-02-01T00:00:00Z",
"isActive": true,
"daysRemaining": 15
}
}Entitlement Error Codes
Businesses
/api/businessesList all businesses for the authenticated merchant.
cURL Example
curl https://coinpayportal.com/api/businesses \ -H "Authorization: Bearer YOUR_TOKEN"
/api/businessesCreate a new business.
Request Body
{
"name": "My Store",
"description": "Online retail store", // optional
"wallet_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"webhook_url": "https://mystore.com/webhook" // optional
}Node.js Example
const response = await fetch('https://coinpayportal.com/api/businesses', {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_TOKEN',
'Content-Type': 'application/json'
},
body: JSON.stringify({
name: 'My Store',
wallet_address: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb'
})
});
const data = await response.json();/api/businesses/:idUpdate an existing business.
/api/businesses/:idDelete a business.
Supported Coins
Get the list of supported cryptocurrencies (wallets) configured for a business. This endpoint is useful for displaying available payment options to customers.
/api/supported-coinsGet supported cryptocurrencies for a business.
Query Parameters
business_id - Business UUID (required for JWT auth, not needed with API key)
active_only - If "true", only return active wallets (optional)
cURL Example (API Key)
curl https://coinpayportal.com/api/supported-coins \ -H "Authorization: Bearer cp_live_your_api_key"
cURL Example (JWT with business_id)
curl "https://coinpayportal.com/api/supported-coins?business_id=your-business-uuid" \ -H "Authorization: Bearer YOUR_JWT_TOKEN"
Response
{
"success": true,
"coins": [
{
"symbol": "BTC",
"name": "Bitcoin",
"is_active": true,
"has_wallet": true
},
{
"symbol": "ETH",
"name": "Ethereum",
"is_active": true,
"has_wallet": true
},
{
"symbol": "SOL",
"name": "Solana",
"is_active": false,
"has_wallet": true
}
],
"business_id": "your-business-uuid",
"total": 3
}Node.js Example
const response = await fetch('https://coinpayportal.com/api/supported-coins', {
headers: {
'Authorization': 'Bearer cp_live_your_api_key'
}
});
const data = await response.json();
// Display available payment options to customers
data.coins.filter(c => c.is_active).forEach(coin => {
console.log(`Accept ${coin.name} (${coin.symbol})`);
});Available Cryptocurrency Symbols
BTCBitcoin
BCHBitcoin Cash
ETHEthereum
POLPolygon
SOLSolana
USDTTether
USDCUSD Coin
BNBBNB
XRPXRP
ADACardano
DOGEDogecoin
Tip: Use this endpoint to dynamically show customers which cryptocurrencies your business accepts. Only coins with is_active: true should be offered as payment options.
Payments
/api/payments/createCreate a new payment request.
Request Body
{
"business_id": "business-123",
"amount_usd": 100.00,
"currency": "usdc_pol", // See currency options below
"description": "Order #12345", // optional
"redirect_url": "https://yoursite.com/success" // optional - redirect after payment
}Currency Options
Low Fee Options (Recommended)
usdc_pol - USDC on Polygon (~$0.01 fee)
usdc_sol - USDC on Solana (~$0.001 fee)
pol - Polygon native (~$0.01 fee)
sol - Solana native (~$0.001 fee)
Higher Fee Options
btc - Bitcoin (~$2-3 fee)
eth - Ethereum (~$3-5 fee)
usdc_eth - USDC on Ethereum (~$3-5 fee)
usdt - USDT on Ethereum (~$3-5 fee)
Tip: Network fees are added to ensure merchants receive the full amount. Use usdc_pol or usdc_sol for the lowest customer fees while still accepting stablecoins.
cURL Example with redirect_url
curl -X POST https://coinpayportal.com/api/payments/create \
-H "Authorization: Bearer YOUR_TOKEN" \
-H "Content-Type: application/json" \
-d '{
"business_id": "business-123",
"amount_usd": 100.00,
"currency": "usdc_pol",
"redirect_url": "https://yoursite.com/order/success?id=12345"
}'Response
{
"success": true,
"payment": {
"id": "payment-456",
"business_id": "business-123",
"amount_usd": "100.00",
"amount_crypto": "100.50",
"currency": "usdc_pol",
"payment_address": "0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb",
"status": "pending",
"metadata": {
"network_fee_usd": 0.50,
"total_amount_usd": 100.50,
"redirect_url": "https://yoursite.com/order/success?id=12345"
},
"created_at": "2024-01-01T12:00:00Z",
"expires_at": "2024-01-01T12:15:00Z"
}
}Auto-Redirect After Payment
When redirect_url is provided, customers are automatically redirected back to your site 5 seconds after payment completion. A "Return to Merchant" button is also shown for immediate redirect.
/api/payments/:idRetrieve payment details by ID.
Node.js Example
const response = await fetch('https://coinpayportal.com/api/payments/payment-456', {
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
});
const data = await response.json();
console.log(data.payment.status);/api/payments/:id/qrGet QR code image for payment address.
Usage
<img src="https://coinpayportal.com/api/payments/payment-456/qr"
alt="Payment QR Code" />Business Collection
Business Collection payments allow the platform to collect payments from business users (subscription fees, service charges, etc.) with 100% forwarding to platform wallets.
Key Difference: Unlike regular payments (99.5% merchant / 0.5% platform), Business Collection forwards 100% of funds to the platform's collection wallet.
/api/business-collectionCreate a new business collection payment.
Request Body
{
"business_id": "business-123",
"amount": 99.99,
"currency": "USD",
"blockchain": "ETH", // BTC, BCH, ETH, POL, SOL
"description": "Monthly subscription fee",
"metadata": {
"plan": "premium",
"billing_period": "2024-01"
}
}Response
{
"success": true,
"payment": {
"id": "collection-456",
"payment_address": "0x1234...5678",
"amount": 99.99,
"currency": "USD",
"blockchain": "ETH",
"destination_wallet": "0xplatform...wallet",
"status": "pending",
"description": "Monthly subscription fee",
"expires_at": "2024-01-02T12:00:00Z",
"created_at": "2024-01-01T12:00:00Z"
}
}/api/business-collectionList business collection payments with optional filters.
Query Parameters
business_id - Filter by business (optional)
status - Filter by status: pending, confirmed, forwarded (optional)
limit - Results per page, default 50 (optional)
offset - Pagination offset (optional)
/api/business-collection/:idGet details of a specific business collection payment.
Collection Payment Statuses
pendingWaiting for payment
detectedPayment detected on blockchain
confirmedPayment confirmed
forwardingForwarding to platform wallet
forwarded100% forwarded to platform
expiredPayment request expired
Dashboard
/api/dashboard/statsGet payment statistics and recent activity.
Response
{
"success": true,
"stats": {
"total_payments": 150,
"successful_payments": 142,
"pending_payments": 5,
"failed_payments": 3,
"total_volume": "0.12345678",
"total_volume_usd": 5234.56
},
"recent_payments": [...]
}Settings
/api/settingsGet merchant notification settings.
/api/settingsUpdate notification preferences.
Request Body
{
"notifications_enabled": true,
"email_notifications": true,
"web_notifications": false
}Supported Cryptocurrencies
Native Cryptocurrencies
btcethpolsolUSDC Stablecoin (Multi-Chain)
Recommendation: Use usdc_pol or usdc_sol for the lowest fees while accepting stable USD-pegged payments.
Webhooks
Configure webhook URLs in your business settings to receive real-time payment notifications.
Webhook Events
payment.confirmedPayment confirmed on blockchain - safe to fulfill order
payment.forwardedFunds forwarded to your merchant wallet
payment.expiredPayment request expired (15 minute window)
test.webhookTest webhook (sent from dashboard)
Base Payload Fields
All webhook events include these fields:
| Field | Type | Description |
|---|---|---|
event | string | Event type |
type | string | Alias for event |
payment_id | string | Payment identifier |
business_id | string | Your business ID |
amount_crypto | string | Amount in crypto |
amount_usd | string | Amount in USD |
currency | string | Blockchain (ETH, BTC, etc.) |
status | string | Payment status |
timestamp | string | ISO 8601 timestamp |
Webhook Headers
Content-Type: application/json X-CoinPay-Signature: t=1702234567,v1=5d41402abc4b2a76b9719d911017c592 User-Agent: CoinPay-Webhook/1.0
The X-CoinPay-Signature header contains: t (Unix timestamp) and v1 (HMAC-SHA256 signature)
payment.confirmed Payload
Sent when payment is confirmed. Safe to fulfill the order.
{
"event": "payment.confirmed",
"type": "payment.confirmed",
"payment_id": "pay_abc123",
"business_id": "biz_xyz789",
"amount_crypto": "0.05",
"amount_usd": "150.00",
"currency": "ETH",
"status": "confirmed",
"received_amount": "0.05",
"confirmed_at": "2024-01-15T10:30:00Z",
"payment_address": "0x1234...5678",
"tx_hash": "0xabc...def",
"timestamp": "2024-01-15T10:30:00Z"
}payment.forwarded Payload
Sent when funds are forwarded to your wallet. Includes transaction hashes.
{
"event": "payment.forwarded",
"type": "payment.forwarded",
"payment_id": "pay_abc123",
"business_id": "biz_xyz789",
"amount_crypto": "0.05",
"amount_usd": "150.00",
"currency": "ETH",
"status": "forwarded",
"merchant_amount": 0.049,
"platform_fee": 0.001,
"tx_hash": "0xmerchant123...",
"merchant_tx_hash": "0xmerchant123...",
"platform_tx_hash": "0xplatform456...",
"timestamp": "2024-01-15T10:35:00Z"
}payment.expired Payload
Sent when payment expires without receiving funds.
{
"event": "payment.expired",
"type": "payment.expired",
"payment_id": "pay_abc123",
"business_id": "biz_xyz789",
"amount_crypto": "0.05",
"amount_usd": "150.00",
"currency": "ETH",
"status": "expired",
"reason": "Payment window expired (15 minutes)",
"expired_at": "2024-01-15T10:45:00Z",
"timestamp": "2024-01-15T10:45:00Z"
}Verifying Webhook Signatures
The signature is computed as HMAC-SHA256(timestamp.payload, secret)
JavaScript Example
import crypto from 'crypto';
function verifyWebhookSignature(payload, signatureHeader, secret) {
// Parse signature header (format: t=timestamp,v1=signature)
const parts = signatureHeader.split(',');
const signatureParts = {};
for (const part of parts) {
const [key, value] = part.split('=');
signatureParts[key] = value;
}
const timestamp = signatureParts.t;
const expectedSignature = signatureParts.v1;
// Check timestamp tolerance (300 seconds)
const timestampAge = Math.floor(Date.now() / 1000) - parseInt(timestamp, 10);
if (Math.abs(timestampAge) > 300) {
return false; // Reject old webhooks
}
// Compute expected signature
const signedPayload = `${timestamp}.${payload}`;
const computedSignature = crypto
.createHmac('sha256', secret)
.update(signedPayload)
.digest('hex');
// Timing-safe comparison
return crypto.timingSafeEqual(
Buffer.from(expectedSignature, 'hex'),
Buffer.from(computedSignature, 'hex')
);
}Important: Always verify webhook signatures before processing. Use express.raw() or equivalent to get the raw body for signature verification.
SDK Support: Use verifyWebhookSignature() and parseWebhookPayload() from the CoinPay SDK for easier integration.
Rate Limits & Fees
Rate Limits
• API Requests: 100 requests/minute
• Payment Creation: 10 payments/minute
• Webhook Retries: 3 attempts with exponential backoff
Platform Fees
• Platform Fee: 0.5% per transaction
• Network Fees: Paid by customer
• Minimum Payment: $1.00 USD
Error Codes
Error Response Format
{
"success": false,
"error": "Detailed error message here"
}