q-koa 10.3.0 → 10.4.0
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.
|
@@ -838,7 +838,6 @@ exports.pc_pay = async (ctx) => {
|
|
|
838
838
|
order_id,
|
|
839
839
|
price,
|
|
840
840
|
prefix = '',
|
|
841
|
-
type = 'PC-WEIXIN',
|
|
842
841
|
out_trade_no: _out_trade_no,
|
|
843
842
|
is_admin = false,
|
|
844
843
|
config = 'weixin_mp',
|
|
@@ -846,77 +845,8 @@ exports.pc_pay = async (ctx) => {
|
|
|
846
845
|
} = ctx.request.body
|
|
847
846
|
|
|
848
847
|
if (price === 0) throw new Error('价格不能为0')
|
|
849
|
-
|
|
850
|
-
const appConfig = getConfig(app)
|
|
851
|
-
|
|
852
|
-
const { mchId, key, partner_key } = await appConfig.getObject(pay_config)
|
|
853
|
-
|
|
854
|
-
const { is_dev, site_host } = await appConfig.getObject('base')
|
|
855
|
-
// 公众号支付用 服务号 appid,其他用小程序 appid
|
|
856
|
-
const app_id = (await appConfig.getObject(config)).app_id
|
|
857
|
-
|
|
858
|
-
const wxpay = WXPay({
|
|
859
|
-
appid: app_id,
|
|
860
|
-
mch_id: mchId,
|
|
861
|
-
partner_key: key.length > 10 ? key : partner_key, // 微信商户平台API密钥
|
|
862
|
-
})
|
|
863
|
-
|
|
864
|
-
const pay = (options) =>
|
|
865
|
-
new Promise((resolve, reject) => {
|
|
866
|
-
wxpay.createUnifiedOrder(options, (err, result) => {
|
|
867
|
-
if (err) return reject(err)
|
|
868
|
-
return resolve(result)
|
|
869
|
-
})
|
|
870
|
-
})
|
|
871
|
-
|
|
872
|
-
const out_trade_no = _out_trade_no
|
|
873
|
-
? _out_trade_no
|
|
874
|
-
: prefix
|
|
875
|
-
? `${key.length > 10 ? appName : key}_${prefix}-${order_id}_${type}`
|
|
876
|
-
: `${key.length > 10 ? appName : key}_${order_id}_${type}`
|
|
877
|
-
|
|
878
|
-
const notify_url = `https://${
|
|
879
|
-
site_host || 'api.kuashou.com'
|
|
880
|
-
}/${appName}/weixin/notify`
|
|
881
|
-
|
|
882
|
-
const result = await pay({
|
|
883
|
-
body: name,
|
|
884
|
-
detail: '公众号支付测试',
|
|
885
|
-
out_trade_no,
|
|
886
|
-
trade_type: 'NATIVE',
|
|
887
|
-
total_fee: is_admin || is_dev ? 1 : Math.round(price * 100),
|
|
888
|
-
spbill_create_ip: '192.168.2.210',
|
|
889
|
-
notify_url,
|
|
890
|
-
})
|
|
891
|
-
|
|
892
|
-
if (result.result_code === 'FAIL') throw new Error(result.err_code_des)
|
|
893
|
-
|
|
894
|
-
return ctx.SUCCESS(
|
|
895
|
-
`https://${site_host || 'api.kuashou.com'}/${appName}/common/createQr?url=${
|
|
896
|
-
result.code_url
|
|
897
|
-
}`
|
|
898
|
-
)
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
exports.pc_pay = async (ctx) => {
|
|
902
|
-
const { app, appName } = getAppByCtx(ctx)
|
|
903
|
-
const {
|
|
904
|
-
name,
|
|
905
|
-
order_id,
|
|
906
|
-
price,
|
|
907
|
-
prefix = '',
|
|
908
|
-
out_trade_no: _out_trade_no,
|
|
909
|
-
is_admin = false,
|
|
910
|
-
config = 'weixin_mp',
|
|
911
|
-
pay_config = 'weixin_pay',
|
|
912
|
-
} = ctx.request.body
|
|
913
|
-
|
|
914
|
-
if (price === 0) throw new Error('价格不能为0')
|
|
915
|
-
|
|
916
|
-
if (!app.service.weixin) throw new Error(`weixin可能没有service.js`)
|
|
917
848
|
const result = await app.service.weixin.pc_pay({
|
|
918
|
-
|
|
919
|
-
appName,
|
|
849
|
+
ctx,
|
|
920
850
|
name,
|
|
921
851
|
order_id,
|
|
922
852
|
price,
|
|
@@ -444,25 +444,23 @@ exports.funds_order_refund = async ({ app, result }) => {
|
|
|
444
444
|
}
|
|
445
445
|
|
|
446
446
|
exports.pc_pay = async ({
|
|
447
|
-
|
|
448
|
-
appName,
|
|
447
|
+
ctx,
|
|
449
448
|
name,
|
|
450
449
|
order_id,
|
|
451
450
|
price,
|
|
452
|
-
config,
|
|
453
|
-
pay_config,
|
|
451
|
+
config = 'weixin_mp',
|
|
452
|
+
pay_config = 'weixin_pay',
|
|
454
453
|
out_trade_no: _out_trade_no,
|
|
455
454
|
is_admin,
|
|
456
455
|
type = 'PC-WEIXIN',
|
|
457
456
|
prefix,
|
|
458
457
|
}) => {
|
|
458
|
+
const { app, appName } = getAppByCtx(ctx)
|
|
459
459
|
const appConfig = getConfig(app)
|
|
460
|
-
|
|
460
|
+
const app_id = (await appConfig.getObject(config)).app_id
|
|
461
461
|
const { mchId, key, partner_key } = await appConfig.getObject(pay_config)
|
|
462
462
|
|
|
463
463
|
const { is_dev, site_host } = await appConfig.getObject('base')
|
|
464
|
-
// 公众号支付用 服务号 appid,其他用小程序 appid
|
|
465
|
-
const app_id = (await appConfig.getObject(config)).app_id
|
|
466
464
|
|
|
467
465
|
const wxpay = WXPay({
|
|
468
466
|
appid: app_id,
|
|
@@ -497,10 +495,12 @@ exports.pc_pay = async ({
|
|
|
497
495
|
spbill_create_ip: '192.168.2.210',
|
|
498
496
|
notify_url,
|
|
499
497
|
})
|
|
500
|
-
|
|
501
498
|
if (result.return_code === 'FAIL') {
|
|
502
499
|
throw new Error(result.return_msg)
|
|
503
500
|
}
|
|
501
|
+
if (result.result_code === 'FAIL') {
|
|
502
|
+
throw new Error(result.err_code_des)
|
|
503
|
+
}
|
|
504
504
|
|
|
505
505
|
return `https://${
|
|
506
506
|
site_host || 'api.kuashou.com'
|