djangoldp package for working with Stripe payments
Project description
djangoldp-stripe
A DjangoLDP package supporting Stripe payments. Uses dependency dj-stripe to achieve much of the functionality, a library for handling Stripe payments in Django
Requirements
-
djangoldp 2.1
-
Python 3.6.5
-
Requires the installation of a DjangoLDP server
-
You will need to set up a Stripe client
Installation
- You will need to set the following settings to your settings.yml:
dependencies:
# ...
- djangoldp-stripe
ldp_packages:
# ...
- djangoldp_stripe
server:
# ...
STRIPE_LIVE_MODE: True # Should be False when testing, True in production
DJSTRIPE_USE_NATIVE_JSONFIELD: True # if using SQLite, set this to False
DJSTRIPE_FOREIGN_KEY_TO_FIELD: "id"
- Set
STRIPE_LIVE_SECRET_KEY
andSTRIPE_TEST_SECRET_KEY
in your OS environment variables where the server is run. These settings will then be securely imported when you next configure. Alternatively, you can add them to the settings.yml:
server:
# ...
STRIPE_LIVE_SECRET_KEY: ""
STRIPE_TEST_SECRET_KEY: ""
You can find these settings via the Stripe dashboard
-
In the Stripe dashboard, add your first webhook
-
In the created webhooks, find your webhook secret, and set this in the OS variable (or server setting)
DJSTRIPE_WEBHOOK_SECRET
. It is a string which will startwhsec_
-
Run
djangoldp install
-
Run
djangoldp configure
-
Run
python manage.py djstripe_sync_models
## Migrating existing customers
After configuration, you can do this by running:
djangoldp configure
python manage.py djstripe_init_customers
python manage.py djstripe_sync_plans_from_stripe
Optional Configuration Options
LDP_STRIPE_URL_PATH
: the path where Django Stripe's urls will be accessible. By default"stripe/"
StripeSubscriptionPermissions
This package can be used to provide custom permissions on your models and views. To do this you can use the permissions class StripeSubscriptionPermissions
or the utility functions in permissions.py
- Set up the required product permissions on your model:
class MyModel(Model):
# ...
class Meta(Model.Meta):
# ...
PERMS_REQUIRED_STRIPE_SUBSCRIPTIONS = ['prod_xxxx',]
When applying either the permission class to a LDPViewSet
or the utility function, you can now control access based on the products a requesting user is subscribed to
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for djangoldp_stripe-0.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | b969144a9f9d739388f6572907031f9a684883b23e1870110220bcc7f333f806 |
|
MD5 | c62b24ac75091d372b5f2dc3e22a3525 |
|
BLAKE2b-256 | 40f81c9d39b534d86eec34a92b2758d4ff1daf7925974486912bb86e0f85a9c2 |