๐Ÿ’ง Spraay + Stripe Machine Payments

March 23, 2026 ยท View on GitHub

Hybrid x402 + Stripe gateway for AI agent commerce.

Agents pay USDC via x402. Spraay executes multi-chain DeFi operations. Stripe settles the fiat equivalent into the merchant's dashboard โ€” with tax, reporting, refunds, and fraud protection built in.

Agent (wallet)                    Merchant
    โ”‚                                 โ”‚
    โ”‚  1. POST /batch-payment         โ”‚
    โ”‚  2. x402: pay \$0.01 USDC       โ”‚
    โ”‚                                 โ”‚
    โ–ผ                                 โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                โ”‚
โ”‚  x402 Middleware   โ”‚                โ”‚
โ”‚  (verify payment)  โ”‚                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚
         โ”‚                            โ”‚
         โ–ผ                            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”                โ”‚
โ”‚  Spraay Gateway    โ”‚                โ”‚
โ”‚  (on-chain exec)   โ”‚                โ”‚
โ”‚  13 chains, 76+    โ”‚                โ”‚
โ”‚  DeFi primitives   โ”‚                โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜                โ”‚
         โ”‚                            โ”‚
         โ–ผ                            โ–ผ
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”   โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚  Base / Ethereum   โ”‚   โ”‚ Stripe Dashboard โ”‚
โ”‚  Solana / Bitcoin  โ”‚   โ”‚ PaymentIntent    โ”‚
โ”‚  + 9 more chains   โ”‚   โ”‚ Tax ยท Refunds    โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜   โ”‚ Reporting ยท API  โ”‚
                         โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

Why this exists

AI agents need to pay for services. The internet has two payment rails:

  • Crypto (x402) โ€” instant, global, no accounts, perfect for agents
  • Fiat (Stripe) โ€” tax compliant, enterprise-ready, merchants already use it

This hybrid gateway bridges both. The agent pays crypto. The merchant sees fiat. Everyone's happy.

Quick Start

git clone https://github.com/plagtech/spraay-stripe-machine-payments.git
cd spraay-stripe-machine-payments
npm install
cp .env.example .env
# Fill in PAY_TO_ADDRESS and STRIPE_SECRET_KEY
npm run dev

Endpoints

MethodPathx402 PriceWhat happens
POST/batch-payment$0.01 USDCSpraay sends tokens to multiple recipients โ†’ Stripe records fiat
POST/payroll$0.05 USDCSpraay runs crypto payroll โ†’ Stripe creates invoice record
POST/ai/inference$0.03 USDCSpraay calls AI model (43+ providers) โ†’ Stripe tracks usage
POST/rtp/task$0.05 USDCSpraay hires a robot via RTP โ†’ Stripe records the transaction
GET/discoverFreeReturns full endpoint catalog and architecture info

The Hybrid Flow (step by step)

1. Agent discovers the API

curl http://localhost:4021/discover

Returns endpoint catalog, pricing, supported chains, and Stripe integration details.

2. Agent pays USDC and triggers an operation

import { withPaymentInterceptor } from "@x402/axios";
import axios from "axios";

const api = withPaymentInterceptor(
  axios.create({ baseURL: "http://localhost:4021" }),
  walletClient // agent's wallet
);

// Agent pays \$0.01 USDC โ†’ Spraay batch sends โ†’ Stripe records
const result = await api.post("/batch-payment", {
  chain: "base",
  token: "USDC",
  recipients: ["0xAlice...", "0xBob...", "0xCharlie..."],
  amounts: ["10.00", "25.00", "15.00"],
});

3. Response includes both on-chain and Stripe data

{
  "txHash": "0xabc123...",
  "recipients": 3,
  "totalAmount": "50.00",
  "chain": "base",
  "stripe": {
    "stripe_payment_intent_id": "pi_3abc123...",
    "stripe_status": "requires_capture"
  }
}

4. Merchant sees everything in Stripe Dashboard

The PaymentIntent shows up in the merchant's Stripe Dashboard with:

  • Amount in USD
  • Metadata (chain, number of recipients, Spraay endpoint)
  • Full tax calculation, refund, and reporting tooling

Configuration

Testnet (default)

PAY_TO_ADDRESS=0xYourAddress
STRIPE_SECRET_KEY=sk_test_...
NETWORK=eip155:84532
FACILITATOR_URL=https://x402.org/facilitator

Mainnet

PAY_TO_ADDRESS=0xYourAddress
STRIPE_SECRET_KEY=sk_live_...
NETWORK=eip155:8453
FACILITATOR_URL=https://api.cdp.coinbase.com/platform/v2/x402

Stripe machine payments must be enabled for your account โ€” request access here.

What is Spraay?

Spraay is a multi-chain batch payment protocol and x402 gateway. It provides 76+ paid API endpoints across 16 categories and 13 blockchains:

  • Batch Payments โ€” send tokens to hundreds of recipients in one tx
  • Payroll โ€” recurring crypto payroll
  • Token Swaps โ€” DEX routing across chains
  • Bridge โ€” cross-chain asset transfers
  • AI Inference โ€” 43+ models via BlockRun
  • Robot Task Protocol (RTP) โ€” hire robots for physical tasks
  • Agent Wallets โ€” managed wallets for AI agents
  • Escrow, Staking, NFTs, Governance, Oracle, ENS โ€” and more

Live gateway: gateway.spraay.app ยท Docs: docs.spraay.app ยท MCP Server: @plagtech/spraay-x402-mcp

How Stripe fits

Stripe's machine payments support lets merchants accept payments from AI agents. Combined with Spraay:

  • Agent side: pays USDC via x402 (no account, no API key, no subscription)
  • Merchant side: sees every payment in Stripe Dashboard (USD, with tax/reporting)
  • Execution: Spraay handles the actual DeFi operation on-chain

This is the "best of both worlds" โ€” crypto speed for agents, fiat compliance for businesses.

License

MIT