Financials
Autonomous financial operations - revenue, expenses, accounting, and agent payments via x402
Complete financial autonomy through Stripe's ecosystem plus x402 protocol for agent-to-agent payments. Every subscription, payment, invoice, expense, and reconciliation happens automatically.
Revenue Automation
Stripe Connect: Subscription & Payment Management
Automate the complete revenue lifecycle - from subscription creation to payment collection to revenue recognition.
import { $ } from 'sdk.do'
// Subscriptions managed automatically
on.Customer.subscribes(async (customer) => {
await $.Stripe.create.Subscription({
customer: customer.stripeId,
items: [
{ price: 'price_saas_dashboard_99', quantity: 1 },
{ price: 'price_per_transaction_002', quantity: 'metered' }
],
billing: 'automatic',
collection_method: 'charge_automatically'
})
})
// Metered usage tracked in real-time
on.Transaction.processed(async (transaction) => {
await $.Stripe.report.Usage({
subscription: transaction.customer.subscription,
quantity: 1, // 1 transaction
timestamp: Date.now()
})
})
// Invoices generated and collected automatically
every.month('1st', async () => {
await $.Stripe.generate.Invoices() // Automatic
await $.Stripe.collect.Payments() // Automatic
await $.Accounting.recognize.Revenue() // ASC-606
})Automated Revenue Recognition
---
$type: Business.Revenue
automation:
subscriptions:
provider: stripe_connect
billing: automatic
collection: automatic
dunning: automatic
recognition: asc_606
metered_usage:
tracking: real_time
reporting: automatic
aggregation: daily
billing: monthly
invoicing:
generation: automatic
delivery: automatic
reminders: automatic
collections: automatic
---
Zero manual work from subscription creation to revenue recognition.Cash Management
Stripe Financial Accounts: Embedded Banking Operations
Securely store funds, move money, and manage treasury operations directly within your platform. Stripe Financial Accounts provides FDIC-insured banking infrastructure with multi-currency support and instant money movement.
// Financial accounts for different purposes
await $.Stripe.create.FinancialAccounts({
operating: {
currency: 'usd',
purpose: 'daily_operations',
autoRouting: true,
externalTransfers: true
},
reserve: {
currency: 'usd',
purpose: 'reserves',
minimumBalance: 10000,
externalTransfers: false
},
payroll: {
currency: 'usd',
purpose: 'payroll',
scheduledPayouts: true,
externalTransfers: true
},
taxes: {
currency: 'usd',
purpose: 'tax_obligations',
escrow: true,
externalTransfers: false
}
})
// Automatic routing of revenue to accounts
on.Payment.received(async (payment) => {
await $.Treasury.route.Funds({
source: payment,
allocations: [
{ account: 'operating', percent: 0.70 },
{ account: 'reserve', percent: 0.15 },
{ account: 'taxes', percent: 0.15 }
]
})
})Expense Management
Stripe Issuing: Vendor-Specific Debit Cards
Issue physical or virtual debit cards with granular controls per vendor, category, or budget.
// Vendor-specific cards with automatic controls
await $.Stripe.issue.Card({
vendor: 'OpenAI',
type: 'virtual',
limits: {
daily: 1000,
monthly: 25000
},
categories: ['ai_services'],
autoDecline: {
wrongVendor: true,
overBudget: true
},
receiptMatching: 'automatic'
})
await $.Stripe.issue.Card({
vendor: 'Cloudflare',
type: 'virtual',
limits: {
monthly: 5000
},
categories: ['infrastructure'],
approvals: 'automatic'
})
// All expenses tracked automatically
on.Card.transaction(async (transaction) => {
await $.Accounting.record.Expense({
amount: transaction.amount,
vendor: transaction.merchant,
category: transaction.category,
receipt: transaction.receipt // Auto-attached
})
})Expense Automation
Not just platform costs (compute, data, AI) - any vendor expense can be managed through Stripe Issuing:
---
$type: Business.Expenses
cards:
- vendor: OpenAI
category: ai_inference
limit: 25000
period: monthly
- vendor: Anthropic
category: ai_inference
limit: 25000
period: monthly
- vendor: Cloudflare
category: infrastructure
limit: 5000
period: monthly
- vendor: Any
category: office_supplies
limit: 500
period: monthly
approval: required
- vendor: Any
category: software_tools
limit: 1000
period: monthly
approval: required
---
Every expense tracked, categorized, and reconciled automatically.Autonomous Accounting
Zero Manual Bookkeeping
// Everything happens automatically
every.transaction(async (transaction) => {
// 1. Record transaction
await $.Accounting.record.Transaction(transaction)
// 2. Categorize automatically
const category = await $.AI.categorize.Transaction(transaction)
// 3. Match to budget
await $.Budget.track.Spending(category, transaction.amount)
// 4. Update financials in real-time
await $.Financials.update.RealTime()
})
// Multi-dimensional tracking
await $.Accounting.configure.Dimensions([
'department', // Sales, Engineering, Operations
'project', // Product A, Product B, Initiative X
'customer', // Per-customer P&L
'agent' // Which agent incurred cost
])x402 & 402.do: Agent-to-Agent Payments
HTTP 402 Payment Required
The x402 protocol and 402.do service enable payments to and from bots/agents via HTTP and MCP.
import { x402 } from '402.do'
// Agent makes paid API call
const response = await fetch('https://api.bookkeeping.do/process', {
method: 'POST',
headers: {
'Authorization': 'Bearer agent_key_...',
'X-402-Budget': '1.00', // Max willing to pay
},
body: JSON.stringify({ transaction })
})
// If 402 Payment Required
if (response.status === 402) {
const paymentRequired = await response.json()
// { price: 0.02, payment_url: 'https://402.do/pay/...' }
// Agent pays automatically via x402
const paid = await x402.pay({
url: paymentRequired.payment_url,
amount: paymentRequired.price,
agent: 'agent_bookkeeper_01'
})
// Retry request with proof of payment
const result = await fetch(url, {
headers: {
'X-402-Payment': paid.proof
}
})
}
// Agent earns by providing service
app.post('/api/bookkeeping', async (c) => {
// Check if payment received via x402
const payment = await x402.verify(c.req.header('X-402-Payment'))
if (!payment || payment.amount < 0.02) {
return c.json({ price: 0.02, payment_url: x402.generatePaymentUrl() }, 402)
}
// Payment verified, provide service
const result = await $.Agent.Bookkeeper.process(await c.req.json())
return c.json(result)
})Agent-to-Agent Economy
---
$type: Agent.PaymentConfig
agent: bookkeeper_01
receives_payments:
via: x402
rates:
- service: transaction_processing
price: 0.02
- service: report_generation
price: 5.00
makes_payments:
via: x402
budget:
daily: 100
monthly: 2000
approved_services:
- ai_inference: 0.001/request
- data_enrichment: 0.10/record
---
Agents pay each other for services automatically via x402 protocol.MCP with Payments
Model Context Protocol servers can charge for tool usage:
// MCP server exposes paid tools
server.tool('process_transaction', async (params, context) => {
// Verify x402 payment
if (!context.payment || context.payment.amount < 0.02) {
throw new Payment402Required({ price: 0.02 })
}
// Payment verified, perform work
return await processTransaction(params)
})
// Agent uses paid MCP tool
const result = await mcp.call('process_transaction', {
transaction: data
}, {
payment: await x402.createPayment(0.02)
})Complete Financial Automation
---
$type: Business.Financials
revenue:
provider: stripe_connect
subscriptions: automatic
invoicing: automatic
collections: automatic
recognition: automatic
cash:
provider: stripe_financial_accounts
fdic_insured: true
multi_currency: true
routing: automatic
reserves: automatic
instant_transfers: true
expenses:
provider: stripe_issuing
cards: vendor_specific
tracking: automatic
categorization: automatic
reconciliation: automatic
receipt_matching: automatic
accounting:
bookkeeping: autonomous
reporting: real_time
dimensions: multi
tax: automated
agents:
payments: x402
economy: autonomous
budgets: automatic
---
# Zero Manual Financial Operations
From customer payment to agent compensation, every financial operation happens autonomously. Humans review dashboards and approve edge cases.Financial Visibility
Real-time dashboards show:
- Revenue: Subscriptions, usage, invoices, collections
- Cash: Account balances, interest earned, cash flow
- Expenses: Vendor spending, budget tracking, cost by category
- P&L: Real-time profitability by dimension
- Agent Economics: Agent earnings/spending via x402