PayGate Examples

E-commerce API

# Create PayGate for product catalog API
POST /api/v1/paygates
{
  "targetUrl": "https://store.example.com/api/products",
  "price": "0.005",
  "credits": 10,
  "method": "GET",
  "title": "Product Catalog API",
  "description": "Access to full product database with pricing"
}

# Generated PayGate: https://402ify.com/prod1234
# Users pay $0.005 for 10 API calls

AI Model API

# Create PayGate for AI inference endpoint
POST /api/v1/paygates
{
  "targetUrl": "https://ai.example.com/api/v1/generate",
  "price": "0.02",
  "credits": 1,
  "method": "POST",
  "title": "AI Text Generation",
  "description": "High-quality text generation per request"
}

# Generated PayGate: https://402ify.com/ai567890
# AI agents pay $0.02 per inference call

REST API with Multiple Methods

# Create PayGate supporting multiple HTTP methods for a REST API
POST /api/v1/paygates
{
  "targetUrl": "https://api.example.com/v1/users",
  "price": "0.01",
  "credits": 5,
  "method": "GET,POST,PUT,DELETE",
  "title": "User Management API",
  "description": "Full CRUD operations on user resources"
}

# Generated PayGate: https://402ify.com/users123
# Supports GET (list users), POST (create), PUT (update), DELETE (remove)
# Users pay $0.01 for 5 operations across any supported methods

High-Speed Trading API

# Create PayGate with fast payment processing for trading
POST /api/v1/paygates
{
  "targetUrl": "https://trading.example.com/api/v1/orders",
  "price": "0.05",
  "credits": 1,
  "method": "POST",
  "title": "High-Speed Trading API",
  "description": "Ultra-low latency order execution",
  "assumeValid": true
}

# Generated PayGate: https://402ify.com/trade123
# Skips blockchain verification for fastest payment processing
# Use when trusting facilitator settlement is acceptable

Premium Content

# Create PayGate for premium article
POST /api/v1/paygates
{
  "targetUrl": "https://blog.example.com/premium-article-123",
  "price": "0.10",
  "credits": 1,
  "method": "GET",
  "title": "Premium Market Analysis",
  "description": "In-depth cryptocurrency market analysis"
}

# Generated PayGate: https://402ify.com/blog4567
# Readers pay $0.10 for article access

PayGate Management

Update PayGate Price

# Update pricing for existing PayGate
PUT /api/v1/paygates/123
{
  "price": "0.01"
}

# Price updated from $0.005 to $0.01

Update PayGate Details

# Update title, description and require authentication
PUT /api/v1/paygates/123
{
  "title": "Enhanced Product Catalog API",
  "description": "Access to full product database with real-time pricing and inventory",
  "price": "0.008",
  "requireAuth": true,
  "assumeValid": false
}

Update PayGate Methods

# Update PayGate to support additional HTTP methods
PUT /api/v1/paygates/123
{
  "method": "GET,POST,PUT"
}

# Restrict PayGate to only support GET requests
PUT /api/v1/paygates/123
{
  "method": "GET"
}

Update Payment Address (Security)

# Update payment address if current address is compromised
PUT /api/v1/paygates/123
{
  "paymentAddress": "0xNEW_SECURE_WALLET_ADDRESS_HERE"
}

# Note: Payment address changes are encrypted and applied immediately.
# Future payments will be sent to the new address.

Update Credits

# Increase the number of credits per payment
PUT /api/v1/paygates/123
{
  "credits": 20
}

# Reduce credits for higher-value API calls
PUT /api/v1/paygates/123
{
  "credits": 1,
  "price": "0.10"
}

# Note: Credit changes only affect new purchases.
# Existing purchases retain their original credit count.

Comprehensive Update Example

# Update multiple fields including security-critical payment address
PUT /api/v1/paygates/123
{
  "title": "Enhanced Premium API",
  "description": "Updated with new features and security improvements",
  "price": "0.015",
  "paymentAddress": "0x742d35Cc6634C0532925a3b8c2414F4e456C10F4",
  "credits": 15,
  "requireAuth": true,
  "headerAuthMode": "hmac",
  "method": "GET,POST"
}

# All changes applied atomically in a single update

Payment Verification Settings

AssumeValid Option

The assumeValid parameter controls blockchain verification behavior:

Default (false) - Secure verification:

  • Payment is verified on blockchain after facilitator settlement

  • Slightly slower but ensures transaction is actually confirmed

  • Recommended for most use cases

Fast mode (true) - Skip verification:

  • Trusts facilitator settlement without blockchain confirmation

  • Faster payment processing (~200-1000ms saved)

  • Use when speed is critical and you trust the facilitator

# Secure verification (default)
{
  "assumeValid": false  # Verify on blockchain
}

# Fast processing
{
  "assumeValid": true   # Trust facilitator, skip verification
}

When to use assumeValid: true:

  • High-frequency trading APIs

  • Real-time gaming transactions

  • Time-sensitive operations

  • When facilitator trust is established

When to use assumeValid: false (default):

  • Financial applications

  • High-value transactions

  • When security is paramount

  • Most general use cases

Last updated