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.0.tar.gz (22.6 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.0-py3-none-any.whl (28.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lxcor_billa-0.1.0.tar.gz
  • Upload date:
  • Size: 22.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for lxcor_billa-0.1.0.tar.gz
Algorithm Hash digest
SHA256 750dda872defe75d3f52972149fa20344ad6586dba80394ae15bfc29d4869167
MD5 84eda814e4df2f474e6effe7920096a4
BLAKE2b-256 651323f6812d0f9c69f61c1365b9abd6b41d4eef6515f47a7ba2313f091ed205

See more details on using hashes here.

File details

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

File metadata

  • Download URL: lxcor_billa-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 28.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.10

File hashes

Hashes for lxcor_billa-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 58ccb2253cc850bf2361c53e3590680f9ac922230d7bff74ab96603fa314b7b2
MD5 9f604c5302a5af3cb5d43810c20742eb
BLAKE2b-256 ef231613b532f8b9b3e33cd500f5bc727e99e5516ee5d83f474f045e547f4a69

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