QBitFlow Documentation

    Complete guide to integrating cryptocurrency payments with QBitFlow

    Managing Subscriptions

    QBitFlow supports two types of subscription models: fixed recurring subscriptions and pay-as-you-go (PAYG) subscriptions. Both leverage smart contracts for automated, trustless billing.

    Subscription Types

    Fixed Recurring Subscriptions

    Traditional subscription model with fixed amounts charged at regular intervals (weekly, monthly, yearly).

    Best for SaaS, memberships

    Pay-As-You-Go (PAYG)

    Usage-based billing where customers are charged based on consumption, with billing cycles to collect the fees.

    Best for API services, utilities

    Creating Subscriptions

    Step-by-Step Process

    1. 1
      Create a Subscription Session

      Use the SDK or API to create a subscription session checkout with your desired parameters (frequency, trial period, etc.)

    2. 2
      Share the Checkout Link

      Send the generated checkout link to your customer

    3. 3
      Customer Completes Setup

      Customer visits the link, selects their cryptocurrency, and signs the allowance transaction

    4. 4
      Monitor via Webhook or Success URL

      Receive notification when the subscription is successfully created

    5. 5
      Fetch Subscription Status Regularly

      Poll the subscription status (e.g., once per day) to monitor billing cycles and handle status changes

    Creating a Fixed Subscription

    Create Recurring Subscription
    Set up a monthly subscription with a 7-day trial
    response = client.subscriptions.create_session(
    product_id=1,
    frequency=Duration(value=1, unit="months"), # Bill monthly
    trial_period=Duration(value=7, unit="days"), # 7-day trial (optional)
    min_periods=3, # Minimum billing periods (optional)
    webhook_url="https://your-domain.com/webhook",
    customer_uuid="customer-uuid",
    )
    print(response.link) # Send to customer

    Creating a Pay-As-You-Go Subscription

    Create PAYG Subscription
    Set up usage-based billing with monthly billing cycles
    response = client.pay_as_you_go.create_session(
    product_id=1,
    frequency=Duration(value=1, unit="months"), # Bill monthly
    free_credits=100, # Initial free credits (optional)
    webhook_url="https://your-domain.com/webhook",
    customer_uuid="customer-uuid",
    )
    print(response.link)

    Monitoring Subscriptions

    Regular Status Polling

    Unlike one-time payments that complete immediately, subscriptions are long-lived. You should fetch the subscription status regularly (e.g., once per day using a cron job) to monitor billing cycles, detect status changes, and take appropriate actions.

    Fetch Subscription Status
    Check subscription status and handle different states
    subscription = client.subscriptions.get("subscription-uuid")
    print(subscription.status, subscription.next_billing_date)
    # Handle different statuses
    # ... your business logic here ...

    Customer Self-Service Management

    Public Management Page

    QBitFlow provides a public subscription management page that customers can access without logging in. Customers can view their subscription details and perform actions like canceling, increasing allowance, or updating the max amount. All actions require wallet signature verification for security.

    Management Page URL:

    https://qbitflow.app/user/<ref-id>/manage?uuid=<subscription-uuid>

    Share this link with your customers so they can manage their subscriptions themselves. This reduces support overhead and empowers customers.

    Available Customer Actions

    Cancel Subscription

    Customers can cancel their subscription at any time. Requires wallet signature to verify ownership.

    Increase Allowance

    If the subscription shows "low_on_funds" status, customers can increase their allowance to ensure future billings succeed.

    Update Max Amount

    If crypto prices drop and the max amount is reached, customers can update it to resume billing.

    💡 Automation Tip: Set up a daily cron job to fetch all active subscriptions and check their status. When a status changes (e.g., from "active" to "past_due"), take appropriate action like sending notifications or revoking access. See the section for details on all possible states.