ClickBank is offering an Instant Notification service for backend integration. The Instant Notification service notifies you of transactions within the ClickBank system for your account. The feature sends data in a near real-time fashion for the following action types:
|
|
The service attempts to post information via HTML FORM POST to a URL specified by you. Each post contains a group of URL Parameters relevant to the transaction. To prevent fraud one of the parameters, the "cverify" field, is used to verify the validity of the other fields.
Ultimately, this feature will allow you to easily integrate your back-end operations with the ClickBank transaction management system.
Note: This service is intended for use by experienced programmers. Clients without extensive programming skills should refrain from implementing Instant Notifications without first enlisting the services of an experienced programmer.
The ClickBank Instant Notification service is triggered every time a transaction is created or an action is taken upon a transaction in your ClickBank account. The primary flow involves the following steps:
Setting up the service on your ClickBank account is straightforward. However, it also necessary to build a program that processes the Instant Notification URL Parameters, which is a more technical task. In order to make good use of this service, your program must at least process the parameters outline in Section 2.1.1 of this document.
To best explain how to use this feature first the "rules" outlining its use are defined, and then step-by-step getting started instructions are provided to outline its implementation. Lastly, code samples are available.
The following rules must be upheld in order for the Instant Notification services to function properly. Failure to adhere to the following rules will result in removal of the feature from your account.
If for any reason the information listed above is not understood, we recommend that you enlist the services of professional who understands the implementation rules. Failure to do so could result in removal of this feature from your account.
Prior to implementing this feature you should familiarize yourself with the following information.
The following URL parameters are passed from the ClickBank Instant Notification service.
| Parameter | Description | Detail |
| ccustname | customer name | 1-510 Characters |
| ccuststate | customer state | 0-2 Characters |
| ccustcc | customer country code | 0-2 Characters |
| ccustemail | customer email | 1-255 Characters |
| cproditem | ClickBank product number | 1-5 Characters |
| cprodtitle | title of product at time of purchase | 0-255 Characters |
| cprodtype | type of product on transaction (STANDARD, and RECURRING) | 8-11 Characters |
| ctransaction * | action taken | 4-15 Characters |
| ctransaffiliate | affiliate on transaction | 0-10 Characters |
| ctransamount | amount paid to party receiving notification (in pennies (1000 = $10.00)) | 3-10 Characters |
| ctranspaymentmethod | method of payment by customer | 0-4 Characters |
| ctranspublisher | vendor on transaction | 5-10 Characters |
| ctransreceipt | ClickBank receipt number | 8-13 Characters |
| caffitid | affiliate tracking id | 0 - 24 Characters |
| cvendthru | extra information passed to order form with duplicated information removed | 0-1024 Characters |
| cverify ** | the "cverify" parameter is used to verify the validity of the previous fields | 8 Characters |
| ctranstime ** | the Epoch time the transaction occurred (not included in cverify) | 10 Characters |
|
* See Section 2.1.1.1 ** See Section 2.1.4 |
When a parameter contains no value, the Instant Notification string will contain the parameter tag without a value. It is also possible for the Instant Notification service to deliver more than one POST on a single receipt. For more information, please review the FAQ Section of this document.
There are a number of values you can receive in the "ctransaction" parameter. These values are listed below with a brief description of their purpose.
| Type | Description |
| SALE | The purchase of a standard product or the initial purchase of recurring billing product. |
| BILL | A rebill for a recurring billing product. |
| RFND | The refunding of a standard or recurring billing product. Recurring billing products that are refunded also result in a "CANCEL-REBILL" action. |
| CGBK | A chargeback for a standard or recurring product. |
| INSF | An eCheck chargeback for a standard or recurring product. |
| CANCEL-REBILL | The cancellation of a recurring billing product. Recurring billing products that are canceled do not result in any other action. |
| UNCANCEL-REBILL | Reversing the cancellation of a recurring billing product. |
| TEST | Triggered by using the test link on the site page. |
It is strongly recommended that you utilize this feature with Secure Socket Layer (SSL) enabled. Using this feature without Secure Socket Layer (SSL) enabled can expose your sales data to internet thieves. However, because credit card and bank information is not transmitted via the Instant Notification service, ClickBank does not require Secure Socket Layer (SSL) to encrypt Instant Notification transmissions.
The Instant Notification service attempts to POST information via HTML to the URL specified on your "My Site" page. If our attempt to post receives a response code from your system of something other than 200, ClickBank will retry delivering the data an hour later. The service will continue retrying once an hour for up to 72 hours, after which the feature will no longer attempt delivery.
Cipher (pronounced SAI-fuhr) is a method of performing encryption and decryption. It ensures there has been no URL tampering of the query string parameters.
When an action occurs within your ClickBank account several values are passed along in the Instant Notification query string (see Section 2.1.1). While building the string we create a sha1, or a hash of the values passed, and your Secret Key. The result is the 'cverify' parameter. Upon receipt of the query string parameters, your system must also create a sha1, or a hash of the values passed, and your Secret Key.
The validity of the data received is evaluated by using the 'cverify' parameter we send and the value produced in your system. Only if there is an exact match between the two values can you be certain the information received has not been tampered with.
Note: ctranstime parameter is not included in the encryption algorithm for the 'cverify' parameter.
Please see Section 4 for code samples.Request access to the Instant Notification service by following these steps:
Test the connectivity and successful processing of the URL parameters between ClickBank and your server by following these steps:
If the test was not successful, remove the URL from the "Instant Notification" field and trouble shoot possible problems with connectivity or your programming.
Important: You should not populate the "Instant Notification" field unless you can conduct a successful test. Doing so may result in your access to the feature being disabled.
The following Instant Notification parameters and values are passed for each execution of the test.
| Parameter | Value |
| ccustname | Test User |
| ccuststate | |
| ccustcc | |
| ccustemail | testuser@somesite.com |
| cproditem | 399 |
| cprodtitle | A passed in title |
| cprodtype | STANDARD |
| ctransaction | TEST |
| ctransaffiliate | |
| ctransamount | 100 |
| ctranspaymentmethod | VISA |
| ctranspublisher | "Real Vendor Nickname" |
| ctransreceipt | XXXXXXXX |
| caffitid | |
| cvendthru | |
| cverify | "Real cverify" |
Now that you have been granted access to the feature and have conducted a successful test, its time to complete the account setup of the Instant Notification service. Setting up the service is straightforward and involves the following steps.
Once the setup is complete, the Instant Notification transmissions will begin immediately.
Removing the URL from the "Instant Notification" field on the "My site" page will stop the system from delivering notifications.
The data sent to you by the Instant Notification service is in the form of HTML FORM POST URL Parameters. Programs written within your application architecture must process these pairs. Programs for order management, database activity, and other services may be written and are outside the scope of this guide.
The following Java code will create the "cverify" value and verify if it is correct using the plain text values in the HTTP POST and your secret key.
Note: This requires the jakarta commons codec library (http://commons.apache.org/codec/) to be functional.
public boolean validateApiNotification(HttpServletRequest request) {
String xxpop = "";
String cverify = request.getParameter("cverify");
String pop = String.format("%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s|%s",
request.getParameter("ccustname"),
request.getParameter("ccustemail"),
request.getParameter("ccustcc"),
request.getParameter("ccuststate"),
request.getParameter("ctransreceipt"),
request.getParameter("cproditem"),
request.getParameter("ctransaction"),
request.getParameter("ctransaffiliate"),
request.getParameter("ctranspublisher"),
request.getParameter("cprodtype"),
request.getParameter("cprodtitle"),
request.getParameter("ctranspaymentmethod"),
request.getParameter("ctransamount"),
request.getParameter("caffitid"),
request.getParameter("cvendthru"),
"YOUR SECRET KEY");
try {
MessageDigest digest = MessageDigest.getInstance("SHA");
byte[] b = digest.digest(pop.getBytes());
xxpop = new String(Hex.encodeHex(b)).toUpperCase();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return xxpop.equalsIgnoreCase(cverify);
}
The following php will create the "cverify" value and verify if it is correct using the plain text values in the HTTP POST and your secret key (e.g. not url encoded).
Response Types:
1 = Pass
0 = Fail
function cbValid() {
$key='YOUR SECRET KEY';
$ccustname = $_REQUEST['ccustname'];
$ccustemail = $_REQUEST['ccustemail'];
$ccustcc = $_REQUEST['ccustcc'];
$ccuststate = $_REQUEST['ccuststate'];
$ctransreceipt = $_REQUEST['ctransreceipt'];
$cproditem = $_REQUEST['cproditem'];
$ctransaction = $_REQUEST['ctransaction'];
$ctransaffiliate = $_REQUEST['ctransaffiliate'];
$ctranspublisher = $_REQUEST['ctranspublisher'];
$cprodtype = $_REQUEST['cprodtype'];
$cprodtitle = $_REQUEST['cprodtitle'];
$ctranspaymentmethod = $_REQUEST['ctranspaymentmethod'];
$ctransamount = $_REQUEST['ctransamount'];
$caffitid = $_REQUEST['caffitid'];
$cvendthru = $_REQUEST['cvendthru'];
$cbpop = $_REQUEST['cverify'];
$xxpop = sha1("$ccustname|$ccustemail|$ccustcc|$ccuststate|$ctransreceipt|$cproditem|$ctransaction|"
."$ctransaffiliate|$ctranspublisher|$cprodtype|$cprodtitle|$ctranspaymentmethod|$ctransamount|$caffitid|$cvendthru|$key");
$xxpop=strtoupper(substr($xxpop,0,8));
if ($cbpop==$xxpop) return 1;
else return 0;
}
?>