Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
my-yaf-project
Project
Project
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
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
chenchuanwen
my-yaf-project
Commits
e10ff338
Commit
e10ff338
authored
Nov 09, 2018
by
liuyuzhen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
测试
parent
8a860b4d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
6 deletions
+23
-6
TencentPay.php
application/library/Payment/TencentPay.php
+23
-6
No files found.
application/library/Payment/TencentPay.php
View file @
e10ff338
...
@@ -128,11 +128,13 @@ class TencentPay {
...
@@ -128,11 +128,13 @@ class TencentPay {
/**
/**
* 作用:设置标配的请求参数,生成签名,生成接口参数xml
* 作用:设置标配的请求参数,生成签名,生成接口参数xml
*/
*/
function
createXml
()
function
createXml
(
$signType
=
'MD5'
)
{
{
if
(
$signType
==
'MD5'
){
$this
->
parameters
[
"sign"
]
=
$this
->
getSign
(
$this
->
parameters
);
//签名
$this
->
parameters
[
"sign"
]
=
$this
->
getSign
(
$this
->
parameters
);
//签名
}
else
{
$this
->
parameters
[
"sign"
]
=
$this
->
getHMACSHA1Sign
(
$this
->
parameters
,
'sha256'
);
}
return
$this
->
arrayToXml
(
$this
->
parameters
);
return
$this
->
arrayToXml
(
$this
->
parameters
);
}
}
...
@@ -258,7 +260,9 @@ class TencentPay {
...
@@ -258,7 +260,9 @@ class TencentPay {
//签名步骤一:按字典序排序参数
//签名步骤一:按字典序排序参数
ksort
(
$Parameters
);
ksort
(
$Parameters
);
$String
=
$this
->
formatBizQueryParaMap
(
$Parameters
,
false
);
$String
=
$this
->
formatBizQueryParaMap
(
$Parameters
,
false
);
$String
=
$String
.
"&key="
.
$this
->
key
;
$String
=
$String
.
"&key="
.
$this
->
key
;
\Our\Log
::
getInstance
()
->
write
(
$this
->
key
,
'/data/log/applognew'
);
//签名步骤三:MD5加密
//签名步骤三:MD5加密
$String
=
md5
(
$String
);
$String
=
md5
(
$String
);
$result_
=
strtoupper
(
$String
);
$result_
=
strtoupper
(
$String
);
...
@@ -269,7 +273,7 @@ class TencentPay {
...
@@ -269,7 +273,7 @@ class TencentPay {
/**
/**
* 作用:生成签名(按照HMAC-SHA1规则签名)
* 作用:生成签名(按照HMAC-SHA1规则签名)
*/
*/
public
function
getHMACSHA1Sign
(
$Obj
)
public
function
getHMACSHA1Sign
(
$Obj
,
$signType
=
'sha1'
)
{
{
foreach
(
$Obj
as
$k
=>
$v
)
foreach
(
$Obj
as
$k
=>
$v
)
{
{
...
@@ -280,7 +284,7 @@ class TencentPay {
...
@@ -280,7 +284,7 @@ class TencentPay {
$String
=
$this
->
formatBizQueryParaMap
(
$Parameters
,
false
);
$String
=
$this
->
formatBizQueryParaMap
(
$Parameters
,
false
);
//$String = $String."&key=".$this->key;
//$String = $String."&key=".$this->key;
//签名步骤三:HMAC-SHA1加密
//签名步骤三:HMAC-SHA1加密
$String
=
hash_hmac
(
'sha1'
,
$String
,
$this
->
key
);
$String
=
hash_hmac
(
$signType
,
$String
,
$this
->
key
);
$result_
=
base64_encode
(
$String
);
$result_
=
base64_encode
(
$String
);
return
$result_
;
return
$result_
;
}
}
...
@@ -350,6 +354,19 @@ class TencentPay {
...
@@ -350,6 +354,19 @@ class TencentPay {
}
}
/**
* 作用:产生随机字符串,不长于32位
*/
public
function
createNoncestr
(
$length
=
32
)
{
$chars
=
"abcdefghijklmnopqrstuvwxyz0123456789"
;
$str
=
""
;
for
(
$i
=
0
;
$i
<
$length
;
$i
++
)
{
$str
.=
substr
(
$chars
,
mt_rand
(
0
,
strlen
(
$chars
)
-
1
),
1
);
}
return
$str
;
}
/**
/**
* 将xml数据返回微信
* 将xml数据返回微信
*/
*/
...
...
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