A reusable Django app for creating, logging and verifying purchases.
Project description
A reusable Django app for creating, logging and verifying purchases.
Quick start
Install Django Purchase Core & Dependencies:
>>> pip install django-purchase-core
Add “purchase”, “rest_framework’, and “rangefilter” to your INSTALLED_APPS setting like this:
INSTALLED_APPS = [
...,
'rest_framework',
'purchase',
'rangefilter',
...,
]
Add the following to app_config.urls:
from django.conf.urls import url, include
urlpatterns = [
...,
path("api/", include("purchase.urls")),
...,
]
Run Django Commands:
>>> python manage.py makemigrations >>> python manage.py migrate
Configure configuration and credentials for your game in the admin panel.
Add progress level update processing
To work with subscription you first need to set authorization and user model:
setup “PURCHASE_USER_ATTACHED” in you settings.py to True (not provided equals False, when it False no signal will be called, user model wont be used)
... PURCHASE_USER_ATTACHED = True ...
configure user model (in your settings.py)
USER_MODEL = YourUserModel
configure auth and permission classes for DRF (in your settings.py)
REST_FRAMEWORK = { "DEFAULT_PERMISSION_CLASSES": [ "rest_framework.permissions.IsAuthenticated" ], "DEFAULT_AUTHENTICATION_CLASSES": [ "path.to.your.auth.class.or.base" ], }
to handle completed purchase setup receiver to update progress, which will receive “instance”
from django.dispatch import receiver from purchase.signals import purchase_completed @receiver(purchase_completed) def purchase_completed(sender, **kwargs): purchase = kwargs["instance"] user = purchase.user # User completed purchase purchase_id = purchase.purchase_id # Your product ID, as it presented in store ...
To work with subscription you first need to set authorization and user model:
configure user model, auth and permission classes for DRF (in your settings.py, as for purchase with user)
... USER_MODEL = YourUserModel ... ... REST_FRAMEWORK = { ... "DEFAULT_PERMISSION_CLASSES": [ "rest_framework.permissions.IsAuthenticated" ], ... "DEFAULT_AUTHENTICATION_CLASSES": [ "path.to.your.auth.class.or.base" ], ... } ...
setup receiver for signal, which will receive “instance” as Subscription model instance
from django.dispatch import receiver from purchase.signals import subscription_completed @receiver(subscription_completed) def subscription_completed(sender, **kwargs): subscription = kwargs["instance"] user = subscription.user # User completed subscription subscription_id = subscription.product_id # your subscription ID, as it presented in store ...
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 django-purchase-core-0.3.3.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 42b79e475ff0c08c16170b3f79768c86cec8fb2a3f74583767b4903a625ca1b4 |
|
MD5 | c880411c30386ad15b062997271f5a16 |
|
BLAKE2b-256 | 1ab7076a774a4a4e95f367bd670b565282c576a5846a215cf11af265f290238a |
Hashes for django_purchase_core-0.3.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 77efd7d50cc7b362a3f90d82b64d1cac9e45b964141f7071181256b4b5e7809e |
|
MD5 | a9f9df5607a3eabcb9381fd05fc589af |
|
BLAKE2b-256 | be74119cb41680697a42b93838943bf99342992d032e480fa5636048b8bc45ad |