Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Z
zhichan
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
蒋勇
zhichan
Commits
cabcf7b0
Commit
cabcf7b0
authored
Mar 31, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
cd885517
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
5 deletions
+14
-5
center-app/app/base/api/impl/payment/aliPayment.js
+6
-0
center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js
+8
-5
No files found.
center-app/app/base/api/impl/payment/aliPayment.js
View file @
cabcf7b0
...
...
@@ -14,5 +14,10 @@ class AliPayment extends APIBase {
var
result
=
await
this
.
utilsAlibankSve
.
getH5AliDingPayInfo
(
pobj
,
pobj
.
actionBody
);
return
result
;
}
async
test
(
pobj
,
qobj
,
req
)
{
var
pobj
=
{
appInfo
:
{
uapp_id
:
22
},
actionBody
:
{
total_fee
:
0.01
,
order_num
:
"111222"
,
body_desc
:
"标题描述1"
}
};
var
result
=
await
this
.
utilsAlibankSve
.
getH5AliDingPayInfo
(
pobj
,
pobj
.
actionBody
);
return
result
;
}
}
module
.
exports
=
AliPayment
;
\ No newline at end of file
center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js
View file @
cabcf7b0
...
...
@@ -39,12 +39,13 @@ class utilsTlBankSve extends AppServiceBase {
body
:
actionBody
.
body_desc
,
sign_type
:
"RSA"
};
//
var signStr = await this.getCreateAliSignStr(payParam, parameters);
var
signStr
=
await
this
.
generateSign
(
pobj
,
parameters
,
payParam
.
privatekey
,
"RSA-SHA1"
);
parameters
.
sign
=
signStr
;
var
signStr
=
await
this
.
getCreateAliSignStr
(
payParam
,
parameters
);
//
var signStr = await this.generateSign(pobj, parameters, payParam.privatekey, "RSA-SHA1");
parameters
.
sign
=
encodeURIComponent
(
signStr
)
;
return
system
.
getResultSuccess
(
parameters
);
}
async
getCreateAliSignStr
(
payParam
,
parameters
)
{
let
userPrivateKey
=
payParam
.
privatekey
;
const
key
=
new
NodeRSA
();
...
...
@@ -52,7 +53,9 @@ class utilsTlBankSve extends AppServiceBase {
key
.
importKey
(
userPrivateKey
,
'pkcs8-private'
);
//导入密钥并设定格式
const
publicDer
=
key
.
exportKey
(
'pkcs8-public'
);
let
text
=
Object
.
keys
(
parameters
).
sort
().
map
(
key
=>
{
return
`
${
encodeURIComponent
(
key
)}
=
${
encodeURIComponent
(
parameters
[
key
])}
`
if
(
key
!=
"sign_type"
&&
key
!=
"sign"
&&
parameters
[
key
])
{
return
`
${
encodeURIComponent
(
key
)}
=
${
encodeURIComponent
(
parameters
[
key
])}
`
}
}).
join
(
'&'
);
let
buffer
=
Buffer
.
from
(
text
);
let
signature
=
key
.
sign
(
buffer
).
toString
(
'base64'
);
...
...
@@ -70,7 +73,7 @@ class utilsTlBankSve extends AppServiceBase {
* @returns {String}
*/
async
generateSign
(
pobj
,
dataObj
,
privateKey
,
algorith
)
{
privateKey
=
"-----BEGIN RSA PRIVATE KEY-----
"
+
privateKey
+
"
-----END RSA PRIVATE KEY-----"
;
privateKey
=
"-----BEGIN RSA PRIVATE KEY-----
\
n"
+
privateKey
+
"
\
n
-----END RSA PRIVATE KEY-----"
;
const
stringToBeSign
=
Object
.
keys
(
dataObj
).
sort
().
reduce
((
acc
,
k
)
=>
{
if
(
k
!==
'sign'
&&
dataObj
[
k
]
!==
undefined
)
{
const
v
=
`
${
dataObj
[
k
]}
`
;
...
...
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