Welcome to niteoweb.clickbank’s documentation!

Project title:niteoweb.clickbank
Latest version:0.6
Author:NiteoWeb Ltd.
Generated:August 19, 2010
Browse source:http://dev.plone.org/collective/browser/niteoweb.clickbank


Integrates ClickBank digital products retailer system with Plone to enable paid memberships on your Plone site.

How it works

  1. Visitor comes to yoursite.com/order (or similar) and clicks Order link.

  2. Visitor is sent to ClickBank’s order form (on clickbank.com),

    where he enters his personal information and performs payment.

  3. ClickBank calls-back a special view on your plone site (/@@clickbank),

    which reads POST data from ClickBank, verifies it with your Secret Key and creates a new member.

  4. The following information is stored in member data for later use:

    ClickBank’s Product ID of the purchased item.


    Affiliate who referred the buyer.


    ClickBank receipt ID of the last purchase. This field gets updated on every recurring payment.


    Exact timestamp of the last purchase. This field gets updated on every recurring payment.

  5. Upon creating a new member, Plone send an email with login password.

  6. An IMemberCreateEvent is emitted upon creating a new member.

  7. New member can now login and use the site.


If a member already exists in Plone, then the @@clickbank view simply updates last_purchase_id and last_purchase_timestamp member fields.


You can see this product in action at http://bigcontentsearch.com/order.


To install in your own buildout just add it to your buildout’s eggs and zcml listing as normal:

eggs =

zcml =



Go to ClickBank and create a Vendor account. Add a test Product of type Membership. Then set the following:

Secret Key
Choose a strong password here.
Thank your page
Enter a url for your Thank You page, normally http://yoursite.com/thank-you.
Hoplink destination url.
Enter a url to a site with an order link, normally http://yoursite.com/order.
Test credit card.
Create Test Credit Card so you can do test buys.


  1. Go to Site Setup -> ClickBank control panel form and configure the following fields:

    Secret Key

    Paste the Secret Key you defined above.

  2. Create a Page Order. Insert the following markup, replacing capitalized strings:

    <a href="http://PRODUCT_ID.VENDOR_ID.pay.clickbank.net">Order a subscription to this site!</a>
  3. Create a Page Thank You. Insert the following text:

    Thank you for your order!
    Your credit card or bank statement will show a charge by ClickBank or CLKBANK*COM.
    If you have any questions let us know on info@yoursite.com"

Test it

Fire up your browser and point it to your Order page. Click on Order a subscription to this site!, fill in your Test Credit Card info with your personal email and purchase the subscription. Confirm by logging-in to ClickBank and checking to see if there were any purchases. You should also receive an email with username and password for accessing your site.

Known issues

The following known issues exist:

  • If members stop paying for monthly or yearly subscriptions,

    you have to manually delete them from your Plone site.

  • The same as above goes for any chargebacks or refunds.

    You have to manage them manually.

Running tests

Open up a console and run the following:

$ cd <workspace>/niteoweb.clickbank

# run a specific test
$ bin/test -s niteoweb.clickbank -t test_setup

# run all tests
$ bin/test -s niteoweb.clickbank

# calculate code test coverage
$ bin/coverage-test -s niteoweb.clickbank


Open up a console and run the following:

$ cd <workspace>/niteoweb.clickbank

# use zest.releaser to make an egg distribution and upload it to PyPI
$ fullrelease

# build sphinx docs and upload them to packages.python.org
$ bin/sphinxbuilder
$ python setup.py upload_docs


Views & Controllers

clickbank.py - handle ClickBank purchase notifications

class niteoweb.clickbank.browser.clickbank.ClickBankView(context, request)

A BrowserView that ClickBank calls after a purchase.


Verifies if received POST is a valid ClickBank POST request.

Parameter:params (dict) – POST parameters sent by ClickBank Notification Service

Parses POST from ClickBank and extracts information we need.

Parameter:params (dict) – POST parameters sent by ClickBank Notification Service
_create_or_update_member(username, data)

Creates a new Plone member. In case the member already exists, this method simply updates member’s fields.

  • username (string) – username of member that is to be created/updated
  • data (dict) – member data of member that is to be created/updated
_email_password(mto, password, data)

Send an email with member’s password.

  • mto (string) – email receipient
  • password – member’s login password that is written in the email
  • data (dict) – member data needed to construct the email (fullname, ...)
_generate_password(length=8, include='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')

Generate random password in base64.

  • include (string) – set of characters to choose from
  • length (integer) – number of characters to generate

a random password

Return type:


configure_clickbank.py - configure ClickBank add-on

class niteoweb.clickbank.browser.configure_clickbank.ConfigureClickBankForm(context, request)
A ControlPanelForm BrowserView for ClickBank configuration configlet.


clickbank_settings.py - store ClickBank add-on settings

class niteoweb.clickbank.clickbank_settings.ClickBankSettings
A ZCA local utility for storing information from ClickBank configuration configlet.

interfaces.py - where all interfaces, events and exceptions live

interface niteoweb.clickbank.interfaces.IClickBankSettings

This interface defines fields for ClickBank plone_control_panel configlet.

ClickBank Secret Key
exception niteoweb.clickbank.interfaces.ClickBankError
Exception class for niteoweb.clickbank project
class niteoweb.clickbank.interfaces.MemberCreatedEvent(context, username)
Emmited when a new member is created by ClickBank post-back service calling @@clickbank.
exception niteoweb.clickbank.interfaces.MemberCreationFailedError
Exception that is raised when there is a problem with creating a new member.
exception niteoweb.clickbank.interfaces.MemberUpdateFailedError
Exception that is raised when there is a problem with updating member’s fields.
exception niteoweb.clickbank.interfaces.POSTVerificationFailedError
Exception that is raised when we cannot verify a POST from ClickBank.


__init__.py - where all TestCases live

class niteoweb.clickbank.tests.ClickBankControlPanelTestCase(methodName='runTest')
Test case used for control panel tests, with some convenience methods from plone.app.controlpanel.
class niteoweb.clickbank.tests.ClickBankFunctionalTestCase(methodName='runTest')

We use this base class for all functional tests in this package. These tests are full-blown functional test. The emphasis is on testing what the user may input and see, and the system is largely tested as a black box. We use PloneTestCase to set up this test as well, so we have a full Plone site to play with. We use zope.testbrowser to test end-to-end functionality, including the UI. For testing stuff on the lower levels use integration or unit tests.

Prepare a testbrowser instance and a debugging environment.
login_with_browser(browser, username=None, password=None)
Login to site with testbrowser.
Dumps self.browser.contents (HTML) to a file and opens it with a normal browser.
Start ZServer so we can inspect site state with normal browser.
class niteoweb.clickbank.tests.ClickBankIntegrationTestCase(methodName='runTest')
We use this base class for all integration tests in this package. These tests are integration “unit” test. They use PloneTestCase, to have a full Plone site to play with but they interact with Plone on a low level, below user UI.
class niteoweb.clickbank.tests.MockMailHostTestCase(methodName='runTest')
Test case used for testing emails sent out by this product.

test_setup.py - test installation of niteoweb.clickbank into Plone

class niteoweb.clickbank.tests.test_setup.TestSetup(methodName='runTest')

Test installation of niteoweb.clickbank into Plone.

Test if ClickBank-specific fields were added to memberdata.
Test if anonymous visitors are prevented to register to the site.
Test if email is indeed used as username.

test_clickbank.py - test all aspects of @@clickbank

class niteoweb.clickbank.tests.test_clickbank.TestClickBank(methodName='runTest')

Test all aspects of @@clickbank.

Prepare testing environment.
Test @@clicbank’s response when POST cannot be verified.
Test @@clicbank’s response when POST is empty.
Test @@clicbank’s response when POST is valid.
Test creating a new member out of POST parameters.
Test headers and text of email that is sent to newly created member.
Test password generation.
Test that POST parameters are correctly mirrored into member fields.
Test updating an existing member with POST parameters.
Test POST verification process.


0.6 (unreleased)

  • Nothing changed yet.

0.5 (2010-08-18)

  • Emit MemberCreatedEvent when @@clickbank view creates a new member. [zupo]

0.4 (2010-07-20)

  • Added parameters and return information to docstrings. [zupo]
  • Login credentials email body text is now templated. [zupo]

0.3 (2010-07-18)

  • Big refactoring and cleanup. [zupo]
  • Loads of tests. [zupo]

0.2 (2010-07-16)

  • Use email as username. [zupo]
  • Added ClickBank properties to member data. [zupo]
  • Added @@clickbank BrowserView. [iElectric]
  • Added Plone Control Panel configlet. [zupo]

0.1 (2010-07-15)

  • Initial release. [zupo]

Indices and tables