Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
haishi
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
冷斌
haishi
Commits
2fdca42c
Commit
2fdca42c
authored
Mar 27, 2020
by
冷斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
2a761bff
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
73 deletions
+70
-73
api/Appapi/Api/Charge.php
+70
-73
No files found.
api/Appapi/Api/Charge.php
View file @
2fdca42c
...
@@ -93,24 +93,6 @@ class Api_Charge extends PhalApi_Api {
...
@@ -93,24 +93,6 @@ class Api_Charge extends PhalApi_Api {
$rs
[
'msg'
]
=
'微信未配置'
;
$rs
[
'msg'
]
=
'微信未配置'
;
return
$rs
;
return
$rs
;
}
}
$wx_config
=
[
'appid'
=>
'wxa6bcebff7f4c5a3f'
,
'appSecret'
=>
'4b7d6cd67fc566659fd1d9bd399dbcba'
,
'mch_id'
=>
'1582052881'
,
'key'
=>
'XCthxXszMdXiybUZnJBxyVgyVnV4zPuQ'
,
'notify_url'
=>
'http://www.seals-live.com/index.php?g=Appapi&m=pay&a=notify_wx'
,
'log'
=>
[
// optional
'file'
=>
dirname
(
dirname
(
dirname
(
__DIR__
)))
.
'/wechat.log'
,
'level'
=>
'info'
,
// 建议生产环境等级调整为 info,开发环境为 debug
'type'
=>
'single'
,
// optional, 可选 daily.
'max_file'
=>
30
,
// optional, 当 type 为 daily 时有效,默认 30 天
],
];
// require dirname(dirname(dirname(__DIR__))) . '/vendor/autoload.php';
$wx
=
\Yansongda\Pay\Pay
::
wechat
(
$wx_config
);
var_dump
(
$wx_config
,
$wx
);
die
;
$orderinfo
=
array
(
$orderinfo
=
array
(
"uid"
=>
$uid
,
"uid"
=>
$uid
,
...
@@ -137,64 +119,79 @@ class Api_Charge extends PhalApi_Api {
...
@@ -137,64 +119,79 @@ class Api_Charge extends PhalApi_Api {
}
}
$noceStr
=
md5
(
rand
(
100
,
1000
)
.
time
());
//获取随机字符串
// $noceStr = md5(rand(100,1000).time());//获取随机字符串
$time
=
time
();
// $time = time();
// $paramarr = array(
$paramarr
=
array
(
// "appid" => $configpri['wx_appid'],
"appid"
=>
$configpri
[
'wx_appid'
],
// "body" => "充值{$coin}虚拟币",
"body"
=>
"充值
{
$coin
}
虚拟币"
,
// "mch_id" => $configpri['wx_mchid'],
"mch_id"
=>
$configpri
[
'wx_mchid'
],
// "nonce_str" => $noceStr,
"nonce_str"
=>
$noceStr
,
//// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
// "notify_url" => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx',
"notify_url"
=>
$configpub
[
'site'
]
.
'/index.php?g=Appapi&m=pay&a=notify_wx'
,
// "out_trade_no"=> $orderid,
"out_trade_no"
=>
$orderid
,
// "total_fee" => $money*100,
"total_fee"
=>
$money
*
100
,
// "trade_type" => "APP"
"trade_type"
=>
"APP"
// );
);
// $sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名
$sign
=
$this
->
sign
(
$paramarr
,
$configpri
[
'wx_key'
]);
//生成签名
// $paramarr['sign'] = $sign;
$paramarr
[
'sign'
]
=
$sign
;
// $paramXml = "<xml>";
$paramXml
=
"<xml>"
;
// foreach($paramarr as $k => $v){
foreach
(
$paramarr
as
$k
=>
$v
){
// $paramXml .= "<" . $k . ">" . $v . "</" . $k . ">";
$paramXml
.=
"<"
.
$k
.
">"
.
$v
.
"</"
.
$k
.
">"
;
// }
}
// $paramXml .= "</xml>";
$paramXml
.=
"</xml>"
;
//
// $ch = curl_init ();
$ch
=
curl_init
();
// @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 跳过证书检查
// @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, true); // 从证书中检查SSL加密算法是否存在
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYHOST
,
true
);
// 从证书中检查SSL加密算法是否存在
// @curl_setopt($ch, CURLOPT_URL, "https://api.mch.weixin.qq.com/pay/unifiedorder");
@
curl_setopt
(
$ch
,
CURLOPT_URL
,
"https://api.mch.weixin.qq.com/pay/unifiedorder"
);
// @curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
@
curl_setopt
(
$ch
,
CURLOPT_RETURNTRANSFER
,
true
);
// @curl_setopt($ch, CURLOPT_POST, 1);
@
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
// @curl_setopt($ch, CURLOPT_POSTFIELDS, $paramXml);
@
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$paramXml
);
// @$resultXmlStr = curl_exec($ch);
@
$resultXmlStr
=
curl_exec
(
$ch
);
// if(curl_errno($ch)){
if
(
curl_errno
(
$ch
)){
// //print curl_error($ch);
//print curl_error($ch);
// file_put_contents('./wxpay.txt',date('y-m-d H:i:s').' 提交参数信息 ch:'.json_encode(curl_error($ch))."\r\n",FILE_APPEND);
file_put_contents
(
'./wxpay.txt'
,
date
(
'y-m-d H:i:s'
)
.
' 提交参数信息 ch:'
.
json_encode
(
curl_error
(
$ch
))
.
"
\r\n
"
,
FILE_APPEND
);
// }
}
// curl_close($ch);
curl_close
(
$ch
);
//
// $result2 = $this->xmlToArray($resultXmlStr);
//
// if($result2['return_code']=='FAIL'){
// $rs['code']=1005;
// $rs['msg']=$result2['return_msg'];
// return $rs;
// }
// $time2 = time();
// $prepayid = $result2['prepay_id'];
// $sign = "";
// $noceStr = md5(rand(100,1000).time());//获取随机字符串
// $paramarr2 = array(
// "appid" => $configpri['wx_appid'],
// "noncestr" => $noceStr,
// "package" => "Sign=WXPay",
// "partnerid" => $configpri['wx_mchid'],
// "prepayid" => $prepayid,
// "timestamp" => $time2
// );
// $paramarr2["sign"] = $this -> sign($paramarr2,$configpri['wx_key']);//生成签名
// $rs['info'][0]=$paramarr2;
$result2
=
$this
->
xmlToArray
(
$resultXmlStr
);
$wx_config
=
[
'wechat'
=>
[
'appid'
=>
'wxa6bcebff7f4c5a3f'
,
'appSecret'
=>
'4b7d6cd67fc566659fd1d9bd399dbcba'
,
'mch_id'
=>
'1582052881'
,
'key'
=>
'XCthxXszMdXiybUZnJBxyVgyVnV4zPuQ'
,
'notify_url'
=>
'http://www.seals-live.com/index.php?g=Appapi&m=pay&a=notify_wx'
,
]
];
if
(
$result2
[
'return_code'
]
==
'FAIL'
){
require
dirname
(
dirname
(
dirname
(
__DIR__
)))
.
'/vendor/autoload.php'
;
$rs
[
'code'
]
=
1005
;
$wx
=
new
\Yansongda\Pay\Pay
(
$wx_config
);
$rs
[
'msg'
]
=
$result2
[
'return_msg'
];
return
$rs
;
}
$time2
=
time
();
$prepayid
=
$result2
[
'prepay_id'
];
$sign
=
""
;
$noceStr
=
md5
(
rand
(
100
,
1000
)
.
time
());
//获取随机字符串
$paramarr2
=
array
(
"appid"
=>
$configpri
[
'wx_appid'
],
"noncestr"
=>
$noceStr
,
"package"
=>
"Sign=WXPay"
,
"partnerid"
=>
$configpri
[
'wx_mchid'
],
"prepayid"
=>
$prepayid
,
"timestamp"
=>
$time2
);
$paramarr2
[
"sign"
]
=
$this
->
sign
(
$paramarr2
,
$configpri
[
'wx_key'
]);
//生成签名
$rs
[
'info'
][
0
]
=
$paramarr2
;
$data
=
$wx
->
app
(
$orderid
);
$rs
[
'info'
][
0
]
=
json_decode
(
$data
,
true
);
return
$rs
;
return
$rs
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment