Copperx Docs
LoginGet Started
  • 🏠 Getting Started
    • Introduction to Copperx
    • Use Cases: How You Can Use Copperx
    • Key Concepts & Terminology
  • 🔑Setup & Configuration
    • Setup an account
      • Payment Configuration
      • Business Details
      • Apply your Branding
      • Manage Promo Codes
    • Environments (Testnet vs Mainnet)
    • How to Generate an API Key
  • 💳 Integrate Payments
    • Accept One-Time Crypto Payments
    • Accept Crypto Subscriptions
    • Create Invoices
    • Create a Recurring Invoices
    • Webhooks & Events
  • Error Handling & Troubleshooting
  • 📚API & Reference
    • Checkout Session API
    • Invoice API
    • Webhook Events
    • Authentication & Security
  • API Reference
  • 🔗No-Code Tools
    • Payment Link
    • Recurring Subscription
    • Recurring Invoice
    • Crypto Invoice
  • 🔌Integrations
    • WooCommerce
    • Zapier
    • Stripe
    • BigCommerce
    • Magento
  • ⚙️Support
    • Clear Your Stuck Payments
Powered by GitBook
On this page
  1. Integrate Payments

Accept Crypto Subscriptions

🚀 How It Works

✅ Step 1: Create a Product

Every subscription plan is associated with a product. Create the product first using the following API request:

curl --request POST \
  --url https://api.copperx.dev/api/v1/products \
  --header 'Authorization: Bearer {API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "name": "Pro Membership",
    "description": "Monthly plan for premium users",
    "isActive": true,
    "unitLabel": "month",
    "url": "https://example.com/product",
    "metadata": {
      "category": "SaaS"
    },
    "visibility": 10,
    "defaultPriceData": {
      "currency": "usdc",
      "unitAmount": 50000000,
      "interval": "month",
      "intervalCount": 1,
      "type": "recurring"
    }
  }'

The response will include a unique productId. Save this for the next step.


✅ Step 2: Create a Subscription Checkout Session

Using the created product’s ID, generate a checkout session to enable the user to subscribe:

curl --request POST \
  --url https://api.copperx.dev/api/v1/checkout/sessions \
  --header 'Authorization: Bearer {API_KEY}' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "mode": "subscription",
    "lineItems": {
      "data": [
        {
          "priceData": {
            "currency": "usdc",
            "unitAmount": "50000000",
            "interval": "month",
            "productId": "{PRODUCT_ID}"
          }
        }
      ]
    },
    "successUrl": "https://yourapp.com/success?session_id={CHECKOUT_SESSION_ID}",
    "cancelUrl": "https://yourapp.com/cancel"
  }'

The API response will provide a hosted checkout session URL. Redirect your user to this URL to complete the subscription.


✅ Step 3: Automate Recurring Billing

Copperx’s smart contracts automatically handle the recurring charges based on the interval (monthly, yearly, etc.) and send blockchain-verified payment confirmations.


✅ Step 4: Stay Updated with Webhooks

Copperx sends webhook events for key actions:

  • customer.subscription.created

  • customer.subscription.started

  • customer.subscription.unpaid

Use these events to manage access and provide real-time updates to your users.

PreviousAccept One-Time Crypto PaymentsNextCreate Invoices

Last updated 6 days ago

💳