function getSign(){
$stringA="appid=wx1eab284c0454ecab&body=test&device_info=1000&mch_id=1535695301&nonce_str=".nonce_str();
$stringSignTemp=$stringA."&key=16f2330f2934FASDFsddfasw"; //注:key为商户平台设置的密钥key
$string = md5($stringSignTemp);
//签名步骤四:所有字符转为大写
$result = strtoupper($string);
return $result;
}
$fee=100;
$appid="wxasdfsdaflsa";
$body="test";
$mch_id="1535695601";
$nonce_str=random();
$notify_url="";
$out_trade_no=order_number();
$spbill_create_ip="125.216.62.121";
$total_fee=$fee*100;
$trade_type="JSAPI";
$post_xml = '<xml><appid>'.$appid.'</appid>
<body>'.$body.'</body>
<device_info>pccbshop</device_info>
<mch_id>'.$mch_id.'</mch_id>
<nonce_str>'.$nonce_str.'</nonce_str>
<notify_url>'.$notify_url.'</notify_url>
<openid>'.$openid.'</openid>
<out_trade_no>'.$out_trade_no.'</out_trade_no>
<spbill_create_ip>'.$spbill_create_ip.'</spbill_create_ip>
<total_fee>'.$total_fee.'</total_fee>
<trade_type>'.$trade_type.'</trade_type>
<sign>'.getSign().'</sign>
<sign_type>md5</sign_type>
</xml> ';
//echo getSign();
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
$xml = http_request($url,$post_xml);
echo $xml;exit;
签名方式的值应该是 MD5 不是 md5,注意大小写。