Platform Integration Guide
Use PayDirect as the payment infrastructure layer for your platform. Provision wallets for every user and agent, handle token transfers, and collect revenue — all via REST API.
PLATFORM LEVEL (created once, manually)
├── Liquidity Workspace → Smart Wallet (token reserve for OTC swaps)
└── Revenue Workspace → Smart Wallet (receives fees, forwards to treasury)
└── settlement_address → External treasury wallet
USER LEVEL (created per user, via API on sign-up)
├── User "alice@example.com" → Smart Wallet (prepaid balance)
├── User "bob@example.com" → Smart Wallet (prepaid balance)
└── ...
AGENT / PRODUCT LEVEL (created per listing, via API)
├── Agent "Content Strategist" → Smart Wallet (receives earnings)
├── Agent "Data Analyst Pro" → Smart Wallet (receives earnings)
└── ...Every entity gets its own PayDirect workspace + smart wallet. Smart wallets are gasless — no ETH needed for token transfers. The platform controls all wallets via their API keys.
Liquidity Workspace
Holds your token reserve (e.g. ADAO). Used to fulfill OTC token purchases. When users buy tokens, this wallet sends them.
Revenue Workspace
Receives platform fees. Set a settlement address to auto-forward revenue to your treasury. PayDirect takes its fee on forwarding (tiered: Free 0.75%/1.5%, Pro 0.5%/1.0%, Enterprise 0.25%/0.5% for ADAO/USDC-ETH).
Environment Variables
# PayDirect API
PAYDIRECT_BASE_URL=https://www.paydirect.com
PAYDIRECT_ADMIN_SECRET=<your admin API secret>
# Liquidity Workspace (holds token reserve)
LIQUIDITY_WORKSPACE_ID=<workspace id>
LIQUIDITY_API_KEY=<pd_live_... key>
LIQUIDITY_WALLET=<smart wallet 0x address>
# Revenue Workspace (receives platform fees)
REVENUE_WORKSPACE_ID=<workspace id>
REVENUE_API_KEY=<pd_live_... key>
REVENUE_WALLET=<smart wallet 0x address>
# Token config
ADAO_TOKEN_ADDRESS=0x1ef7Be0aBff7d1490e952eC1C7476443A66d6b72async function onUserSignUp(user: { name: string; email: string }) {
// 1. Create PayDirect workspace
const wsRes = await fetch(`${PAYDIRECT_URL}/api/v1/workspaces`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${ADMIN_SECRET}`,
},
body: JSON.stringify({
name: `User — ${user.email}`,
ownerEmail: user.email,
platform: "yourplatform",
webhookUrl: "https://yourplatform.com/api/webhooks/paydirect",
}),
});
const { workspaceId, walletAddress, apiKeys } = await wsRes.json();
// 2. Create smart wallet (gasless) + set as default
const swRes = await fetch(
`${PAYDIRECT_URL}/api/v1/workspaces/${workspaceId}/smart-wallet`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${ADMIN_SECRET}`,
},
body: JSON.stringify({ setDefault: true }),
}
);
const { smartWallet } = await swRes.json();
// 3. Store credentials in your database
await db.users.update(user.id, {
paydirectWorkspaceId: workspaceId,
paydirectApiKey: apiKeys.live,
walletAddress: smartWallet.address,
});
return smartWallet.address;
}Two API calls per user: One to create the workspace (returns API keys), one to enable the smart wallet (returns wallet address). Both are idempotent.
User clicks "Buy 500 ADAO" ($2.50 USDC)
│
├─ Leg 1: DEBIT user
│ POST /api/v1/payouts (user's API key)
│ → $2.50 USDC from User Wallet → Revenue Wallet
│
├─ Leg 2: CREDIT user
│ POST /api/v1/payouts (liquidity API key)
│ → 500 ADAO from Liquidity Wallet → User Wallet
│
└─ Leg 3: SETTLEMENT (automatic)
Revenue Workspace forwards USDC → Your Treasury
(PayDirect takes 1.5% settlement fee on USDC for Free tier)async function buyTokens(userId: string, adaoAmount: number) {
const user = await db.users.findById(userId);
const usdcCost = (adaoAmount * ADAO_PRICE_USD).toFixed(2);
// Leg 1: Debit USDC from user → revenue wallet
await fetch(`${PAYDIRECT_URL}/api/v1/payouts`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${user.paydirectApiKey}`,
},
body: JSON.stringify({
tokenSymbol: "USDC",
amount: usdcCost,
destinationAddress: REVENUE_WALLET,
walletType: "smart_wallet",
idempotencyKey: `swap-${userId}-${Date.now()}-debit`,
}),
});
// Leg 2: Credit ADAO from liquidity → user wallet
await fetch(`${PAYDIRECT_URL}/api/v1/payouts`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${LIQUIDITY_API_KEY}`,
},
body: JSON.stringify({
tokenSymbol: "ADAO",
amount: String(adaoAmount),
destinationAddress: user.walletAddress,
walletType: "smart_wallet",
idempotencyKey: `swap-${userId}-${Date.now()}-credit`,
}),
});
}No built-in subscriptions: PayDirect does not have a native recurring payment engine. Implement billing as a cron job on your backend that calls the payouts API monthly.
// Cron job: runs monthly (or daily to check due dates)
async function processSubscriptions() {
const due = await db.subscriptions.findDue(); // WHERE next_billing_at <= NOW()
for (const sub of due) {
const user = await db.users.findById(sub.userId);
// Check balance first
const balRes = await fetch(`${PAYDIRECT_URL}/api/v1/wallet/balance`, {
headers: { "Authorization": `Bearer ${user.paydirectApiKey}` },
});
const balance = await balRes.json();
const adaoBalance = parseFloat(balance.smartWallet?.adao || balance.adao || "0");
if (adaoBalance < sub.totalCost) {
await db.subscriptions.pause(sub.id);
await notifyUser(user, "Insufficient ADAO balance");
continue;
}
// Pay agent (95%)
const agentAmount = (sub.totalCost * 0.95).toFixed(4);
await fetch(`${PAYDIRECT_URL}/api/v1/payouts`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${user.paydirectApiKey}`,
},
body: JSON.stringify({
tokenSymbol: "ADAO",
amount: agentAmount,
destinationAddress: sub.agentWalletAddress,
walletType: "smart_wallet",
idempotencyKey: `sub-${sub.id}-${sub.period}-agent`,
}),
});
// Platform fee (5%)
const feeAmount = (sub.totalCost * 0.05).toFixed(4);
await fetch(`${PAYDIRECT_URL}/api/v1/payouts`, {
method: "POST",
headers: {
"Content-Type": "application/json",
"Authorization": `Bearer ${user.paydirectApiKey}`,
},
body: JSON.stringify({
tokenSymbol: "ADAO",
amount: feeAmount,
destinationAddress: REVENUE_WALLET,
walletType: "smart_wallet",
idempotencyKey: `sub-${sub.id}-${sub.period}-fee`,
}),
});
await db.subscriptions.markBilled(sub.id);
}
}// Check a user's balance
const res = await fetch(`${PAYDIRECT_URL}/api/v1/wallet/balance`, {
headers: { "Authorization": `Bearer ${user.paydirectApiKey}` },
});
const balance = await res.json();
// Response:
// {
// "address": "0xEOA...",
// "eth": "0.001",
// "usdc": "50.00",
// "adao": "10000.00",
// "smartWallet": {
// "address": "0xSmartWallet...",
// "eth": "0.00",
// "usdc": "25.00",
// "adao": "5000.00"
// },
// "defaultWalletType": "smart_wallet"
// }Workspace Management (admin auth)
/api/v1/workspaces/api/v1/workspaces/:id/smart-wallet/api/v1/workspaces/:id/smart-walletTransfers (workspace API key auth)
/api/v1/payouts/api/v1/wallet/balance/api/v1/payoutsWebhooks
/api/v1/webhooks| Transaction | PayDirect Fee | Notes |
|---|---|---|
| Payout (wallet → wallet) | 0% | Direct transfers via /api/v1/payouts have no fee |
| Settlement forwarding (USDC) | 1.5% Free / 1.0% Pro / 0.5% Enterprise | When revenue workspace forwards to your treasury |
| Settlement forwarding (ETH) | 1.5% Free / 1.0% Pro / 0.5% Enterprise | When revenue workspace forwards to your treasury |
| Settlement forwarding (ADAO) | 0.75% Free / 0.5% Pro / 0.25% Enterprise | Discounted rate for ADAO |
| Smart wallet creation | Free | No cost to create wallets |
| Gas (smart wallet) | Sponsored | CDP Paymaster covers gas for smart wallet transactions |
| Event | When |
|---|---|
payout.completed | Token transfer succeeded |
payout.failed | Token transfer failed |
payment.detected | Incoming deposit detected on-chain |
payment.confirmed | Block confirmations met |
payment.forwarded | Settlement forwarded to merchant |
payment.failed | Settlement failed |
All webhooks include an X-PayDirect-Signature HMAC-SHA256 header for verification. See the Webhooks docs for details.
| Plan | Limit | Notes |
|---|---|---|
| Free | 100 req/min | Per API key |
| Pro | 1,000 req/min | Per API key |
Each workspace gets its own API key with its own rate limit bucket. Admin secret requests are not rate-limited. Workspace creation has no explicit limit but should be staggered for best performance.
