x402 is an open payment protocol by Coinbase that revives HTTP 402 status for instant stablecoin payments over HTTP, enabling monetized APIs and content on blockchains like Base or Solana. It supports chain-agnostic, agentic payments without user accounts, using facilitators for verification and settlement of USDC transfers.
x402-Payment-Gateway is an early-stage project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.
A modern, feature-rich payment gateway demonstration showcasing secure payment processing, transaction management, and API integration.
git clone https://github.com/Harshanandhan/x402-Payment-Gateway.git
cd x402-Payment-Gateway
cd backend
npm install
cp .env.example .env
# Edit .env with your configuration
npm start
cd frontend
npm install
npm start
cd backend
npm start
The API will be available at http://localhost:3000
cd frontend
npm start
The application will be available at http://localhost:5173
Navigate to the demo page and try a test payment:
http://localhost:3000/api/v1
POST /payments/initialize
Content-Type: application/json
{
"amount": 1000,
"currency": "USD",
"customer": {
"name": "John Doe",
"email": "[email protected]",
"phone": "+1234567890"
},
"description": "Product Purchase"
}
Response:
{
"success": true,
"transaction_id": "txn_1234567890",
"payment_token": "tok_abcdefgh123456",
"amount": 1000,
"currency": "USD",
"status": "pending"
}
POST /payments/process
Content-Type: application/json
{
"transaction_id": "txn_1234567890",
"payment_method": "card",
"card_details": {
"number": "4242424242424242",
"expiry_month": "12",
"expiry_year": "2025",
"cvv": "123"
}
}
GET /payments/status/:transaction_id
POST /payments/refund
Content-Type: application/json
{
"transaction_id": "txn_1234567890",
"amount": 1000,
"reason": "Customer request"
}
GET /payments/history?limit=10&offset=0
Credit/Debit Cards
Digital Wallets
Bank Transfer
| Card Number | Brand | Result |
|---|---|---|
| 4242 4242 4242 4242 | Visa | Success |
| 4000 0000 0000 0002 | Visa | Declined |
| 5555 5555 5555 4444 | Mastercard | Success |
| 3782 822463 10005 | Amex | Success |
# Backend tests
cd backend
npm test
# Frontend tests
cd frontend
npm test
x402-Payment-Gateway/
├── backend/
│ ├── src/
│ │ ├── controllers/
│ │ ├── models/
│ │ ├── routes/
│ │ ├── middleware/
│ │ ├── utils/
│ │ └── config/
│ ├── tests/
│ ├── package.json
│ └── server.js
├── frontend/
│ ├── public/
│ ├── src/
│ │ ├── components/
│ │ ├── pages/
│ │ ├── services/
│ │ ├── styles/
│ │ └── utils/
│ ├── package.json
│ └── index.html
├── docs/
├── .gitignore
├── LICENSE
└── README.md
Contributions are welcome! Please follow these steps:
git checkout -b feature/AmazingFeature)git commit -m 'Add some AmazingFeature')git push origin feature/AmazingFeature)This project is licensed under the MIT License - see the LICENSE file for details.
For support, email [email protected] or create an issue in the GitHub repository.
This is a demonstration project for educational purposes. Do not use in production without proper security audits and compliance verification.
Made with ❤️ by Harshanandhan
Your AI trading terminal assistant for US stocks, commodities, forex, and crypto.
The agent-native LLM router for autonomous agents. 55+ models (8 free), <1ms local routing, USDC payments on Base & Solana via x402.
A payments protocol for the internet. Built on HTTP.
A local-first AI agent with persistent memory, emotional intelligence, and a peer-to-peer skills economy.
The trust layer for agent-to-agent commerce — natural-language mandates, ERC-7710 delegated permissions, x402 payments, escrow, and dispute resolution as one open, catch-all Agent Skill / Claude Code plugin.
The AI agent with a wallet — spends USDC autonomously to get real work done. Apache-2.0, TypeScript.