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.1.0, the first release. 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. Not yet: subscriptions, Vault, 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:

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 (after 0.1.0)
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.1.0.tar.gz (74.0 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.1.0-py3-none-any.whl (51.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dj_paypal_checkout-0.1.0.tar.gz
  • Upload date:
  • Size: 74.0 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.1.0.tar.gz
Algorithm Hash digest
SHA256 0ddc3dce8d0e9bc6662aadf49b9511b927b5d704be7024ce1eeabd96390b3f9e
MD5 24219f45b3bb8e4ab31faf5768a072f8
BLAKE2b-256 28cbd53494d7fc0f832e456d630cbfa6b0e06dd12f0a7fb7db67a994e04fc01d

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_paypal_checkout-0.1.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.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for dj_paypal_checkout-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 8a202b8dfea59b88e6dd8472dadf4931aae099bb362bb4f9637483164efe9bbf
MD5 ac74612e53f3797b6fdb6244165904fb
BLAKE2b-256 6b321811ea413cef8d5685c9a67ed8ca71510d5f9a1ab1701d67b74c735511a0

See more details on using hashes here.

Provenance

The following attestation bundles were made for dj_paypal_checkout-0.1.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