MCPcopy Index your code
hub / github.com/HearthSim/dj-paypal

github.com/HearthSim/dj-paypal @v0.16.1

Chat with this repo
repository ↗ · DeepWiki ↗ · release v0.16.1 ↗ · + Follow
193 symbols 578 edges 46 files 12 documented · 6%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

dj-paypal

CI PyPI

A Paypal integration for Django, inspired by dj-stripe.

Currently only supports subscriptions.

Requirements

  • Python 3.6+
  • Django 3.1+
  • Postgres 9.6+ (Non-postgres engines not supported)

Installation

  1. Install dj-paypal with pip install dj-paypal
  2. Add djpaypal to django INSTALLED_APPS setting
  3. Get a client ID and client secret from paypal and add them to the settings PAYPAL_CLIENT_ID and PAYPAL_CLIENT_SECRET
  4. Set PAYPAL_MODE = "sandbox" (or "live") in the settings
  5. Install your Billing Plans (see below)

Setting up billing plans

Download already-created billing plans from Paypal

Run manage.py djpaypal_download_plans to sync all plans already created upstream into the local database.

This will create djpaypal.models.BillingPlan objects, which can be listed from the Django admin.

Creating new Paypal billing plans

The manage.py djpaypal_upload_plans management command creates billing plans using the Paypal API. An extra PAYPAL_PLANS setting must be set, which will contain a dict of Paypal billing plans to create.

See example_settings.py for an example of plans to create.

Webhooks

The djpaypal.views.ProcessWebhookView view should be hooked up to an URL endpoint which you then set up in Paypal as a webhook endpoint (https://developer.paypal.com).

In order to verify webhooks being transmitted to your app, dj-paypal needs to know the ID of the webhook that is expected at that URL. Set it in the setting PAYPAL_WEBHOOK_ID.

Sandbox vs. Live

All models have a livemode boolean attribute. That attribute is set to True if created in Live (production) mode, False otherwise (sandbox mode). Sandbox and Live data can co-exist without issues. Once you are done testing in Sandbox mode, use the manage.py djpaypal_delete_all_test_data management command to (locally) clear all the test data. This command has no impact on the upstream data.

Data considerations

Most of the models defined in dj-paypal are copies of the upstream Paypal model data. Deleting or editing objects (be it from the admin or in the database) does not actually change any of the upstream Paypal data.

License and Sponsorship

This project was designed and developed by HearthSim. It is licensed under the MIT license. The full license text is available in the LICENSE file.

Core symbols most depended-on inside this repo

save
called by 12
src/djpaypal/models/billing.py
get_or_update_from_api_data
called by 11
src/djpaypal/models/base.py
find_and_sync
called by 5
src/djpaypal/models/base.py
sync_data
called by 5
src/djpaypal/models/base.py
create
called by 4
src/djpaypal/models/billing.py
find_paypal_object
called by 3
src/djpaypal/models/base.py
process
called by 3
src/djpaypal/models/webhooks.py
sdk_object_as_dict
called by 2
src/djpaypal/models/base.py

Shape

Method 84
Class 81
Function 28

Languages

Python100%

Modules by API surface

src/djpaypal/enums.py33 symbols
src/djpaypal/models/billing.py29 symbols
src/djpaypal/admin.py28 symbols
src/djpaypal/models/webhooks.py20 symbols
src/djpaypal/models/base.py14 symbols
tests/test_webhooks.py9 symbols
tests/conftest.py8 symbols
tests/test_billing.py7 symbols
src/djpaypal/models/payments.py6 symbols
src/djpaypal/utils.py5 symbols
src/djpaypal/views.py2 symbols
src/djpaypal/models/payer.py2 symbols

For agents

$ claude mcp add dj-paypal \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact