支付回调
<pre><code class="language-php">&lt;?php
/*
*支付成功通知
*/
$urldata = isset($GLOBALS[&quot;HTTP_RAW_POST_DATA&quot;]) ? $GLOBALS[&quot;HTTP_RAW_POST_DATA&quot;] : '';//获取请求参数
$success = &quot;SUCCESS&quot;; //成功
$fail = &quot;FAILURE&quot;; //失败
// 缺少参数
if (empty($urldata)) {
exit($fail);
}
$urldata = get_object_vars(json_decode($urldata));
$order_id = isset($urldata['order_id']) ? $urldata['order_id'] : '';
$mem_id = isset($urldata['mem_id']) ? $urldata['mem_id'] : '';
$app_id = isset($urldata['app_id']) ? intval($urldata['app_id']) : 0;
$money = isset($urldata['money']) ? $urldata['money'] : 0.00;
$order_status = isset($urldata['order_status']) ? $urldata['order_status'] : '';
$paytime = isset($urldata['paytime']) ? intval($urldata['paytime']) : 0;
$attach = isset($urldata['attach']) ? $urldata['attach'] : ''; //CP扩展参数
$sign = isset($urldata['sign']) ? $urldata['sign'] : ''; // 签名
//money 参数为小数点后两位
$money = number_format($money,2);
//1 校验参数合法性
if (empty($urldata) || empty($order_id) || empty($mem_id) || empty($app_id) || empty($money)
|| empty($order_status) || empty($paytime) || empty($attach) || empty($sign)){
//CP添加自定义参数合法检测
exit($fail);
}
//2 校验此单合法性
{
$attach;
//CP自定义参数,可以为CP的订单ID,与其他信息,校验平台订单合法性.建议英文与数字,请不要有特殊字符 UTF-8编码
}
//3 通过游戏id查询appkey
{
//通过游戏ID查询到此游戏的appkey,
$appkey = &quot;&quot;;
}
// 4 拼接参数
{
$paramstr = &quot;order_id=&quot;.$order_id.&quot;&amp;mem_id=&quot;.$mem_id.&quot;&amp;app_id=&quot;.$app_id.&quot;&amp;money=&quot;.$money.&quot;&amp;order_status=&quot;.$order_status.&quot;&amp;paytime=&quot;.$paytime.&quot;&amp;attach=&quot;.$attach.&quot;&amp;app_key=&quot;.$appkey;
$verrifysign = md5($paramstr);
if (0 == strcasecmp($verrifysign, $sign)){
exit($success);
}
}
exit($fail);</code></pre>