Skip to main content

dj-paypal-checkout

CI codecov Documentation Django 5.2 | 6.0 Python 3.11+ PayPal REST

A modern, REST-first PayPal integration for Django: Orders v2 checkout, refunds and verified webhooks, with models, signals and admin.

Status: 0.2.0. One-off payments are covered end to end: configuration, OAuth2 auth with token caching, sync/async HTTP clients, amount handling, models with persisted idempotency keys, the Orders v2 create/authorize/capture flows, refunds and voids, verified webhooks, a reconciliation command, signals, a read-only admin and a runnable demo. Subscriptions add the products/plans catalog, create/revise and lifecycle operations, verified lifecycle/payment webhooks and recurring-payment records. Not yet: Vault and Card Fields.

It has not been run against live PayPal traffic yet, and the API may still change on minor versions before 1.0. See PROGRESS.md.

Why another PayPal library?

The established django-paypal package is built on Payments Standard with IPN/PDT, i.e. PayPal's Classic stack. PayPal now recommends webhooks for all new integrations and IPN is not fired by newer payment products. Meanwhile PayPal's own paypal-server-sdk is sync-only and ships neither webhook signature verification nor the subscription plans/products catalog.

This library targets the current REST APIs and fills those gaps:

Area API / implementation
Checkout Orders v2 (create → approve → capture)
Captures/refunds Payments v2, with a local guard against over-refunding
Notifications Webhooks with RSA-SHA256 signature verification — no IPN
Client side JS SDK v6 (standalone buttons, Card Fields)
Subscriptions Subscriptions v1 + plans/products catalog and lifecycle webhooks
Async sync and async client, same surface

Design principles

  • The server owns the amount. It is computed from your own order; the browser only ever receives a PayPal order id.
  • Webhooks are the source of truth for money having moved, and handlers are idempotent — PayPal retries, and events can arrive more than once.
  • Writes are idempotent, via PayPal-Request-Id, so a retry cannot double-charge.
  • Decimal end to end, with currency-correct scale (never float).
  • One config entry point: a single PAYPAL settings dict, read only by paypal_checkout.config.
  • The DB is a local cache of PayPal state — concrete models plus a generic FK to your own order object, so admin, audit and re-sync work out of the box.

Requirements

  • Python 3.11+
  • Django 5.2 LTS or 6.0

Try it

example/ is a runnable sandbox checkout — two endpoints, signals, and a read-only admin:

export PAYPAL_CLIENT_ID=...      # sandbox REST app credentials
export PAYPAL_CLIENT_SECRET=...
./run_demo.sh                    # http://127.0.0.1:8000/

Development

# Run the test suite (custom runner, uses tests/test_settings.py)
python tests/runtests.py

# Coverage (what CI runs; fails below 100% via .coveragerc)
coverage run tests/runtests.py && coverage report -m

# Docs the way CI and Read the Docs build them (warnings are errors)
sphinx-build -W --keep-going -b html docs/source docs/build/html

Invoke tasks are available too: invoke test, invoke coverage, invoke docs, invoke clean.

License

MIT — see LICENSE.

Download files

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

Source Distribution

dj_paypal_checkout-0.2.0.tar.gz (89.2 kB view details)

Uploaded Source

Built Distribution

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

dj_paypal_checkout-0.2.0-py3-none-any.whl (61.2 kB view details)

Uploaded Python 3

File details

Details for the file dj_paypal_checkout-0.2.0.tar.gz.

File metadata

  • Download URL: dj_paypal_checkout-0.2.0.tar.gz
  • Upload date:
  • Size: 89.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.14

File hashes

Hashes for dj_paypal_checkout-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1f6cc53d6e7f9cf59e446a2737c04ae6288a12ec42cff5805ed7c0c78abdd811
MD5 4d13e8f8888795dca752d4e8c0240417
BLAKE2b-256 371d7fc2c085e875da7afb40a682f06a53151dbb880635a0cf124f4e316a7e89

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_paypal_checkout-0.2.0.tar.gz:

Publisher: publish.yml on otto-torino/dj-paypal-checkout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file dj_paypal_checkout-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dj_paypal_checkout-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8eb8d855f871eb2713756501acd6e7541a2260925b4fa72fb4a2e4f693bd55c8
MD5 a32e2db1ba8bb072b138116a56b54670
BLAKE2b-256 5aeb29aab8a6668223bde0426e5a340ecddef614ade0d2f1362dc94ffad6b63d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_paypal_checkout-0.2.0-py3-none-any.whl:

Publisher: publish.yml on otto-torino/dj-paypal-checkout

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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