SDK for AI agents to interact with Zerocard payment API
npm install zerocard-agent-kitThe Financial System for Clawdbot (OpenClaw/Moltbot)
Give your AI agent a compliant, secure financial life. This SDK connects your Clawdbot to the Zerocard network, allowing it to issue virtual cards and pay for services autonomously.
Clawdbot gave LLMs "arms and legs" on your computer:
* The Gateway (Ear): Listens to you via WhatsApp/Telegram.
* The Brain (LLM): Decides what to do.
* The Tools (Hands): Browses the web (Puppeteer), manages files (fs).
* The Wallet (Zerocard): This SDK. Allows the agent to spend money.
Without this, if your agent needs $20 for a Moltbook Premium subscription or a new API key, it hits a wall. With zerocard-agent-kit, it simply requests a card and completes the purchase.
``bash`
npm install zerocard-agent-kit
`typescript
import { ZerocardToolHandler } from 'zerocard-agent-kit';
// 1. Initialize with your agent API key
const handler = new ZerocardToolHandler({
apiKey: 'sk_agent_xxx',
});
// 2. When AI requests payment method
const result = await handler.handleToolCall({
amount: 9.99,
merchant: 'Spotify',
});
// 3. Return the result to your AI
console.log(result.content);
// Output:
// ✅ Using existing active card (no issuance fee charged).
//
// 💳 Card Details:
// • Card ID: card_123...
// • Card Number: * * 4242
// • CVV: *
// • Expiry: 12/2025
//
// 🔑 Secure Access Token Available
// • Token: eyJhbG...
// • Use generateWidgetHtml(token) to render secure card view if PAN is masked.`
For agents that need to use the card for online purchases (e.g. filling a checkout form with Puppeteer), sensitive details (PAN, CVV) are masked by default.
1. Check Response: You'll see ** in the pan.accessToken
2. Use Access Token: The response includes a secure .
3. "Card" the Details: Use the token to render a secure widget in your headless browser and "click-to-copy" the details.
`typescript
// Example Puppeteer Snippet in your Clawdbot
const html = zerocard.generateWidgetHtml(response.accessToken);
await page.setContent(html);
// Bots interact with the overlay elements to retrieve data
await page.click('#copy-card-pan');
const pan = await page.evaluate(() => navigator.clipboard.readText());
// Now fill the payment form
await page.type('#payment-form-card', pan);
`
This method remains PCI compliant because the sensitive data is never transmitted directly to your backend API; it is only rendered ephemerally in the browser context.
`typescript
import OpenAI from 'openai';
import { ZerocardToolHandler } from 'zerocard-agent-kit';
const openai = new OpenAI();
const zerocardHandler = new ZerocardToolHandler({ apiKey: 'sk_agent_xxx' });
const tools = [ZerocardToolHandler.getToolDefinition()];
const response = await openai.chat.completions.create({
model: 'gpt-4',
messages: [...],
tools,
});
// Handle tool call
if (response.choices[0].message.tool_calls) {
const toolCall = response.choices[0].message.tool_calls[0];
const args = JSON.parse(toolCall.function.arguments);
const result = await zerocardHandler.handleToolCall(args);
// Send result back to AI
messages.push({
role: 'tool',
tool_call_id: toolCall.id,
content: result.content,
});
}
`
`typescript
import Anthropic from '@anthropic-ai/sdk';
import { ZerocardToolHandler } from 'zerocard-agent-kit';
const claude = new Anthropic();
const zerocardHandler = new ZerocardToolHandler({ apiKey: 'sk_agent_xxx' });
const response = await claude.messages.create({
model: 'claude-3-5-sonnet-20241022',
max_tokens: 1024,
tools: [{
name: 'get_payment_method',
description: 'Get a virtual card to make a payment.',
input_schema: ZerocardToolHandler.getToolDefinition().function.parameters,
}],
messages: [...],
});
`
For custom integrations without the Tool Handler:
`typescript
import { ZerocardClient } from 'zerocard-agent-kit';
const client = new ZerocardClient({
apiKey: 'sk_agent_xxx',
});
const response = await client.getPaymentMethod({
amount: 29.99,
merchant: 'Amazon',
force_new: false,
});
console.log(response.card.number);
``
MIT