Repository avatar
AI Tools
v2.3.2
active

paygate-usdt

io.github.EzeLich/paygate-usdt

Non-custodial multi-chain USDT/USDC payment gateway, recurring subscriptions & x402 MCP tools.

Documentation

PayGate USDT v2.3 โ€” Non-Custodial Stablecoin Payment Gateway, Subscriptions & MCP Server

CI PayGate USDT MCP server PayGate USDT MCP connector License: MIT Python 3.10+ Protocol: x402 v2 MCP Native Custody: Zero

Accept USDT & USDC across 6 blockchains straight to your own self-custody wallet โ€” with Hosted Checkout Invoices, HMAC-SHA256 Signed Webhooks, FastAPI HTTP 402 (x402 v2) API Paywalls, Automated Telegram VIP Groups, and an AI-Agent MCP Server.

No custodial processor holds your funds. No Stripe / Whop / bank account requirements. No platform percentage cut.


Why Builders Choose PayGate USDT Over Custodial Processors

FeaturePayGate USDT v2.3Custodial Gateways / Whop / InviteMember
Settlement Destination100% direct buyer -> your wallet (Phantom, MetaMask, Ledger, Safe, Exchange)Held by intermediary; payout delays / freezes
Transaction Fees$0% cut on settlements (self-hosted MIT)1%โ€“10% + withdrawal minimums
Networks SupportedPolygon, BSC (BEP-20), Base, Arbitrum, Ethereum, Solana SPLLimited or custodian-locked
Hosted Invoice Pages + Webhooksโœ… /paygate/checkout/{id} + X-PayGate-Signature (HMAC-SHA256)Often requires merchant KYB/KYC
Non-Custodial SaaS Subscriptionsโœ… customer_ref + billing_days + /api/v1/paygate/subscriptions/check (renewal stacking, 0 MAX_UINT256 approvals)Requires cards or infinite token approvals
FastAPI HTTP 402 (x402 v2) Decoratorโœ… @require_usdt_payment(...) with PAYMENT-REQUIRED header + anti-replayRare / separate SDK
Telegram Paid VIP Automationโœ… 60-second bot onboarding, 1-time invite links, auto-kick on expiryHigh % revenue share
MCP Server for AI Agentsโœ… Streamable HTTP (2025-03-26, ping, resources, prompts) + Stdio MCPNot supported
Security & Reproducibility100% pure auditable Python, full pytest + GitHub Actions CIBlack-box binaries / closed SaaS

Architecture Overview

  Merchant / SaaS / AI Agent
        โ”‚
        โ”œโ”€โ”€ 1. Invoice API or MCP (`create_usdt_invoice`)
        โ”‚        โ””โ”€> Hosted Checkout URL (/paygate/checkout/{inv_id})
        โ”‚
        โ”œโ”€โ”€ 2. FastAPI `@require_usdt_payment` Route Guard
        โ”‚        โ””โ”€> Returns HTTP 402 + `PAYMENT-REQUIRED` (x402 v2 JSON)
        โ”‚
        โ””โ”€โ”€ 3. Multi-Tenant Telegram VIP Bot (`/vip` / `/start`)
                 โ”‚
                 โ–ผ
      Buyer transfers USDT / USDC directly to Merchant Wallet
      (Polygon ยท BSC BEP20 ยท Base ยท Arbitrum ยท Ethereum ยท Solana)
                 โ”‚
                 โ–ผ
      PayGate On-Chain RPC Verifier (live JSON-RPC + SQLite anti-replay)
                 โ”‚
                 โ”œโ”€โ”€ Signed `invoice.paid` Webhook (`X-PayGate-Signature: sha256=...`)
                 โ”œโ”€โ”€ Single-use Telegram Invite Link (`member_limit=1`) + Expiry Kick
                 โ””โ”€โ”€ HTTP 200 API Response Unlocked

30-Second Quickstarts

1. Protect any FastAPI Endpoint with HTTP 402 (x402 v2 Direct USDT/USDC)

from fastapi import FastAPI, Request
from paygate_sdk import require_usdt_payment

app = FastAPI()

@app.get("/api/pro-signal")
@require_usdt_payment(
    price_usd=5.0,
    recipient_wallet="0xYourEvmWalletAddress",
    networks=("base", "polygon", "arbitrum", "bsc"),
)
async def pro_signal(request: Request):
    return {"signal": "ETH/USDC breakout verified"}

Unpaid callers receive 402 Payment Required with an x402 v2 PAYMENT-REQUIRED header. Callers pass X-Payment-Network + X-Payment-Tx and PayGate verifies the stablecoin Transfer event on-chain with built-in anti-replay protection.

2. Create Hosted Checkout Links & Verify HMAC-SHA256 Webhooks

from paygate_sdk import PayGateClient, verify_webhook_signature

client = PayGateClient("https://chainguard-studio-production.up.railway.app")

res = client.create_invoice(
    title="SaaS Pro Seat (30 Days)",
    amount_usd=29.0,
    network="polygon",  # polygon | bsc | base | arbitrum | ethereum | solana
    merchant_wallet="0xYourEvmWalletAddress",
    webhook_url="https://yourapp.com/webhooks/paygate",
    webhook_secret="whsec_your_signing_secret",
)
print("Send buyer to:", res["checkout_url"])

# Inside your webhook receiver:
is_authentic = verify_webhook_signature(raw_body_bytes, request.headers["X-PayGate-Signature"], "whsec_your_signing_secret")

3. Verify On-Chain Transfers Standalone (OnChainPaymentVerifier)

from app.onchain_verifier import OnChainPaymentVerifier

verifier = OnChainPaymentVerifier()
result = verifier.verify(
    network="bsc",
    tx_hash="0x...",
    min_amount_usd=199.0,
    expected_recipient="0xYourBep20WalletAddress",
)
print(result.verified, result.amount_usd, result.token)

4. CLI & Local Stdio MCP Server (Claude Desktop / Cursor / OpenCode)

Run an instant hosted checkout link directly from your terminal:

pip install -e .
paygate-usdt invoice --title "VIP Access" --amount 49 --network polygon --wallet 0xYourWallet
paygate-usdt verify-tx --network bsc --tx 0x... --amount 199 --wallet 0xYourWallet

Or connect PayGate USDT as a local Stdio MCP server (mcpServers config):

{
  "mcpServers": {
    "paygate-usdt": {
      "command": "python",
      "args": ["-m", "paygate_sdk", "mcp"]
    }
  }
}

5. Runnable Examples, 1-Line Embed Widget & Docker

Add a non-custodial USDT/USDC pay button to any static site, GitHub README, or Markdown page in 1 URL or 1 <script> tag:

<a data-paygate-merchant="0xYourWallet" data-paygate-amount="29" data-paygate-network="polygon" data-paygate-title="Pro Access">
  Pay $29 USDT
</a>
<script src="https://chainguard-studio-production.up.railway.app/paygate/widget.js"></script>

Or generate a stateless 1-click checkout URL directly in Python:

from paygate_sdk import PayGateClient
url = PayGateClient().build_payment_url(
    merchant_wallet="0xYourWallet",
    amount_usd=29.0,
    network="polygon",
    title="Pro Plan (30d)",
)

6. Non-Custodial Recurring SaaS Subscriptions (No Infinite Approvals)

Accept recurring 30-day SaaS/API memberships directly in USDT/USDC without requesting MAX_UINT256 token allowances. Renewals paid early automatically stack remaining days:

from paygate_sdk import PayGateClient

client = PayGateClient("https://chainguard-studio-production.up.railway.app")

# 1. Check active entitlement & get a 1-Click pre-filled renewal link
sub = client.check_subscription(
    merchant_wallet="0xYourEvmWalletAddress",
    customer_ref="user_42",
    amount_usd=19.0,
    network="base",
    billing_days=30,
)
if not sub["active"]:
    print("Renew here:", sub["renewal_url"])
docker compose up --build

Run Tests Locally

git clone https://github.com/EzeLich/paygate-usdt.git
cd paygate-usdt
pip install -r requirements.txt
pytest -v

Zero external API keys or private wallet keys are required to run the test suite.


Hosted Cloud, 1-Click Passes & Done-For-You B2B Deployment

Want this running for your business without touching servers, RPC failovers, or webhook glue? Click any instant non-custodial checkout badge below (supports 1-Click MetaMask / Rabby / Phantom Browser Pay + automatic SHA-256 Receipt):

OptionPriceInstant 1-Click Checkout / Action
Open-Source Self-Hosted (MIT)$0Clone this repo, run with FastAPI/uvicorn + .env, 0% fees
30-Day Unlimited MCP & Pro API Pass$9 USDC/USDTโšก Pay $9 Base USDC/USDT โ€” Auto-Mints cg_live_ Key
Managed Cloud VIP Bot$29 USDT/mo (7-day free trial)Launch Bot Free in 60s
Lifetime White-Label Bot License$79 USDT one-timeโšก Pay $79 Polygon USDT/USDC
Turnkey B2B VIP Gate Deployment (24h)$199 USDT ($99 deposit)โšก Pay $99 Kickoff Deposit (Polygon) ยท Book B2B Scope
Custom Crypto Bot + API / Exchange Automation$499 USDT ($249 deposit)โšก Pay $249 Kickoff Deposit (Polygon) ยท Submit GitHub Inquiry