<?php
header('Content-type:text/html; Charset=utf-8');
ini_set
('
date
.timezone','Asia/Shanghai');
$data_s
=
file_get_contents
('php:
$data_s
= json_decode(
$data_s
,true);
function
wechartAddOrder(
$name
,
$ordernumber
,
$money
,
$openid
,
$timeStamp
,
$noncestr
){
$url
=
"https://api.mch.weixin.qq.com/v3/pay/transactions/jsapi"
;
$urlarr
=
parse_url
(
$url
);
$appid
= '小程序APPID';
$mchid
= '微信支付商户ID';
$xlid
= '微信支付公钥序列号';
$data
=
array
();
$time
=
$timeStamp
;
$data
['appid'] =
$appid
;
$data
['mchid'] =
$mchid
;
$data
['description'] =
$name
;
$data
['out_trade_no'] =
$ordernumber
;
$data
['notify_url'] =
"你的域名/你的支付目录路径/notify.php"
;
$data
['amount']['total'] =
intval
(
$money
* 1);
$data
['payer']['openid'] =
$openid
;
$data
= json_encode(
$data
);
$key
= getSign(
$data
,
$urlarr
['path'],
$noncestr
,
$time
);
$token
= sprintf('mchid=
"%s"
,serial_no=
"%s"
,nonce_str=
"%s"
,timestamp=
"%d"
,signature=
"%s"
',
$mchid
,
$xlid
,
$noncestr
,
$time
,
$key
);
$header
=
array
(
'Content-Type:'.'application/json; charset=UTF-8',
'Accept:application/json',
'User-Agent:*
function
curl_post_https(
$url
,
$data
,
$header
){
$curl
= curl_init();
curl_setopt(
$curl
, CURLOPT_URL,
$url
);
curl_setopt(
$curl
, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt(
$curl
, CURLOPT_SSL_VERIFYHOST, 1);
curl_setopt(
$curl
, CURLOPT_USERAGENT,
$_SERVER
['HTTP_USER_AGENT']);
curl_setopt(
$curl
, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt(
$curl
, CURLOPT_AUTOREFERER, 1);
curl_setopt(
$curl
, CURLOPT_POST, 1);
curl_setopt(
$curl
, CURLOPT_POSTFIELDS,
$data
);
curl_setopt(
$curl
, CURLOPT_TIMEOUT, 30);
curl_setopt(
$curl
, CURLOPT_HEADER, 0);
curl_setopt(
$curl
, CURLOPT_RETURNTRANSFER, 1);
curl_setopt(
$curl
, CURLOPT_HTTPHEADER,
$header
);
$tmpInfo
= curl_exec(
$curl
);
if
(curl_errno(
$curl
)) {
echo
'Errno'.curl_error(
$curl
);
}
curl_close(
$curl
);
return
$tmpInfo
;
}
暂时没有评论,来抢沙发吧~