Monday 3 December 2012

How To Set Up Email Notifications for ClickBank Sales





Rather than logging into your ClickBank account continually to see if you’ve made a sale, it’s much easier and convenient to receive an email informing you of one. Unfortunately, back in 2003 ClickBank discontinued sending email sale notifications to its affiliates. Although this feature is no longer available within your ClickBank account, there is still a way to receive email sale notifications. The method requires using a script and it’s fairly simple to set up, anyone with a website can do it.

Below we provide you with a free script that will send you ClickBank sale notifications by email. But before we cover how to set it up, let’s go over some of the basics of the script.

Requirements…
A ClickBank account
An email address (to receive your sale notifications)
A web hosting account.

How it Works…
The script uses ClickBank’s Instant Notification Service.
When you make a sale, ClickBank’s Instant Notification Service sends the sale information to the script installed on your website.
The script then takes that information and puts it into an email and sends it to whatever email address you’ve defined in the script.

Additional Details…
Although ClickBank still sends sale notifications by email to vendors, this script will work for all sales within a ClickBank account, including vendor and affiliate sales.
The script will send an email notification for sales, refunds, rebills, and rebill cancellations.
You have our permission to use this script freely and customize it.
It’s possible to use SSL with ClickBank’s Instant Notification Service and this script, but it’s not required.

Installation…
Copy the script below to NotePad, WordPad, or any HTML editor and save it as clickscoopnotify.php
?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
/*
CLICK BANK IPN SCRIPT
VERSION 2.1
CLICKSCOOP.COM
*/
// SECRET KEY
$SECRETKEY = 'ENTER SECRET KEY HERE';
//EMAIL FROM
$EMAIL_FROM = 'ClickScoop Notify';
//EMAIL RECEIVER
$EMAIL_TO = 'ENTER EMAIL ADDRESS HERE'; //example: john@somewhere.com

//Forces TEST transactions to work.
$FORCE_TESTS_TO_WORK = true;


$HEADER = "From:" . $EMAIL_FROM;


// SECURITY CHECK (cverify)
// Returns: (bool)
function ipnVerify() {
global $SECRETKEY;
global $_EXPECTED;
global $_RESULTS;
global $FORCE_TESTS_TO_WORK;

$secretKey = $SECRETKEY;
$pop = "";
$ipnFields = array();
foreach ($_POST as $key => $value)
{
if ($key == "cverify") {
$_EXPECTED = $value;
continue;
}
$ipnFields[] = $key;
}
sort($ipnFields);
foreach ($ipnFields as $field)
{
$pop = $pop . $_POST[$field] . "|";
}
$pop = $pop . $secretKey;
$calcedVerify = sha1(mb_convert_encoding($pop, "UTF-8"));
$calcedVerify = strtoupper(substr($calcedVerify,0,8));

$_RESULTS = $calcedVerify;

if ($_POST['ctransreceipt'] == '********' && $_POST['ctransaction'] == 'TEST' && $FORCE_TESTS_TO_WORK){
return true;
}

return $calcedVerify == $_POST["cverify"];
}
// PROCESS ONLY WHEN VERIFIED TRANSACTION
if(ipnVerify())
{
$SUBJECT = "New Transaction: ".ucfirst(strtolower($_POST['ctransaction'])).": quot; . $_POST['caccountamount']/100 ;
$BODY = 'Product: ' . $_POST['cprodtitle'] ."\n";
$BODY .= 'Vendor: ' . $_POST['ctranspublisher'] ."\n";
if ($_POST['ctransaffiliate']) $BODY .= "Affiliate: " . $_POST['ctransaffiliate'] . "\n";
$BODY .= "Amount: quot; . $_POST['caccountamount']/100 . "\n";

if ($_POST['ctid']) $BODY .= "TID: " . $_POST['ctid'] . "\n";

if ($_POST['ccustfullname']) $BODY .= "Customer Name: " . $_POST['ccustfullname']. "\nCustomer Email: " . $_POST['ccustemail']. "\n";

$BODY .= "\n\nhttp://www.ClickScoop.com - The Community for ClickBank Vendors and Affiliates";
}
else
{
$SUBJECT = 'FAILED TRANSACTION';
$BODY = 'SECURITY CHECK FAILED TO VERIFY';
$BODY .= print_r($_POST, true);
$BODY .= "Expected $_EXPECTED but found $_RESULTS instead";
}
mail($EMAIL_TO, $SUBJECT, $BODY , $HEADER);
?>

Replace the following information in the script…
Line 8 – You’ll need to create a secret key, this can be any series of up to 16 numbers and letters but must be in ALL UPPERCASE. Replace “ENTER SECRET KEY HERE” with your new secret key.
Line 12 – Replace “ENTER EMAIL ADDRESS HERE” with the email address you want your notifications sent to.
Upload the script to your website and note the path to the script. For example http://www.yourwebsite.com/folder/clickscoopnotify.php
Enable “Instant Notification” in your ClickBank Account.
Log into your ClickBank account and click on the Account Settings tab.

Click on “My Site.”

Under the “Advanced Tools” section click on “Edit.”

Under the “Advanced Tools Editor” click “request access.”

Answer the questions and make sure you’ve reviewed the Terms of Use. You’ll need to scroll to the bottom as there is a checkbox at the end of the terms.
Once you’ve agreed to the terms and click on “Save Changes & Request API Access.”

Enter your Secret Key. This is the same secret key you created in Step 2a above.

Paste the path to your script into the field “Instant Notification URL 1:

Select version 2.1 from the drop-down.

Click to Save Changes.
Test the script. After you’ve saved your changes go ahead and click the (test) link to test the script.

This will send a $1 test purchase notification. At this point you should receive an email. If not, check the steps above to make sure you’ve set everything up correctly.
Make sales and get notified by email!

Further customization…

Currently, the script emails information in the following way…

Email Subject –
New Transaction: (Transaction Type): $(Amount)

Body of email –
Product: (Title of product)
Vendor: (Product Vendor)
Affiliate: (Referring Affiliate) – Only displays if affiliate referred the sale.
Amount: $(Amount paid to you)
TID: (Tracking ID) – Only displays if there a TID is present.
Customer Name: (Customer Name) – Only displays if sale is made as a vendor.
Customer Email: (Customer Email Address) – Only displays if sale is made as a vendor.

By editing the script, you can customize the information in numerous ways to fit your specific needs. All the post parameters available with the Instant Notification Version 2.1 will work with this script. By editing the script you could display additional customer or transaction information, rebill info., product item numbers, and more. If you are not familiar with PHP then we recommend outsourcing to vWorker or somewhere else to have the script customized to your liking. For $10 to $15 many coders will easily do this for you.

Troubleshooting…
Make sure to double check your email address, Secret Key, and the Instant Notification URL.
The sale notification email may be getting marked as spam, so make sure to check your spam folder.
Verify with your web host that this script will work. Chances are it should, however in rare cases a web host may require a different email process for the script such as RackSpace cloud hosting.

No comments:

Post a Comment