微信统一订单

https://www.iplayers.cn   企业建站 设计 本网站另有技术资料文档
$stringA->appid="";
$stringA->attach="";
$stringA->body="充值金额:".$fee;
$stringA->mch_id="";
$stringA->nonce_str="60uf9sh6nmppr9azveb2bn7arhy79izk";
$stringA->notify_url="";
$stringA->out_trade_no=$out_trade_no;
$stringA->total_fee=$fee*100;
$stringA->trade_type="APP";
foreach ($stringA as $k => $v)
{
$Parameters[$k] = $v;
}
ksort($Parameters);
$urlencode=false;
$buff = "";
foreach ($Parameters as $k => $v)
{
if($urlencode)
{
$v = urlencode($v);
}
$buff .= $k . "=" . $v . "&";
}
$reqPar;
if (strlen($buff) > 0)
{
$reqPar = substr($buff, 0, strlen($buff)-1);
}
$reqPar = $reqPar."&key=abcdefghijklmnopqrstuvwxyz012345";
$String = md5($reqPar);
$sign = strtoupper($String);
$fee_wx=$fee*100;
$xmlData = "<xml>
<appid>wx20f0d48a859d752f</appid>
<attach>".$stringA->attach."</attach>
<body>".$stringA->body."</body>
<mch_id>1307712801</mch_id>
<nonce_str>60uf9sh6nmppr9azveb2bn7arhy79izk</nonce_str>
<notify_url></notify_url>
<out_trade_no>".$out_trade_no."</out_trade_no>
<total_fee>".$stringA->total_fee."</total_fee>
<trade_type>APP</trade_type>
<sign>".$sign."</sign>
</xml>";
$url = 'https://api.mch.weixin.qq.com/pay/unifiedorder';
$header[] = "Content-type: text/xml";
$ch = curl_init ($url);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xmlData);
$response = curl_exec($ch);
var_dump($response);
if(curl_errno($ch)){
print curl_error($ch);
}
curl_close($ch);




?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值