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
20095837
Commit
20095837
authored
Apr 02, 2020
by
宋毅
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tj
parent
d3da5eeb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
20 deletions
+22
-20
center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js
+22
-20
No files found.
center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js
View file @
20095837
...
...
@@ -26,6 +26,15 @@ class utilsTlBankSve extends AppServiceBase {
return
{
status
:
-
310
,
msg
:
"应用没有对应的支付凭证"
};
}
var
parameters
=
{
// "service="mobile.securitypay.pay"",
// "partner="2088101568338364"",
// "_input_charset="utf-8"",
// "notify_url="http://notify.msp.hk/notify.htm"",
// "out_trade_no="0819145412-6177"",
// "subject="《暗黑破坏神3:凯恩之书》"",
// "payment_type="1"",
// "seller_id="alipay-test01@alipay.com"",
// "total_fee="0.01""
service
:
"mobile.securitypay.pay"
,
partner
:
payParam
.
partner
,
_input_charset
:
"UTF-8"
,
...
...
@@ -33,42 +42,35 @@ class utilsTlBankSve extends AppServiceBase {
// app_id: pobj.appInfo.uapp_id.toString(),//可为空
out_trade_no
:
actionBody
.
order_num
,
subject
:
"888"
,
//actionBody.body_desc,
body
:
"888"
,
//actionBody.body_desc,
payment_type
:
"1"
,
seller_id
:
payParam
.
seller_id
,
total_fee
:
actionBody
.
total_fee
,
body
:
"888"
,
//actionBody.body_desc,
total_fee
:
actionBody
.
total_fee
.
toString
(),
sign_type
:
"RSA"
};
var
signStr
=
await
this
.
getCreateAliSignStr
(
pobj
,
parameters
,
payParam
.
privatekey
,
"sha1"
);
// let signParam = "a=123";
let
signParam
=
await
this
.
getVerifyParams
(
parameters
);
var
signStr
=
await
this
.
getCreateAliSignStr
(
pobj
,
signParam
,
payParam
.
privatekey
,
"sha1"
);
// var signStr = await this.getSign(pobj,payParam.privatekey, parameters);
parameters
.
sign
=
encodeURIComponent
(
signStr
);
return
system
.
getResultSuccess
(
parameters
);
// parameters.sign = encodeURIComponent(signStr);
signParam
=
signParam
+
"&sign=
\"
"
+
encodeURIComponent
(
signStr
)
+
"
\"
&sign_type=
\"
"
+
parameters
.
sign_type
+
"
\"
"
;
return
system
.
getResultSuccess
(
signParam
);
}
async
getCreateAliSignStr
(
pobj
,
parameters
,
privateKey
,
algorith
)
{
async
getCreateAliSignStr
(
pobj
,
signParam
,
privateKey
,
algorith
)
{
privateKey
=
"-----BEGIN PRIVATE KEY-----"
+
privateKey
+
"-----END PRIVATE KEY-----"
;
const
key
=
new
NodeRSA
();
key
.
setOptions
({
b
:
1024
,
signingScheme
:
algorith
});
key
.
importKey
(
privateKey
,
'pkcs8-private'
);
//导入密钥并设定格式
const
publicDer
=
key
.
exportKey
(
'pkcs8-public'
);
// let text = Object.keys(parameters).sort().map(key => {
// if (key != "sign_type" && key != "sign" && parameters[key]) {
// return `${encodeURIComponent(key)}=${encodeURIComponent(parameters[key])}`
// }
// }).join('&');
// let text = "a=123";
let
text
=
await
this
.
getVerifyParams
(
parameters
);
// console.log(text, "signature.............texttexttexttext.............>")
let
buffer
=
Buffer
.
from
(
text
);
let
buffer
=
Buffer
.
from
(
signParam
);
let
signature
=
key
.
sign
(
buffer
).
toString
(
'base64'
);
// console.log(signature, "signature..........................>")
this
.
logCtl
.
info
({
appid
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_id
:
""
,
appkey
:
pobj
.
appInfo
?
pobj
.
appInfo
.
uapp_key
:
""
,
op
:
"center-app/app/base/service/impl/utilsSve/utilsAlibankSve.js/getCreateAliSignStr"
,
content
:
"参数:"
+
text
+
"返回结果signStr:"
+
signature
,
content
:
"参数:"
+
signParam
+
"返回结果signStr:"
+
signature
,
optitle
:
"获取钉钉支付签名信息返回"
,
});
return
signature
;
...
...
@@ -85,11 +87,11 @@ class utilsTlBankSve extends AppServiceBase {
if
(
key
===
"subject"
||
key
===
"body"
)
{
sPara
.
push
([
key
,
"
\"
"
+
encodeURIComponent
(
params
[
key
])
+
"
\"
"
]);
}
else
{
sPara
.
push
([
key
,
params
[
key
]
]);
sPara
.
push
([
key
,
"
\"
"
+
params
[
key
]
+
"
\"
"
]);
}
// sPara.push([key, "\"" + params[key] + "\""]);
}
sPara
=
sPara
.
sort
();
//
sPara = sPara.sort();
var
prestr
=
''
;
for
(
var
i2
=
0
;
i2
<
sPara
.
length
;
i2
++
)
{
var
obj
=
sPara
[
i2
];
...
...
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