Clickbank IPN version 6 PHP / Laravel -
i trying create ipn listener clickbank far have not been successful.
i used code example listed on clickbank site: https://support.clickbank.com/entries/22803622-instant-notification-service
<?php // note: mcrypt libraries need installed , listed available extension in // phpinfo() able use method of decryption. $secretkey = "your secret key"; // secret key clickbank account // json raw body... $message = json_decode(file_get_contents('php://input')); // pull out encrypted notification , initialization vector // aes/cbc/pkcs5padding decryption $encrypted = $message->{'notification'}; $iv = $message->{'iv'}; error_log("iv: $iv"); // decrypt body... $decrypted = trim(mcrypt_decrypt(mcrypt_rijndael_128, substr(sha1($secretkey), 0, 32), base64_decode($encrypted), mcrypt_mode_cbc, base64_decode($iv)), "\0..\32"); error_log("decrypted: $decrypted"); // convert decrypted string json object... $order = json_decode($decrypted); // ready rock , roll - if decoding of json string wasn't successful, // can assume notification wasn't encrypted secret key. ?>
for ipn v4 managed verified confirmation ipn tester, , save output in logs. v6, can't save output log files. seems clickbank not sending anything. documentation vague, i'm wondering if code should working in first place.
does have experience this? should return other response 200?
thanks in advance.
<?php function ipnverification() { $secretkey="your secret key"; $pop = ""; $ipnfields = array(); foreach ($_post $key => $value) { if ($key == "cverify") { continue; } $ipnfields[] = $key; } sort($ipnfields); foreach ($ipnfields $field) { // if magic quotes enabled $_post[$field] need // un-escaped before being appended $pop $pop = $pop . $_post[$field] . "|"; } $pop = $pop . $secretkey; $calcedverify = sha1(mb_convert_encoding($pop, "utf-8")); $calcedverify = strtoupper(substr($calcedverify,0,8)); return $calcedverify == $_post["cverify"]; } ?>
you can use ipn verified. work well
Comments
Post a Comment