ClickBank is generous to provide code examples for many implementations of their Instant Notification Service, but… they don’t include Perl for some reason.
Here’s my Perl implementation.
use CGI; use Digest::SHA1 qw(sha1_hex); use Encode; $q = new CGI; sub ipnVerification() { my $secretkey = 'YOUR SECRET KEY'; my $pop = ""; foreach $field (sort($q->param)) { unless ($field eq "cverify") { $pop .= $q->param($field) . "|"; } } $pop .= $secretkey; my $calcedVerify = sha1_hex(encode("utf8", $pop)); $calcedVerify = uc(substr($calcedVerify,0,8)); return ($calcedVerify eq $q->param("cverify")); }
Enjoy!
Hi Jeremy,
Im using a .net implementation and when I use the “test” option that they provide at
Account>my site and enter the secret key and enter my url and click test… the value of the hash that’s calculated and the value that they send in the cverify param are different.
Now I’m wondering if their sample code is wrong or the hash that they send in the test url option is just a dummy value?
Wanted your opinion since you too seem to be working on the same thing.
From what I see all they are doing is taking the value of each post parameter ( except the cverify) , concatenating it with the “|” symbol and creating a hash of it?
I look forward to your comments. Thanks
Satya, a few things might be tripping you up.
Hope that helps!
Nice one Jeremy – Just what I needed as I could not find any descent examples.
BTW – It is Perl and not PERL! Perl is the langauge, and perl is the binary…Apparently
😉
Thanks! I’ve changed PERL to Perl. Good catch and thanks! 😉