Пример #1
0
<?php

error_reporting(0);
/**
 * 支付通知验签demo
 * 传输过程一律使用UTF-8编码
 */
define(LOG_FILE, './game.server.notify.log');
file_put_contents(LOG_FILE, "#" . date('Y-m-d H:i:s') . "\n#AnySDK支付通知HTTP原文:\n" . get_http_raw() . "\n");
checkAnySDKSever();
$privateKey = "696064B29E9A0B7DDBD6FCB88F34A555";
$enhancedKey = 'OGM3ODFkNDRhYjUzYjM4ZmUzZjk';
$params = $_POST;
//注意:$_POST数据如果服务器没有自动处理urldecode,请做一次urldecode(参考rfc1738标准)处理
//foreach ($params as $key => $value) {
//        $params[$key] = urldecode($value);
//}
//注意:如果没有增强密钥的游戏只需要通用验签即可,即只需要checkSign
//if (checkSign($params, $privateKey)) {
if (checkSign($params, $privateKey) && checkEnhancedSign($params, $enhancedKey)) {
    checkAmount($params);
    // @todo 验证成功,游戏服务器处理逻辑
    echo "ok";
} else {
    //@todo
    echo "Wrong signature.";
}
exit;
/**
 * anysdk 支付通知白名单判断
 */
Пример #2
0
 /**
  * 记录HTTP请求原文为日志文件
  * @return string
  */
 function http_log()
 {
     if (!file_exists('./log/http.txt')) {
         file_put_contents('./log/http.txt', '');
     }
     $content = file_get_contents("./log/http.txt");
     $ret = "time:" . date('Y-m-d H:i:s', time()) . "\n";
     $ret .= "---start---" . "\n";
     $ret .= get_http_raw() . "\n";
     $ret .= "---end---" . "\n\r";
     $content .= $ret;
     file_put_contents('./log/http.txt', $content);
 }