Clickbank Payment Processor Integration

January 15, 2009 | Clickbank, Payment Processors | 4 comments

Clickbank is an payment processor that doesnt seem to have any documentation or working complex examples. However, and this is a big however, they take payments on their site from a single url (ie no form need be posted to their site) and even better it handles the entire affiliate click through arrangements for your products. They seem to have a monopoly on this particular area so have no need to upgrade their systems to fall more inline with other processors (like Paypal for example).

I shall start from the beginning with the initial steps. Let us assume that we have a clickbank account for the time being…

The first step is to log into your clickbank admin account and set up your products with the price, name and, something else they require, a thankyou page.

Note that for the first product you sell with clickbank there is a $50 fee for the priviledge of having it activated. I have no idea whether you get this back or not.

So set up your product, get it activated and keep note of the Product ID…

As previously mentionned, Clickbank takes money for you when you send your clients to a specific payment page on a url which is formed in the following way:


Where the parts in square brackets must be replaced with the appropriate information.

That is essentially it…. you create the product, generate the url, put it on your site and start collecting money.

But what if you want to do something useful with the payment like provide a service of some sort or systematically keep a record of transactions on your own server?

For this you need to enable the IPN (Instant Payment Notification) service which requires ticking a couple of boxes to prove you aren’t an idiot (which, if doing this type of integration, you most likely won’t be). You also need to give it the url to ‘Call Back’ to (The url of the script that will be dealing with the data collected during the transaction).

Once IPN has been enabled you can write a script to receive the data sent by Clickbank on each payment. This basically needs to do three things:

  • Verify that the request is valid
  • Send back a 200 OK response code
  • Do anything you like with the data

The first part is fully documented on their site, carefully hidden but fully documented with examples in various languages. It basically consists of taking the first 8 characters from a sha1 encoded string built up of the concatenated variables sent via POST with your ‘Secret Key’ on the end. When compared to the verify code they send you in the same POST request you can see whether the request is genuine or not.

See the ‘You might also be interested in’ section at the bottom of this post for a code example and links to official documentation

This is the first time that I have mentioned the secret key but it is just that, a key which you set up in the Clickbank admin system that you also put in your script but NOT tell anyone else.

Once you have verified the request is a genuine one then you can move onto the part that does something to your site/database.

The data that it sends you says:

  • Type of transaction it is (SALE, BILL, REFUND, TEST…)
  • Product sold
  • Time and date of sale (in a useful unix timestamp)
  • Who purchased it (name and email)
  • Product ID

This is useful for basic systems that simply log a sale so with this data you should be able to email yourself to send a book or get it to activate an account etc..

I needed a bit more information than this though so needed to use another variable it sends through called ‘cvendthru’. What cvendthru does is gives you a list of the extra arguments which were given against the sell url (example above but with ‘/?myvariable=test’ or something useful at the end).

This makes life alot easier when updating records and storing more information because it can contain anything at all in a string which looks like ‘var1=1&var2=2&var3=3&var4=…’. You can use your script to ‘explode’ this into an array and use the variables contained within. It did take me a few attempts to work out how to do this as Google seems to have few results with cvendthru in the name.

You might also be interested in:

If you have done any clickbank integration and feel I have missed anything or given the wrong information then please contact me by leaving a comment on this post, the forum or sending an email to

A Donate Button!



    hi Sean ,
    Thank you for this information
    i really need to integrate clickbank with virtuemart joomla component if you can help me in this , i will be so glad to hear this ,

    best regards.
    michael raouf

    • Sean

      Hi Michael,

      Thanks.. Ouch Joomla and Virtuemart. I would bin it and go with WordPress and WPSC or use a proper cart like Magento. However if you want to use it.. The best place to start would be to find another module inside virtuemart and modify it to suit. Essentially the button generation code is going to be similar. You will also need to add the product ID to each product you are selling and set it up inside Clickbank as well.


  2. Dave

    Cheers mate, I’m hoping to use clickbank for both a standard drop in on a site thats already using paypal ( pretty straight forward as i was also using an ipn system with them ) and also in a completely flash driven site to charge up account credits and pay invoices. little more complex, but at least this is a good starting point to go from. Thanks šŸ™‚ If I end up making something useful and modular ( and not a butchered bodge that just barely works by the skin of its teeth ) I’ll be sure to share it with the community as these things never seem to have enough documentation.

    • Sean

      Hi Dave, no problem at all. I still prefer Paypal although for those people without accounts Sagepay is a nice and simple to integrate alternative. Clickbank is ok if you do a lot with affiliates though. Good luck with it. Hopefully my guide has provided some help.



Submit a Comment

Your email address will not be published. Required fields are marked *

CommentLuv badge

Stay in touch!

Page Builder Cloud

Page Builder Cloud

A truly universal template library for WordPress Page Builders.

Page Builder Recommendation

Elementor Banner

We are BIG fans of the Elementor page builder. Give it a look!

About this site and Sean Barton

Picture of Sean
Sean Barton is a Freelance PHP Website Developer in Crewe, Cheshire. He is a Wordpress and CMS/Framework specialist and Co-Founder of Page Builder Cloud.
This site was set up in 2008 as a tutorial and scripting resource for the PHP language and Wordpress.
Find out more about Sean on the About Me page or use the Hire Me page to get in touch. For more information about Sean's work take a look at the Portfolio

Our Services

  • Wordpress plugin/theme development
  • Divi specialist
  • Ecommerce (Woocommerce, WPSC, Shopify, Magento)
  • PSD to Wordpress theme conversion (Responsive)
  • Website design work (Banners, Logos, Full Site, etc)
  • Website analysis (security, usability, SEO)
  • API Integrations (InfusionSoft, SalesForce, Ontraport, Customer Thermometer, etc..)
  • Wordpress consultancy & expert advice
  • Crisis support
  • Website hosting

The main services offered are Wordpress based although we do a great deal of technical programming for bespoke systems. From troubleshooting, extending frameworks, finding bugs to writing them from scratch.

Find out more by looking through our past projects or get a quote.

Be the first to hear about new products/updates!

This is a mailing list for those people interested in being toldĀ when we releaseĀ a new product (Divi plugin or Theme).

We shall also use this list to let you know about product updates and releases.

You have Successfully Subscribed!