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
1172412b
Commit
1172412b
authored
Mar 27, 2020
by
冷斌
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix bug
parent
8a5db478
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
90 deletions
+57
-90
api/Appapi/Api/Charge.php
+57
-90
No files found.
api/Appapi/Api/Charge.php
View file @
1172412b
<?php
<?php
class
Api_Charge
extends
PhalApi_Api
{
class
Api_Charge
extends
PhalApi_Api
{
public
function
getRules
()
{
public
function
getRules
()
{
...
@@ -47,17 +48,6 @@ class Api_Charge extends PhalApi_Api {
...
@@ -47,17 +48,6 @@ class Api_Charge extends PhalApi_Api {
return
$orderid
;
return
$orderid
;
}
}
protected
function
getWx
(
$configpri
,
$configpub
)
{
return
Yansongda\Pay\Pay
::
wechat
([
'appid'
=>
$configpri
[
'wx_appid'
],
'appSecret'
=>
$configpri
[
'wx_appsecret'
],
'mch_id'
=>
$configpri
[
'wx_mchid'
],
'key'
=>
$configpri
[
'wx_key'
],
'notify_url'
=>
$configpub
[
'site'
]
.
'/index.php?g=Appapi&m=pay&a=notify_wx'
,
]);
}
/**
/**
* 微信支付
* 微信支付
* @desc 用于 微信支付 获取订单号
* @desc 用于 微信支付 获取订单号
...
@@ -119,87 +109,64 @@ class Api_Charge extends PhalApi_Api {
...
@@ -119,87 +109,64 @@ class Api_Charge extends PhalApi_Api {
}
}
// $noceStr = md5(rand(100,1000).time());//获取随机字符串
$noceStr
=
md5
(
rand
(
100
,
1000
)
.
time
());
//获取随机字符串
// $time = time();
$time
=
time
();
// $paramarr = array(
// "appid" => $configpri['wx_appid'],
$paramarr
=
array
(
// "body" => "充值{$coin}虚拟币",
"appid"
=>
$configpri
[
'wx_appid'
],
// "mch_id" => $configpri['wx_mchid'],
// "nonce_str" => $noceStr,
//// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
// "notify_url" => $configpub['site'].'/index.php?g=Appapi&m=pay&a=notify_wx',
// "out_trade_no"=> $orderid,
// "total_fee" => $money*100,
// "trade_type" => "APP"
// );
// $sign = $this -> sign($paramarr,$configpri['wx_key']);//生成签名
// $paramarr['sign'] = $sign;
// $paramXml = "<xml>";
// foreach($paramarr as $k => $v){
// $paramXml .= "<" . $k . ">" . $v . "</" . $k . ">";
// }
// $paramXml .= "</xml>";
//
// $ch = curl_init ();
// @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // 跳过证书检查
// @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_RETURNTRANSFER, true);
// @curl_setopt($ch, CURLOPT_POST, 1);
// @curl_setopt($ch, CURLOPT_POSTFIELDS, $paramXml);
// @$resultXmlStr = curl_exec($ch);
// if(curl_errno($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);
// }
// 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;
require
dirname
(
dirname
(
dirname
(
__DIR__
)))
.
'/vendor/autoload.php'
;
$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'
,
]
];
ini_set
(
"display_errors"
,
On
);
ini_set
(
"error_reporting"
,
E_ALL
);
$wx
=
new
\Yansongda\Pay\Pay
(
$wx_config
);
$data
=
$wx
->
driver
(
'wechat'
)
->
gateway
(
'app'
)
->
pay
([
'out_trade_no'
=>
$orderid
,
"body"
=>
"充值
{
$coin
}
虚拟币"
,
"body"
=>
"充值
{
$coin
}
虚拟币"
,
"mch_id"
=>
$configpri
[
'wx_mchid'
],
"nonce_str"
=>
$noceStr
,
// "notify_url" => $configpub['site'].'/Appapi/pay/notify_wx',
"notify_url"
=>
$configpub
[
'site'
]
.
'/index.php?g=Appapi&m=pay&a=notify_wx'
,
"out_trade_no"
=>
$orderid
,
"total_fee"
=>
$money
*
100
,
"total_fee"
=>
$money
*
100
,
"spbill_create_ip"
=>
$_SERVER
[
"REMOTE_ADDR"
]
"trade_type"
=>
"APP"
]);
);
var_dump
(
$wx_config
,
$data
);
$sign
=
$this
->
sign
(
$paramarr
,
$configpri
[
'wx_key'
]);
//生成签名
die
;
$paramarr
[
'sign'
]
=
$sign
;
$rs
[
'info'
][
0
]
=
json_decode
(
$data
,
true
);
$paramXml
=
"<xml>"
;
foreach
(
$paramarr
as
$k
=>
$v
){
$paramXml
.=
"<"
.
$k
.
">"
.
$v
.
"</"
.
$k
.
">"
;
}
$paramXml
.=
"</xml>"
;
$ch
=
curl_init
();
@
curl_setopt
(
$ch
,
CURLOPT_SSL_VERIFYPEER
,
false
);
// 跳过证书检查
@
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_RETURNTRANSFER
,
true
);
@
curl_setopt
(
$ch
,
CURLOPT_POST
,
1
);
@
curl_setopt
(
$ch
,
CURLOPT_POSTFIELDS
,
$paramXml
);
@
$resultXmlStr
=
curl_exec
(
$ch
);
if
(
curl_errno
(
$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
);
}
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
;
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