Python Subscription Billing with Paylio

Three lines of Python to check any user's subscription. Works with Django, Flask, FastAPI, and any Python framework.

Start Free

Get Started in 3 Lines

# Install

pip install paylio

# Check subscription

import paylio

paylio.api_key = "sk_live_xxx"

sub = paylio.get_subscription("user_123")
print(sub.status)       # "active"
print(sub.plan.name)    # "Pro"
print(sub.features)     # {"can_export": True, "seats": 10}

# Gate features

if sub.status == "active" and sub.features.get("can_export"):
    export_data(user_id)
else:
    return {"error": "Upgrade to Pro to export"}

Integration Steps

1

Install the SDK

Run pip install paylio to add the Python SDK. It supports Python 3.8+ with zero runtime dependencies beyond requests.

2

Set Your API Key

Set the PAYLIO_SECRET_KEY environment variable or pass it directly when initializing the client. Get your key from the Paylio dashboard.

3

Check Subscription

Call paylio.get_subscription(user_id) to get the full subscription state including status, plan name, billing period, and entitlements.

4

Gate Features with Entitlements

Read the features dict from the subscription response to conditionally enable premium functionality in your application logic.

FAQ

How do I add subscription billing in Python?

Install the paylio package with pip, set your API key, and call paylio.get_subscription(user_id). It returns the subscription status, plan details, and entitlements in a single call. The entire setup takes under 2 minutes.

Does the Paylio Python SDK work with Django, Flask, and FastAPI?

Yes. The SDK is a standard Python package with no framework dependencies. It works with Django, Flask, FastAPI, Starlette, or any Python application. Import it and call the API from your views, routes, or endpoints.

What does get_subscription return?

It returns a Subscription object with status (active, trialing, past_due, canceled, none), plan details (name, interval, amount), the current billing period (start and end dates), and a features dictionary mapping entitlement keys to their values.

How do I handle Paylio webhooks in Python?

Create an endpoint that accepts POST requests at your webhook URL. Use paylio.verify_webhook(payload, signature) to validate authenticity, then handle events like subscription.created, subscription.renewed, and subscription.canceled.

Start Billing with Python Today

Free up to 100 subscribers. No credit card required.

Get Your API Key