Menu

Explorer & Settings

Tempo Explorer Submit Project
Back to all projects

x402-Payment-Gateway

by Harshanandhan · Updated 5 months ago

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.

In the AI payments ecosystem

x402-Payment-Gateway is an early-stage project in the AI payments / x402 ecosystem. It currently has 0 GitHub stars and 0 forks.

README.md View on GitHub →

X402 Payment Gateway Demo

A modern, feature-rich payment gateway demonstration showcasing secure payment processing, transaction management, and API integration.

License Node Status

🚀 Features

  • Secure Payment Processing: Process credit card, debit card, and UPI payments
  • Transaction Management: Track and manage all transactions in real-time
  • Multiple Payment Methods: Support for various payment options
  • RESTful API: Well-documented API endpoints
  • Admin Dashboard: Monitor transactions and analytics
  • Payment Status Tracking: Real-time payment status updates
  • Refund Management: Process refunds with ease
  • Transaction History: Complete audit trail of all transactions
  • Webhook Support: Receive payment notifications
  • Test Mode: Sandbox environment for testing

📋 Table of Contents

🛠️ Installation

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn
  • Git

Clone the Repository

git clone https://github.com/Harshanandhan/x402-Payment-Gateway.git
cd x402-Payment-Gateway

Backend Setup

cd backend
npm install
cp .env.example .env
# Edit .env with your configuration
npm start

Frontend Setup

cd frontend
npm install
npm start

🚀 Quick Start

1. Start the Backend Server

cd backend
npm start

The API will be available at http://localhost:3000

2. Start the Frontend

cd frontend
npm start

The application will be available at http://localhost:5173

3. Test Payment

Navigate to the demo page and try a test payment:

  • Test Card Number: 4242 4242 4242 4242
  • Expiry: Any future date
  • CVV: Any 3 digits

📚 API Documentation

Base URL

http://localhost:3000/api/v1

Endpoints

Initialize Payment

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"
}

Process Payment

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 Transaction Status

GET /payments/status/:transaction_id

Refund Payment

POST /payments/refund
Content-Type: application/json

{
  "transaction_id": "txn_1234567890",
  "amount": 1000,
  "reason": "Customer request"
}

Get Transaction History

GET /payments/history?limit=10&offset=0

💳 Payment Methods

Supported Payment Options

  1. Credit/Debit Cards

    • Visa
    • Mastercard
    • American Express
    • Discover
  2. Digital Wallets

    • UPI
    • PayPal
    • Apple Pay
    • Google Pay
  3. Bank Transfer

    • Direct bank transfer
    • Net banking

🔒 Security

  • PCI DSS Compliance: Follows Payment Card Industry Data Security Standards
  • Encryption: All sensitive data encrypted in transit and at rest
  • Tokenization: Card details are tokenized and never stored directly
  • HTTPS Only: All API endpoints require HTTPS in production
  • Rate Limiting: Protection against brute force attacks
  • Input Validation: Comprehensive input sanitization

🧪 Testing

Test Cards

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

Run Tests

# Backend tests
cd backend
npm test

# Frontend tests
cd frontend
npm test

📁 Project Structure

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

🌟 Features Roadmap

  • Multi-currency support
  • Recurring payments
  • Payment links
  • QR code payments
  • Analytics dashboard
  • Export transactions (CSV, PDF)
  • Email notifications
  • SMS notifications
  • Fraud detection
  • 3D Secure authentication

🤝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

👥 Authors

  • Harshanandhan - Initial work - GitHub

🙏 Acknowledgments

  • Built with Node.js and React
  • Inspired by modern payment gateway solutions
  • Special thanks to the open-source community

📞 Support

For support, email [email protected] or create an issue in the GitHub repository.

⚠️ Disclaimer

This is a demonstration project for educational purposes. Do not use in production without proper security audits and compliance verification.


Made with ❤️ by Harshanandhan

All x402 projects →