django-checkouts
Checkout hospedado e cobrança recorrente para Django por uma interface única, tipada e orientada a recursos. O gateway Stripe está completo; integrações com Asaas e PagBank ainda não estão implementadas.
A biblioteca não cria models e não persiste checkouts, assinaturas, faturas ou eventos. A aplicação decide seu modelo de dados, transações, filas e regras de negócio.
Instalação
pip install 'django-checkouts[stripe]'
Adicione django_checkouts ao INSTALLED_APPS e configure uma variante:
INSTALLED_APPS = [
...,
"django_checkouts",
]
CHECKOUT_VARIANTS = {
"stripe": (
"django_checkouts.gateways.stripe.StripeGateway",
{
"api_key": env("STRIPE_API_KEY"),
"webhook_secret": env("STRIPE_WEBHOOK_SECRET"),
"sandbox": DEBUG,
},
),
}
Use python manage.py check para validar a configuração sem fazer chamadas externas.
Primeiro checkout
Valores monetários são inteiros na menor unidade da moeda: R$ 49,90 é 4990. Toda mutação exige uma chave de idempotência estável.
from django.shortcuts import redirect
from django_checkouts import Gateway, get_checkout_gateway
from django_checkouts.enums import PaymentMethod
from django_checkouts.types import CheckoutCreate, CheckoutItem, InlinePrice
client = get_checkout_gateway(Gateway.STRIPE)
result = client.checkouts.create(
CheckoutCreate(
items=(
CheckoutItem(
price=InlinePrice(name="Plano Pro", unit_amount=4990),
quantity=1,
),
),
success_url="https://example.com/obrigado/",
cancel_url="https://example.com/carrinho/",
payment_methods=(PaymentMethod.CARD,),
reference_id="pedido-123",
),
idempotency_key="pedido-123:checkout:v1",
)
return redirect(result.url)
O cliente publica cinco recursos: checkouts, subscriptions, invoices, webhooks e events. Resultados são dataclasses imutáveis e normalizados; o campo raw é somente leitura, oculto do repr e deve ser usado apenas para diagnóstico.
Webhooks e reconciliação
Sempre verifique os bytes originais do corpo:
event = client.webhooks.verify(request.body, request.headers)
Persista a deduplicação na sua aplicação com unicidade em (variant, event_id). Para recuperar eventos perdidos, percorra janelas semiabertas [occurred_since, occurred_before) e deduplique a sobreposição.
Documentação
A documentação completa cobre assinaturas, webhooks, reconciliação, erros, opções Stripe, autoria de gateways e migração da API anterior a 1.0 em docs/.
Desenvolvimento
uv sync --all-extras --all-groups
uv run pytest
uv run mypy django_checkouts
uvx ruff check .
uv run sphinx-build -W -b html docs docs/_build/html
uv build
Licença
BSD-3-Clause. Consulte LICENSE.
Metadata
Release files for django-checkouts 1.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 | Provenance | Actions |
|---|---|---|---|---|
| django_checkouts-1.1.0.tar.gz | 189.2 kB | With provenance | Details for django_checkouts-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| django_checkouts-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for django_checkouts-1.1.0-py3-none-any.whl |
Total release size: 246.6 kB
Release files / django_checkouts-1.1.0.tar.gz
| Download URL | django_checkouts-1.1.0.tar.gz |
|---|---|
| Size | 189.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6ae222dd4342495beaece11b24422de41fdfd014bd7e5e37798356127ba4b64f
|
|
BLAKE2b-256 checksum How to use checksums |
481cc8dfa85c001a482d7a29f840c3a39e68cf5dac5e954606111f06272b13ba
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logRelease files / django_checkouts-1.1.0-py3-none-any.whl
| Download URL | django_checkouts-1.1.0-py3-none-any.whl |
|---|---|
| Size | 57.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
88fe37b0575b3ddae6c502d1bb05a2e5febe8380e52e9f48dbe2f807157c023d
|
|
BLAKE2b-256 checksum How to use checksums |
44746db575f792c989f04b76d65bd978a9fc1121c4af22f9773baf7cc6c4de8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logSecurity for django-checkouts 1.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for django_checkouts-1.1.0.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 22, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.