Skip to main content

A reusable Django app for creating, logging and verifying purchases.

Project description

A reusable Django app for creating, logging and verifying purchases.

Quick start

  1. Install Django Purchase Core & Dependencies:

    >>> pip install django-purchase-core
    
  2. Add “purchase”, “rest_framework’, and “rangefilter” to your INSTALLED_APPS setting like this:

INSTALLED_APPS = [
    ...,
    'rest_framework',
    'purchase',
    'rangefilter',
    ...,
]
  1. Add the following to app_config.urls:

from django.conf.urls import url, include

urlpatterns = [
    ...,
    path("api/", include("purchase.urls")),
    ...,
]
  1. Run Django Commands:

    >>> python manage.py makemigrations
    >>> python manage.py migrate
    
  2. Configure configuration and credentials for your game in the admin panel.

Add progress level update processing

  1. 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
        ...
  2. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-purchase-core-0.3.63.tar.gz (21.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_purchase_core-0.3.63-py3-none-any.whl (37.0 kB view details)

Uploaded Python 3

File details

Details for the file django-purchase-core-0.3.63.tar.gz.

File metadata

  • Download URL: django-purchase-core-0.3.63.tar.gz
  • Upload date:
  • Size: 21.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.1.13 CPython/3.8.9 Darwin/21.5.0

File hashes

Hashes for django-purchase-core-0.3.63.tar.gz
Algorithm Hash digest
SHA256 bc1dd8255a8fe98fe1aad306374d1d2336b0e6426fc7d34f8a89dcf40fa70d76
MD5 a2cd4daf5ac4929a7bb2d95e2feacb71
BLAKE2b-256 5d9a08bcf2593354b002160b83ddaa96cb08cdba58f32a014f2e684d67229e6d

See more details on using hashes here.

File details

Details for the file django_purchase_core-0.3.63-py3-none-any.whl.

File metadata

File hashes

Hashes for django_purchase_core-0.3.63-py3-none-any.whl
Algorithm Hash digest
SHA256 30aeaa1a32d8592d8715711240e1695db8833610f9e1bcf6698a82ecbfea83a0
MD5 b1c7a88ba7c25cb7c7106c5e4a1d5008
BLAKE2b-256 1f194d52b80c4b3cb25feb05826c6a99029f16978bafb68e9076211f590adae7

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page