django-clickbank is a pluggable django application for recieving ClickBank [Instant Payment Notifications] 1
- Recieves and stores all notifications to the database.
- Stores raw post data, whether notifications fails or not (configurable)
- Formats raw CB field names into easier ones easier to work with.
- Sends signals for each transaction type
django-clickbank is currently written for django 1.5.x and python 2.7, but it should run fine on 1.6.
The only major requirement is that you have South installed.
pip install django-clickbank
pip install -e git+https://github.com/Sureiya/django-clickbank.git
git clone https://github.com/Sureiya/django-clickbank.git django-clickbank
cd django-clickbank
python setup.py
-
Install (see above)
-
Add django-clickbank and South to your INSTALLED_APPS
# settings.py
INSTALLED_APPS = (
...
'south',
'django_clickbank',
...
)
- Import the django-clickbank default settings in settings.py
# settings.py
from django_clickbank.settings import *
- Add django-clickbank urls to your urls.py
urlpatterns = patterns('',
...
url(r'^', include('django_clickbank.urls')),
...
)
- Run migrations
python manage.py migrate django_clickbank
-
Setup Clickbank
- Login to Clickbank
- Navigate to Settings -> My Site
- To the right of Advanced Tools, click Edit
- Add http://yoursite/clickbank/ipn/ as a URL, you can choose 2.1 or 4.0.
- Create a Secret Key
- Hit 'Save'
-
Update Settings with Secret Key
# settings.py
CLICKBANK_SECRET_KEY = <key generated in step 6>
- Setup Logging (Optional)
# settings.py
LOGGING['loggers']['django_clickbank.notications' = {
'handlers': ['console'], # Change handlers if you want. Logging levels are DEBUG and INFO
'propogate': True,
}
- Test it out.
from django_clickbank.signals import sale
def sale_callback(sender, **kwargs):
## Logic for processing sale
For more information on signals, see [Django Signals] 2
To view a full list of signals refer to [signals.py] 3
To view all notification fields, see [models.py] 4
Important Note
Under some circumstances ClickBank sends multiple notifications per sale (upsells). Due to the way Django signals work, its possible for notification callbacks to be processed at the same time (multithreaded server). If your callbacks could fail due to this, look into using a task queue like celergy, along with a single worker to force your callbacks to be executed 'first in first out'.
## Setting debug to True turns off things like secret key verification
CLICKBANK_DEBUG = False
## If set to true raw post data will be stored regardless of CLICKBANK_DEBUG
CLICKBANK_STORE_POSTS = True
## If set to true, app will still log notifications when verification fails
CLICKBANK_KEEP_INVALID = True
## When set to true, app will still send signal when invalid notification recieved.
CLICKBANK_SIGNAL_INVALID = False
## Send 200 status when a transaction is received that already exists. Mostly for debugging
CLICKBANK_IGNORE_DUPLICATES = False
If you'd like to contribute, feel free to make a fork and send me a pull request.
MIT