q-koa 12.2.7 → 12.2.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -25,6 +25,7 @@ exports.refund = async ({
|
|
|
25
25
|
pay_config = 'weixin_pay',
|
|
26
26
|
out_trade_no: _out_trade_no,
|
|
27
27
|
out_refund_no: _out_refund_no,
|
|
28
|
+
is_pem = false,
|
|
28
29
|
...rest
|
|
29
30
|
}) => {
|
|
30
31
|
if (!ctx) throw new Error('?ctx')
|
|
@@ -44,7 +45,7 @@ exports.refund = async ({
|
|
|
44
45
|
__dirname,
|
|
45
46
|
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.p12`
|
|
46
47
|
)
|
|
47
|
-
),
|
|
48
|
+
),
|
|
48
49
|
})
|
|
49
50
|
const orderModel = prefix ? `${prefix}_order` : 'order'
|
|
50
51
|
const out_trade_no = _out_trade_no
|
|
@@ -63,6 +64,22 @@ exports.refund = async ({
|
|
|
63
64
|
appid: appId,
|
|
64
65
|
mch_id: mchId,
|
|
65
66
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
67
|
+
...(is_pem
|
|
68
|
+
? {
|
|
69
|
+
cert_pem: await fsPromise.readFile(
|
|
70
|
+
path.resolve(
|
|
71
|
+
__dirname,
|
|
72
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.pem`
|
|
73
|
+
)
|
|
74
|
+
),
|
|
75
|
+
key_pem: await fsPromise.readFile(
|
|
76
|
+
path.resolve(
|
|
77
|
+
__dirname,
|
|
78
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_key.pem`
|
|
79
|
+
)
|
|
80
|
+
),
|
|
81
|
+
}
|
|
82
|
+
: {}),
|
|
66
83
|
})
|
|
67
84
|
const payResult = await wxpay.queryOrderSync({
|
|
68
85
|
out_trade_no,
|
|
@@ -86,7 +103,9 @@ exports.refund = async ({
|
|
|
86
103
|
}
|
|
87
104
|
|
|
88
105
|
console.log(data)
|
|
89
|
-
const { result_code, err_code_des, ...restData } =
|
|
106
|
+
const { result_code, err_code_des, ...restData } = is_pem
|
|
107
|
+
? await wxpay.refund(data)
|
|
108
|
+
: await payObj.refund(data)
|
|
90
109
|
if (result_code === 'SUCCESS') {
|
|
91
110
|
const hasResult = await app.model.order_refund_record.findOne({
|
|
92
111
|
where: {
|
|
@@ -119,6 +138,7 @@ exports.refundOnly = async ({
|
|
|
119
138
|
pay_config = 'weixin_pay',
|
|
120
139
|
out_trade_no: _out_trade_no,
|
|
121
140
|
out_refund_no: _out_refund_no,
|
|
141
|
+
is_pem = false,
|
|
122
142
|
...rest
|
|
123
143
|
}) => {
|
|
124
144
|
if (!ctx) throw new Error('?ctx')
|
|
@@ -148,6 +168,22 @@ exports.refundOnly = async ({
|
|
|
148
168
|
appid: appId,
|
|
149
169
|
mch_id: mchId,
|
|
150
170
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
171
|
+
...(is_pem
|
|
172
|
+
? {
|
|
173
|
+
cert_pem: await fsPromise.readFile(
|
|
174
|
+
path.resolve(
|
|
175
|
+
__dirname,
|
|
176
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.pem`
|
|
177
|
+
)
|
|
178
|
+
),
|
|
179
|
+
key_pem: await fsPromise.readFile(
|
|
180
|
+
path.resolve(
|
|
181
|
+
__dirname,
|
|
182
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_key.pem`
|
|
183
|
+
)
|
|
184
|
+
),
|
|
185
|
+
}
|
|
186
|
+
: {}),
|
|
151
187
|
})
|
|
152
188
|
|
|
153
189
|
try {
|
|
@@ -161,7 +197,9 @@ exports.refundOnly = async ({
|
|
|
161
197
|
}
|
|
162
198
|
|
|
163
199
|
console.log(data)
|
|
164
|
-
const { result_code, err_code_des, ...restData } = await
|
|
200
|
+
const { result_code, err_code_des, ...restData } = (await is_pem)
|
|
201
|
+
? await wxpay.refund(data)
|
|
202
|
+
: await payObj.refund(data)
|
|
165
203
|
if (result_code === 'SUCCESS') {
|
|
166
204
|
return restData
|
|
167
205
|
} else {
|
|
@@ -633,10 +671,16 @@ exports.profitsharing = async ({
|
|
|
633
671
|
appid: app_id,
|
|
634
672
|
mch_id: mchId,
|
|
635
673
|
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
636
|
-
|
|
674
|
+
cert_pem: await fsPromise.readFile(
|
|
637
675
|
path.resolve(
|
|
638
676
|
__dirname,
|
|
639
|
-
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.
|
|
677
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_cert.pem`
|
|
678
|
+
)
|
|
679
|
+
),
|
|
680
|
+
key_pem: await fsPromise.readFile(
|
|
681
|
+
path.resolve(
|
|
682
|
+
__dirname,
|
|
683
|
+
`${process.cwd()}/app/${appName}/plugins/weixin/${key}/apiclient_key.pem`
|
|
640
684
|
)
|
|
641
685
|
),
|
|
642
686
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "q-koa",
|
|
3
|
-
"version": "12.2.
|
|
3
|
+
"version": "12.2.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -54,7 +54,7 @@
|
|
|
54
54
|
"sequelize": "^5.21.3",
|
|
55
55
|
"static-koa-router": "^1.0.3",
|
|
56
56
|
"wechat-oauth": "^1.5.0",
|
|
57
|
-
"weixin-pay-fork": "^1.0.
|
|
57
|
+
"weixin-pay-fork": "^1.0.8",
|
|
58
58
|
"node-uuid": "^1.4.8",
|
|
59
59
|
"sha1": "^1.1.1",
|
|
60
60
|
"redis": "^4.0.3",
|