我正在尝试为 Clickbank 创建一个 IPN 侦听器,但到目前为止我还没有成功。
我使用了 clickbank 网站上列出的代码示例:https: //support.clickbank.com/entries/22803622-Instant-Notification-Service
<?php
// NOTE: the mcrypt libraries need to be installed and listed as an available extension in
// your phpinfo() to be able to use this method of decryption.
$secretKey = "YOUR SECRET KEY"; // secret key from your ClickBank account
// get JSON from raw body...
$message = json_decode(file_get_contents('php://input'));
// Pull out the encrypted notification and the initialization vector for
// AES/CBC/PKCS5Padding decryption
$encrypted = $message->{'notification'};
$iv = $message->{'iv'};
error_log("IV: $iv");
// decrypt the 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 the decrypted string to a JSON object...
$order = json_decode($decrypted);
// Ready to rock and roll - If the decoding of the JSON string wasn't successful,
// then you can assume the notification wasn't encrypted with your secret key.
?>
对于 ipn v4,我设法为 ipn 测试器获得了经过验证的确认,并将输出保存在我的日志中。但是对于 v6,我什至无法将输出保存到日志文件中。似乎clickbank甚至没有发送任何东西。他们的文档含糊不清,我想知道这段代码是否应该首先工作。
有人有这方面的经验吗?我应该返回响应 200 以外的任何内容吗?
提前致谢。