Skip to main content
https://badge.fury.io/py/django-plans-paypal.svg https://github.com/PetrDlouhy/django-plans-paypal/actions/workflows/main.yml/badge.svg https://codecov.io/gh/PetrDlouhy/django-plans-paypal/branch/master/graph/badge.svg

Almost automatic integration between django-plans and django-paypal. This will add subscribe buttons to the order page and automatically confirm the Order after the payment.

Currently it is in experimetal stage, wher only recurring payments (subscribtions) are supported.

Documentation

The full documentation is at https://django-plans-paypal.readthedocs.io.

Quickstart

Install and configure django-plans and django-paypal apps. Capture mode is not yet supported, so PAYMENT_VARINANTS with 'capture': False will not get confirmed.

Install Django plans paypal:

pip install django-plans-paypal

Add it to your INSTALLED_APPS, before the plans:

INSTALLED_APPS = (
    ...
    'payments',
    'paypal.standard.ipn',
    'plans_paypal',
    ...
)

Add your bussiness account e-mail address to settings:

PAYPAL_BUSSINESS_EMAIL = "foo@bar.com"

# To enable encrypted PayPal form:
PAYPAL_ENCRYPTED_FORM = True
PAYPAL_PRIVATE_CERT = os.path.join(BASE_DIR, 'certs/paypal_private.pem')
PAYPAL_PUBLIC_CERT = os.path.join(BASE_DIR, 'certs/paypal_public.pem')
PAYPAL_CERT = os.path.join(BASE_DIR, 'certs/paypal_cert.pem')
PAYPAL_CERT_ID = 'xxxxx'

Add Django plans_paypal to the URL patterns:

urlpatterns = [
    ...
    url(r'^plans-paypal', include('plans_paypal.urls')),
    ...
]

Override django-plans class CreateOrderView so that get_success_url() returns url of paypal-payment view:

def get_success_url(self):
   return reverse("paypal-payment", kwargs={'order_id': self.object.id})

Sandbox testing

Set following settings:

PAYPAL_TEST_BUSSINESS_EMAIL = "foo@bar.com"
PAYPAL_TEST = True

# For encrypted PayPal sandbox form:
PAYPAL_TEST_PRIVATE_CERT = os.path.join(BASE_DIR, 'certs/paypal_private.pem')
PAYPAL_TEST_PUBLIC_CERT = os.path.join(BASE_DIR, 'certs/paypal_public.pem')
PAYPAL_TEST_CERT = os.path.join(BASE_DIR, 'certs/paypal_sandbox_cert.pem')
PAYPAL_TEST_CERT_ID = 'xxxx'

Redirect user to paypal-payment-sandbox instead of paypal-payment view.

Features

  • TODO

Running Tests

Does the code actually work?

source <YOURVIRTUALENV>/bin/activate
(myenv) $ pip install tox
(myenv) $ tox

Credits

Tools used in rendering this package:

History

1.3.0 (2026-08-19)

  • receive_ipn now processes each IPN in a single database transaction: a failure while completing the order no longer leaves an armed RecurringUserPlan and a recorded payment behind, so PayPal’s IPN retries start from a clean slate instead of dying on the leftover state as duplicates.

  • pending subscription payments (typically eChecks clearing) are recorded as PayPalPayment rows instead of being silently dropped – an in-flight payment is not a decline.

1.2.0 (2026-05-20)

  • PaymentFailureView: redirect already-completed orders to the success page (with a warning log) instead of raising ValueError. PayPal can send the buyer to the cancel_return URL even after the IPN has marked the order as completed (browser back button, stale tabs, edge cases in the PayPal flow); the previous behaviour produced unhandled 500s for paid users. Reverses the 0.7.1 behaviour change.

  • handle empty/whitespace PayPal IPN custom data without logging an error; also catch ValueError from ast.literal_eval so future Python releases can’t break the parser

  • admin: add paypal_ipn__txn_id column to PayPalPaymentAdmin.list_display

  • drop conflicting isort lines_after_imports = 2 setting (project already uses profile = black) and reformat affected files; the lint CI job is green again

1.1.0 (2025-06-20)

  • add more fields to admin list_display

1.0.1 (2025-05-29)

  • fixes to taking the data from custom_data

1.0.0 (2025-05-23)

  • create order more robust: take the data from custom_data

  • Support Django up to 5.2

0.7.1 (2024-04-23)

  • fail if PaymentFailureView is requested on completed orders

0.7.0 (2024-04-12)

  • migrate code to RecurringUserPlan.renewal_triggered_by

  • migrate data of RecurringUserPlans with payment_provider=”paypal-recurring” and renewal_triggered_by=TASK to renewal_triggered_by=OTHER

0.6.0 (2023-03-22)

  • Fix amount received on recurring payments, add tests

0.5.1 (2023-02-11)

  • allow only logged users to access the failure view

0.5.0 (2022-12-14)

  • Fix tax received on recurring payments

  • More robust receiving original Order ID (if PayPal fails to handle custom_data)

  • update to Django 4.1

  • fix completing recurring payments if first order status is returned

  • only log error if custom data can’t be parsed

0.4.10 (2022-04-29)

  • fix problem with duplicate payments

  • PayPalPaymentAdmin: display connected IPN fields

0.4.9 (2022-03-07)

  • make parsing custom_data more robust

0.4.8 (2022-01-19)

  • fix last release

  • add tests and test on all supported Django/Python versions through GitHub actions

0.4.7 (2022-01-13)

  • fix problem if there was ‘ in custom payment data

0.4.6 (2021-12-02)

  • fix problem with creating bad JSON

0.4.5 (2021-12-01)

  • fix IPN field editing in PayPalPaymentAdmin

  • store also user e-mail in custom to enable search in IPN admin

0.4.4 (2021-12-01)

  • create PayPalPayment before completing the order

0.4.3 (2021-11-30)

  • fix problem with recurring payments

  • add created/modified/author auto fields

0.4.2 (2021-11-08)

  • fix problem with other IPN types

0.4.1 (2021-10-18)

  • cancel order after returning to failure URL

0.4.0 (2021-10-18)

  • allow to set up encrypted PayPal form

0.3.0 (2021-10-15)

  • fixes and improvements to the sandbox/production functionality

  • reverse sandbox logic - if no PAYPAL_TEST, the sandbox view would return production so nobody can pay through sandbox on production server

0.2.2 (2021-10-12)

  • fix foregotten pudb

0.2.1 (2021-10-12)

  • add sandbox view, so both production and sandbox can be used on one server

0.2.0 (2021-10-11)

  • fix periods to complain with PayPal maximal durations

0.1.0 (2021-10-08)

  • hook ipn.PayPalIpn object with plans.Order (for later usage e.g. determining PayPal fee)

  • set plan renewal for django-plans

0.0.2 (2018-08-05)

  • Payment process without capturing should work

  • Automatic buttons generation

0.0.1 (2018-07-23)

  • First release on PyPI.

Release files for django-plans-paypal 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-plans-paypal 1.3.0
File Size Uploaded
django_plans_paypal-1.3.0.tar.gz 17.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-plans-paypal 1.3.0
File Interpreter ABI Platform
django_plans_paypal-1.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 37.0 kB

Release files / django_plans_paypal-1.3.0.tar.gz

Download URL django_plans_paypal-1.3.0.tar.gz
Size 17.5 kB
Tags Source
SHA-256 checksum
How to use checksums
a237e4f5f5fe567f83fd47c35f0f5619c9f2c8713fcac3eaa12ebf90f3b16285
BLAKE2b-256 checksum
How to use checksums
f2d25fa8550967c4de9e6d39da6cb70872ad421cc3ce76b7c955f19ccd9c2fbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / django_plans_paypal-1.3.0-py3-none-any.whl

Download URL django_plans_paypal-1.3.0-py3-none-any.whl
Size 19.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46c3055ae239c9ce18926c17baa7072923e101d6957780430c843cf9e6452c75
BLAKE2b-256 checksum
How to use checksums
dd652610d9a4a27e2d307eec033407c8bda8d778bf65d1023c9d7e4d03901812
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

1.6.0

2 release files

1.5.0

2 release files

1.4.0

2 release files

This release

1.3.0 This release

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.7.1

2 release files

0.7.0

2 release files

0.6.0

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.10

1 release file

0.4.9

1 release file

0.4.8

1 release file

0.4.7

1 release file

0.4.6

1 release file

0.4.5

1 release file

0.4.4

1 release file

0.4.3

1 release file

0.4.2

1 release file

0.4.1

1 release file

0.4.0

1 release file

0.3.1

1 release file

0.3.0

1 release file

0.2.2

1 release file

0.2.1

1 release file

0.2.0

1 release file

0.1.0

1 release file

0.0.2

1 release file

0.0.1

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page