Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lxcor_billa-0.1.2.tar.gz (29.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

lxcor_billa-0.1.2-py3-none-any.whl (38.1 kB view details)

Uploaded Python 3

File details

Details for the file lxcor_billa-0.1.2.tar.gz.

File metadata

  • Download URL: lxcor_billa-0.1.2.tar.gz
  • Upload date:
  • Size: 29.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lxcor_billa-0.1.2.tar.gz
Algorithm Hash digest
SHA256 5ec060b48c995b6e5151a594a15419989ea21fa64a28ae0ca6314bcf891659f7
MD5 f6bba25fc457806fa782928165d1e037
BLAKE2b-256 03014f059dd48f14dcd41da3e22faea692e9f3abb7fa7dd309537872c1dba1ec

See more details on using hashes here.

File details

Details for the file lxcor_billa-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: lxcor_billa-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 38.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for lxcor_billa-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1016cd746891d63e6872086c6bfe0aa3daaaced6cd842369ab7ea7dffb8646a5
MD5 4b14b263bf397caf92c77d8ffb6107e9
BLAKE2b-256 7fc8d10c0c9101ac9a62d771ea3b9da3354db083e9503002a4672c18422ec4b9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page