Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

💧 Spraay + Stripe Machine Payments

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

Method Path x402 Price What happens
POST /batch-payment $0.01 USDC Spraay sends tokens to multiple recipients → Stripe records fiat
POST /payroll $0.05 USDC Spraay runs crypto payroll → Stripe creates invoice record
POST /ai/inference $0.03 USDC Spraay calls AI model (43+ providers) → Stripe tracks usage
POST /rtp/task $0.05 USDC Spraay hires a robot via RTP → Stripe records the transaction
GET /discover Free Returns 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.

Related

License

MIT

About

Hybrid x402 + Stripe machine payments: agents pay USDC via x402, Spraay executes multi-chain DeFi ops, Stripe settles fiat for merchants

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages