Skip to main content

PyPI Travis Documentation Supported Python versions License

Django + Paddle Made Easy

(this project is heavily inspired by dj-stripe)

Introduction

dj-paddle implements Paddle models (currently Subscription only), for Django. Set up your webhook and start receiving model updates. You will then have a copy of all Paddle subscriptions available in Django, no API traffic required!

The full documentation is available at https://dj-paddle.readthedocs.io.

Features

  • Django Signals for all incoming webhook events from paddle

  • Subscriptions

Requirements

  • Django >= 2.1

  • Python >= 3.5

Quickstart

Install dj-paddle:

pip install dj-paddle

Add djpaddle to your INSTALLED_APPS:

INSTALLED_APPS =(
    ...
    "djpaddle",
    ...
)

Add to urls.py:

path("paddle/", include("djpaddle.urls", namespace="djpaddle")),

Tell paddle about the webhook (paddle webhook docs can be found here) using the full URL of your endpoint from the urls.py step above (e.g. https://example.com/paddle/webhook/).

Add your paddle keys and set the operating mode:

# can be found at https://vendors.paddle.com/authentication
DJPADDLE_VENDOR_ID = '<your-vendor-id>'

# create one at https://vendors.paddle.com/authentication
DJPADDLE_API_KEY = '<your-api-key>'

# can be found at https://vendors.paddle.com/public-key
DJPADDLE_PUBLIC_KEY = '<your-public-key>'

djpaddle includes a vendor_id template context processor which adds your vendor ID as DJPADDLE_VENDOR_ID to each template context:

TEMPLATES = [
{
    ...
    'OPTIONS': {
        ...
        'context_processors': [
            ...
            'djpaddle.context_processors.vendor_id',
            ...
        ]
    }
}

Run the commands:

python manage.py migrate

# fetches all subscription plans from paddle
python manage.py djpaddle_sync_plans_from_paddle

Paddle Checkout

Next to setup a PaddleJS checkout page

First load in PaddleJS and initialise it by including the dj-paddle PaddleJS template in your own template to load PaddleJS:

{% include "djpaddle_paddlejs.html" %}

Next add a Paddle product or subscription plan into the page context. Below is an example of how to do this using a class based view where plan_id is passed through as a value from the URL:

from django.conf import settings
from django.views.generic import TemplateView
from djpaddle.models import Plan


class Checkout(TemplateView):
    template_name = 'checkout.html'

    def get_context_data(self, **kwargs):
        context = super().get_context_data(**kwargs)
        context['paddle_plan'] = Plan.objects.get(pk=kwargs['plan_id'])
        # If you have not added 'djpaddle.context_processors.vendor_id' as a template context processors
        context['DJPADDLE_VENDOR_ID'] = settings.DJPADDLE_VENDOR_ID
        return context

Finally put a Buy Now! button for the plan subscription you added to the context:

<a href="#!" class="paddle_button" data-product="{{ paddle_plan.id }}">Buy Now!</a>

You can pass data to Paddle JS by add data attributes to the button. For example to set the users email you can use the data-email attribute:

<a href="#!" class="paddle_button" data-product="{{ paddle_plan.id }}" data-email="{{ user.email }}" >Buy Now!</a>

A full list of parameters can be found on the PaddleJS parameters page

For more information about options on what to do after a successful checkout please see our Checkout success documentation

Subscription model

You can override the model that subscriptions are attached to using the DJPADDLE_SUBSCRIBER_MODEL setting. This setting must use the string model reference in the style ‘app_label.ModelName’.

The model chosen must have an email field.

# Defaults to AUTH_USER_MODEL
DJPADDLE_SUBSCRIBER_MODEL = 'myapp.MyModel'

Warning: To use this setting you must have already created and ran the initial migration for the app/model before adding djpadding to INSTALLED_APPS.

Reporting Security Issues

Please do not report security issues in public, but email the authors directly.

Release files for dj-paddle 0.1.2

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

Source distribution (sdist)

Source distribution for dj-paddle 0.1.2
File Size Uploaded
dj-paddle-0.1.2.tar.gz 13.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dj-paddle 0.1.2
File Interpreter ABI Platform
dj_paddle-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 31.7 kB

Release files / dj-paddle-0.1.2.tar.gz

Download URL dj-paddle-0.1.2.tar.gz
Size 13.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c477dcc438d2125ffdbea1d3e949bf48887c0d1d7814c83fd3b2eb85f520fbe7
BLAKE2b-256 checksum
How to use checksums
24ac39673664fca987726a5170e2650d7fbb1709a097a6ec866509be71ae558e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.5

Release files / dj_paddle-0.1.2-py3-none-any.whl

Download URL dj_paddle-0.1.2-py3-none-any.whl
Size 18.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
016056e9a414c6359be72f11a465023e13eb5e41c2f52e2a025464d28e281536
BLAKE2b-256 checksum
How to use checksums
f48b13551f50944a4cc7e1d00d8d0b2fa6a950022a432083ec7e9e5195b7dd3e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.3.0 pkginfo/1.7.0 requests/2.22.0 setuptools/51.1.0 requests-toolbelt/0.9.1 tqdm/4.58.0 CPython/3.8.5
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