.do
Business

payments

Payment processing and transactions with Stripe integration and x402 agent/bot micropayments

payments

Unified payment processing with full Stripe integration including Stripe Connect for marketplace payments, plus support for x402 agent/bot micropayments (HTTP 402 Payment Required), PayPal, and other providers, featuring one-time and recurring payments, refunds, and fraud detection.

Overview

The payments primitive provides comprehensive payment processing including credit cards, digital wallets, bank transfers, cryptocurrency, payment links, checkout sessions, and automated reconciliation. Features full Stripe integration with Stripe Connect for marketplace payments, enabling customers to sell AI-delivered Services-as-Software. Includes x402 standard support for seamless agent-to-agent and bot-to-bot micropayments.

Quick Example

import { payments } from 'sdk.do'

// One-time payment
const payment = await payments.charge({
  amount: 9999, // $99.99 in cents
  currency: 'usd',
  customer: 'user-123',
  description: 'Pro Plan - Monthly',
  paymentMethod: 'pm_card_visa',
  metadata: {
    orderId: 'order-456',
    plan: 'pro',
  },
})

// x402 Agent/Bot Micropayment
const micropayment = await payments.x402({
  agent: 'agent-ai-writer',
  service: 'content-generation',
  amount: 50, // $0.50 per request
  currency: 'usd',
  metadata: {
    model: 'gpt-5',
    tokens: 1500,
    requestId: 'req-789',
  },
})

// Stripe Connect - Marketplace Seller Setup
const seller = await payments.connect.createAccount({
  type: 'express',
  email: '[email protected]',
  businessType: 'individual',
  capabilities: {
    cardPayments: { requested: true },
    transfers: { requested: true },
  },
  metadata: {
    userId: 'user-123',
    serviceType: 'ai-services',
  },
})

// Services-as-Software Sale (Platform takes fee)
const serviceSale = await payments.charge({
  amount: 5000, // $50.00
  currency: 'usd',
  customer: 'buyer-456',
  description: 'AI Content Generation Service',
  applicationFeeAmount: 500, // Platform takes 10% ($5.00)
  transferData: {
    destination: seller.id, // Seller gets $45.00
  },
  metadata: {
    serviceId: 'service-content-gen',
    sellerId: 'user-123',
    deliveryType: 'ai-automated',
  },
})

// Create checkout session for Services-as-Software
const session = await payments.createCheckout({
  lineItems: [
    {
      price: 'price_ai_service',
      quantity: 1,
    },
  ],
  customer: 'buyer-456',
  paymentIntentData: {
    applicationFeeAmount: 500,
    transferData: {
      destination: seller.id,
    },
  },
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel',
  metadata: {
    serviceType: 'ai-service',
    sellerId: 'user-123',
  },
})

// Subscription to AI Service (recurring revenue)
const subscription = await payments.createSubscription({
  customer: 'buyer-456',
  items: [{ price: 'price_ai_monthly' }],
  applicationFeePercent: 10, // Platform takes 10%
  transferData: {
    destination: seller.id,
  },
  metadata: {
    serviceId: 'ai-content-service',
    sellerId: 'user-123',
  },
})

// Payout to Seller
const payout = await payments.connect.payout({
  account: seller.id,
  amount: 45000, // $450.00
  currency: 'usd',
  method: 'instant', // or 'standard'
})

// Refund payment
await payments.refund(payment.id, {
  amount: 9999,
  reason: 'customer_request',
  reverseTransfer: true, // Also reverse the transfer to connected account
})

// Save payment method
const paymentMethod = await payments.saveMethod({
  customer: 'user-123',
  type: 'card',
  card: {
    number: '4242424242424242',
    expMonth: 12,
    expYear: 2025,
    cvc: '123',
  },
})

// Agent-to-Agent Payment Flow (x402)
on($.Service.requested, async (request) => {
  // Check if service requires payment
  const service = await $.Service.get(request.serviceId)

  if (service.pricing.model === 'per-request') {
    // Charge micropayment via x402
    const payment = await payments.x402({
      agent: request.agentId,
      service: service.id,
      amount: service.pricing.amount,
      currency: 'usd',
      metadata: { requestId: request.id },
    })

    if (payment.status === 'succeeded') {
      // Execute service
      await $.Service.execute(request)
    } else {
      // Return 402 Payment Required
      await send($.Service.paymentRequired, {
        requestId: request.id,
        paymentUrl: payment.paymentUrl,
      })
    }
  }
})

// Platform Revenue Analytics
const revenue = await payments.analytics.getPlatformRevenue({
  timeRange: { last: '30d' },
  breakdown: {
    byService: true,
    bySeller: true,
    byPaymentMethod: true,
  },
})

console.log(`Total Revenue: $${revenue.total / 100}`)
console.log(`Platform Fees: $${revenue.platformFees / 100}`)
console.log(`Seller Payouts: $${revenue.sellerPayouts / 100}`)

Core Capabilities

  • x402 Standard - Agent/bot micropayments protocol
  • Stripe Connect - Marketplace payments and seller payouts
  • Services-as-Software - Enable customers to sell AI services
  • Multi-Provider - Stripe, PayPal, Square, and more
  • Payment Methods - Cards, wallets, bank transfers, crypto
  • Checkout Sessions - Hosted checkout pages
  • Fraud Detection - Automated fraud prevention
  • Refunds - Full and partial refund processing
  • Revenue Sharing - Platform fees and automatic splits

Access Methods

SDK

TypeScript/JavaScript library for payments

await payments.charge({ amount: 9999, currency: 'usd', customer: 'user-123' })

SDK Documentation

CLI

Command-line tool for payment operations

do payment charge 99.99 --customer user-123 --currency usd

CLI Documentation

API

REST/RPC endpoints for payment processing

curl -X POST https://api.do/v1/payments/charge -d '{"amount":9999,"customer":"user-123"}'

API Documentation

MCP

Model Context Protocol for AI-driven payments

Charge user-123 $99.99 for the Pro Plan subscription

MCP Documentation

Subdomain Architecture

The payments primitive uses infinite free subdomains for payment providers and methods:

payments.do                        # Root - Payment processing
├── stripe.payments.do             # Stripe provider
├── paypal.payments.do             # PayPal provider
├── square.payments.do             # Square provider
├── x402.payments.do               # Agent/bot micropayments
└── {custom}.payments.do           # Custom payment providers

Child Primitives

  • plans - Subscription plan management
  • products - Pricing products and SKUs

Child Primitives

  • plans - Subscription plan management
  • products - Pricing products and SKUs
  • services - Services-as-Software monetization
  • webhooks - Payment event notifications
  • analytics - Revenue and payment analytics
  • agents - AI agents with micropayments