Skip to content

profullstack/coinpayportal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

99 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

CoinPay πŸš€

A non-custodial cryptocurrency payment gateway for e-commerce that enables merchants to accept crypto payments with automatic fee handling and real-time transaction monitoring.

🌟 Features

Core Payment Features

  • Multi-Chain Support: Bitcoin, Bitcoin Cash, Ethereum, Polygon, Solana, and USDC across major blockchains
  • Non-Custodial: Merchants maintain full control of their funds
  • Real-Time Processing: Instant payment detection and forwarding (no batching)
  • Automatic Fee Handling: 0.5% platform fee automatically deducted during forwarding
  • Multi-Business Support: Manage multiple businesses under one merchant account
  • Wallet Integration: Connect MetaMask, WalletConnect, or Phantom wallet
  • QR Code Payments: Easy-to-integrate payment QR codes
  • Webhook Notifications: Real-time payment callbacks for your system
  • CLI & SDK: Command-line interface and ESM module for programmatic integration
  • Exchange Rates: Real-time crypto/fiat rates via Tatum API

Subscription Plans & Entitlements

  • Starter Plan (Free): Up to 100 transactions/month, all supported chains, basic API access, email support
  • Professional Plan ($49/month): Unlimited transactions, priority support, advanced analytics, custom webhooks, white-label option
  • Crypto Payments for Subscriptions: Pay for upgrades using BTC, BCH, ETH, POL, or SOL
  • Usage Tracking: Real-time transaction counting with automatic limit enforcement
  • Feature Gating: API-level enforcement of plan-specific features

Business Collection

  • Platform Payments: Collect subscription fees and service charges from businesses
  • 100% Forwarding: Business collection payments forward entirely to platform wallets
  • Multiple Blockchains: Support for BTC, BCH, ETH, POL, SOL

πŸ—οΈ Architecture

CoinPay uses a modern, scalable architecture:

  • Frontend: Next.js 14+ with TypeScript and TailwindCSS
  • Backend: Next.js API Routes (serverless)
  • Database: Supabase (PostgreSQL)
  • Blockchain: Self-hosted wallet generation with RPC provider monitoring
  • Testing: Vitest for unit and integration tests

See Architecture Documentation for detailed system design.

πŸš€ Quick Start

Prerequisites

  • Node.js 18+ and npm/yarn/pnpm
  • Supabase account (free tier available)
  • RPC provider accounts (Alchemy, Infura, or public nodes)
  • Tatum API key (for exchange rates)

Installation

  1. Clone the repository:
git clone https://github.com/yourusername/coinpayportal.git
cd coinpayportal
  1. Install dependencies:
npm install
  1. Copy environment variables:
cp .env.example .env.local
  1. Configure your .env.local file with required credentials:
# Supabase
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_service_role_key

# Encryption
ENCRYPTION_KEY=your_32_byte_encryption_key

# RPC Providers
BITCOIN_RPC_URL=https://your-bitcoin-rpc
ETHEREUM_RPC_URL=https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY
POLYGON_RPC_URL=https://polygon-mainnet.g.alchemy.com/v2/YOUR_KEY
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com

# Platform Fee Wallets
PLATFORM_FEE_WALLET_BTC=your_btc_address
PLATFORM_FEE_WALLET_ETH=your_eth_address
PLATFORM_FEE_WALLET_POL=your_pol_address
PLATFORM_FEE_WALLET_SOL=your_sol_address

# Tatum API
TATUM_API_KEY=your_tatum_api_key

# Webhook
WEBHOOK_SIGNING_SECRET=your_webhook_secret
  1. Set up the database:
npm run db:setup
  1. Run the development server:
npm run dev
  1. Open http://localhost:3000 in your browser.

πŸ“– Documentation

πŸ’» Usage Examples

Creating a Payment Request (API)

const response = await fetch('/api/payments/create', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
    'Authorization': `Bearer ${token}`
  },
  body: JSON.stringify({
    businessId: 'your-business-id',
    amount: 100.00,
    currency: 'USD',
    blockchain: 'eth',
    merchantWalletAddress: '0x...',
    metadata: {
      orderId: 'ORDER-123',
      customerEmail: 'customer@example.com'
    }
  })
});

const payment = await response.json();
// Returns: { id, address, qrCode, amount, expiresAt }

Using the CLI

# Create a payment
coinpay payment create \
  --business-id abc123 \
  --amount 100 \
  --currency USD \
  --blockchain eth \
  --wallet 0x...

# Check payment status
coinpay payment status --id payment_xyz

# List businesses
coinpay business list

# Configure webhook
coinpay webhook set --url https://yoursite.com/webhook

Using the SDK

import { CoinPay } from '@coinpayportal/sdk';

const client = new CoinPay({
  apiKey: 'your-api-key',
  environment: 'production'
});

// Create payment
const payment = await client.payments.create({
  businessId: 'your-business-id',
  amount: 100,
  currency: 'USD',
  blockchain: 'eth',
  merchantWalletAddress: '0x...'
});

// Monitor payment
client.payments.on('confirmed', (payment) => {
  console.log('Payment confirmed:', payment.id);
});

Embedding Payment QR Code

<!-- Simple integration -->
<div id="coinpay-widget"
     data-business-id="your-business-id"
     data-amount="100"
     data-currency="USD"
     data-blockchain="eth">
</div>
<script src="https://coinpayportal.com/widget.js"></script>

πŸ” Security

  • Private keys are encrypted at rest using AES-256
  • All API routes require authentication
  • Rate limiting on all endpoints
  • Webhook signatures for verification
  • Multi-confirmation requirements before forwarding
  • See Security Documentation for details

πŸ§ͺ Testing

# Run all tests
npm test

# Run tests in watch mode
npm run test:watch

# Run tests with coverage
npm run test:coverage

# Run E2E tests
npm run test:e2e

πŸ“¦ Project Structure

coinpayportal/
β”œβ”€β”€ docs/                    # Documentation
β”‚   β”œβ”€β”€ ARCHITECTURE.md
β”‚   β”œβ”€β”€ API.md
β”‚   β”œβ”€β”€ DATABASE.md
β”‚   β”œβ”€β”€ SUBSCRIPTIONS.md    # Subscription plans & entitlements
β”‚   β”œβ”€β”€ BUSINESS_COLLECTION.md
β”‚   └── SECURITY.md
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                # Next.js app directory
β”‚   β”‚   β”œβ”€β”€ api/           # API routes
β”‚   β”‚   β”‚   β”œβ”€β”€ auth/      # Authentication endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ payments/  # Payment endpoints
β”‚   β”‚   β”‚   β”œβ”€β”€ businesses/ # Business management
β”‚   β”‚   β”‚   β”œβ”€β”€ business-collection/ # Platform payments
β”‚   β”‚   β”‚   β”œβ”€β”€ subscriptions/ # Subscription management
β”‚   β”‚   β”‚   └── entitlements/ # Entitlements API
β”‚   β”‚   β”œβ”€β”€ dashboard/     # Merchant dashboard
β”‚   β”‚   β”œβ”€β”€ pricing/       # Pricing & upgrade page
β”‚   β”‚   β”œβ”€β”€ docs/          # API documentation page
β”‚   β”‚   └── page.tsx       # Landing page
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ business/      # Business management components
β”‚   β”‚   └── docs/          # Documentation components
β”‚   β”œβ”€β”€ lib/              # Utility libraries
β”‚   β”‚   β”œβ”€β”€ auth/         # Authentication services
β”‚   β”‚   β”œβ”€β”€ blockchain/   # Blockchain services
β”‚   β”‚   β”œβ”€β”€ business/     # Business services
β”‚   β”‚   β”œβ”€β”€ entitlements/ # Entitlements & usage tracking
β”‚   β”‚   β”œβ”€β”€ payments/     # Payment processing
β”‚   β”‚   β”œβ”€β”€ subscriptions/ # Subscription management
β”‚   β”‚   β”œβ”€β”€ supabase/     # Supabase client
β”‚   β”‚   └── crypto/       # Encryption utilities
β”‚   └── types/            # TypeScript types
β”œβ”€β”€ supabase/
β”‚   └── migrations/       # Database migrations
β”œβ”€β”€ cli/                   # CLI package
β”œβ”€β”€ sdk/                   # SDK package
└── package.json

πŸ›£οΈ Roadmap

  • Core payment processing
  • Multi-chain support (BTC, BCH, ETH, POL, SOL, USDC)
  • Merchant dashboard
  • Webhook system
  • Subscription plans (Starter/Professional)
  • Entitlements & usage tracking
  • Business collection payments
  • Crypto-based subscription payments
  • Mobile SDK
  • WooCommerce plugin
  • Shopify app
  • Recurring payments (auto-renewal)
  • Fiat off-ramp
  • Advanced analytics dashboard

🀝 Contributing

Contributions are welcome! Please read our Contributing Guide for details.

πŸ“„ License

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

πŸ†˜ Support

πŸ™ Acknowledgments


Built with ❀️ by the CoinPay team

About

A non-custodial payment gateway for crypto e-commerce payments

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published