Credit-based billing for Django APIs — pluggable payment backends (Stripe, PayPal, stub), credit pack catalogue, and per-key balance tracking.
Project description
billa
Credit-based billing for Django APIs.
billa provides a pluggable payment backend (Stripe, PayPal, or a local stub for development), a credit pack catalogue, per-key balance tracking, and a BillerThrottle that enforces credit limits on API requests.
Part of the lxcor/api-suite.
Install
pip install lxcor-billa # core + stub backend
pip install lxcor-billa[stripe] # include Stripe
pip install lxcor-billa[paypal] # include PayPal
Setup
# settings.py
INSTALLED_APPS = [
...
'reggi', # required
'kotta', # required
'billa',
]
REST_FRAMEWORK = {
'DEFAULT_THROTTLE_CLASSES': [
'kotta.throttle.AnonEndpointThrottle',
'kotta.throttle.TierThrottle',
'billa.throttle.BillerThrottle',
],
}
# urls.py
urlpatterns = [
path('', include('billa.urls')),
]
Settings
| Setting | Default | Description |
|---|---|---|
BILLA_PAYMENT_BACKEND |
'billa.backends.stub.StubPaymentBackend' |
Active payment backend |
BILLA_MERCHANT_NAME |
'' |
Merchant name shown on terms and pricing pages |
BILLA_CONTACT_EMAIL |
'' |
Contact email shown on terms page |
BILLA_CURRENCY |
'USD' |
Currency code for all transactions |
BILLA_SUCCESS_URL |
'' |
Redirect URL after successful checkout |
BILLA_CANCEL_URL |
'' |
Redirect URL after cancelled checkout |
BILLA_UPGRADE_URL |
'' |
URL appended to 402 responses when credits are exhausted |
BILLA_STRIPE_MODE |
'test' |
'test' or 'live' |
BILLA_PAYPAL_MODE |
'sandbox' |
'sandbox' or 'live' |
Navbar and footer fragments
{% include "billa/_navbar_links.html" %} {# Pricing link #}
{% include "billa/_footer_links.html" %} {# Terms link #}
Management commands
| Command | Description |
|---|---|
dumppacks |
Export credit pack catalogue to JSON |
loadpacks |
Import credit pack catalogue from JSON |
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file lxcor_billa-0.1.1-py3-none-any.whl.
File metadata
- Download URL: lxcor_billa-0.1.1-py3-none-any.whl
- Upload date:
- Size: 36.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.8.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f058c0d9cdbbf8bd4ac5750de452b3804328e7cb79824f2e6d9020e160f53dd6
|
|
| MD5 |
fc7cd1184963b3cef71971fda35984b0
|
|
| BLAKE2b-256 |
7a5487ea61e187aea25a96d244b1f56230e99285269d689521e5465c7312c4af
|