ulfblk-billing
Stripe billing integration: customers, subscriptions, checkout sessions, and webhooks.
Features
- Protocol-first: BillingProvider protocol allows swapping Stripe for Paddle, LemonSqueezy, etc.
- httpx client: No Stripe SDK dependency - direct REST API calls with form-encoded bodies
- Webhook verification: HMAC-SHA256 signature validation using stdlib (no external deps)
- Tenant-aware: Optional multitenant isolation via metadata injection
- Lifecycle managed: async context manager with start/stop for httpx client
Install
uv add ulfblk-billing
Quick Start
from bloque_billing import (
BillingService, BillingSettings, CustomerCreate,
CheckoutCreate, CheckoutMode, StripeProvider,
)
settings = BillingSettings(
api_key="sk_test_...",
webhook_secret="whsec_...",
)
provider = StripeProvider(settings)
service = BillingService(provider, settings=settings)
async with service:
# Create a customer
customer = await service.create_customer(
CustomerCreate(email="user@example.com", name="Jane Doe")
)
# Create a checkout session
checkout = await service.create_checkout_session(
CheckoutCreate(
customer_id=customer.id,
price_id="price_xxx",
success_url="https://example.com/success",
cancel_url="https://example.com/cancel",
mode=CheckoutMode.SUBSCRIPTION,
)
)
print(checkout.url) # redirect user here
Webhook Processing
from bloque_billing import WebhookProcessor, WebhookEventType
processor = WebhookProcessor(webhook_secret="whsec_...")
@processor.on(WebhookEventType.SUBSCRIPTION_CREATED)
async def handle_sub(event):
print(f"New subscription: {event.data}")
# In your webhook endpoint:
event = await processor.process(payload=body, signature_header=sig)
Custom Provider
Implement the BillingProvider protocol for any payment platform:
from bloque_billing.protocol import BillingProvider
class PaddleProvider:
async def create_customer(self, data):
... # Paddle API calls
async def health_check(self) -> bool:
return True
# ... implement all protocol methods
Dependencies
Only ulfblk-core and httpx. Webhook verification uses stdlib hmac.
Metadata
Release files for ulfblk-billing 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ulfblk_billing-0.1.0.tar.gz | 14.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ulfblk_billing-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 31.3 kB
Release files / ulfblk_billing-0.1.0.tar.gz
| Download URL | ulfblk_billing-0.1.0.tar.gz |
|---|---|
| Size | 14.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f8848c4f0cc3a385c34e8233bc2901e2112dbe5ad9de74fd82e398fdb2f0238e
|
|
BLAKE2b-256 checksum How to use checksums |
b8d5358127791497063d180c1d015f9b9f591fec05437b892491c51f04c81c3c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / ulfblk_billing-0.1.0-py3-none-any.whl
| Download URL | ulfblk_billing-0.1.0-py3-none-any.whl |
|---|---|
| Size | 16.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
096d29e0d55da3b9bedd3a814ed65be9d351a948b8a2e41ab3821424a43492cc
|
|
BLAKE2b-256 checksum How to use checksums |
3a66fd9e1058da8cd6f6705c9a6e30110a5854b010a4d22a3113176b05ed402a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.11 {"installer":{"name":"uv","version":"0.10.11","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|