首页 违章代办 违章代办示例代码 异步通知[PHP]

异步通知示例代码[PHP]

作者: 阅读数:1799 上传时间:

异步通知

<?php

$orderno = $_POST['orderno'];
$handlestatus = $_POST['handlestatus'];
$arr = array('orderno'=>$orderno,'outorderno'=>$_POST['outorderno'],'mobile'=>$_POST['mobile'],'handlestatus'=>$_POST['handlestatus'],'totalfee'=>$_POST['totalfee'],'servicefee'=>$_POST['servicefee']);
$appsecret = '123456789';//用户appsecret
if(checkSign($arr, $appsecret, $_POST['sign']))
{
    //1成功 2处理失败 0处理中
    switch($handlestatus)
    {        
        case '1': 
        {
            //成功
            //            
            break;
        }
        case '2':
        {
            //处理失败
            break;
        }
    }
    
    if($handlestatus != 0) echo 'success';
    exit();
}

/**
 * 验证签名 
 * 
 */
function checkSign($queryarr, $appsecret, $signature)
{    
    $str = makeSign($queryarr, $appsecret);
    if($str == strtolower($signature)) return true;
    else return false;
}

/**
 * 生成签名 
 * 
 */
function makeSign($queryarr, $appsecret)
{
    ksort($queryarr, SORT_STRING);
    $str = implode($queryarr);
    $str .= $appsecret;
    //exit($str);
    $str = md5($str);
    
    return $str;
}