Authored by 郭成尧

wechat-pay-disturb

@@ -2,7 +2,7 @@ @@ -2,7 +2,7 @@
2 * @Author: Targaryen 2 * @Author: Targaryen
3 * @Date: 2017-01-03 17:42:41 3 * @Date: 2017-01-03 17:42:41
4 * @Last Modified by: Targaryen 4 * @Last Modified by: Targaryen
5 - * @Last Modified time: 2017-01-04 18:19:06 5 + * @Last Modified time: 2017-01-05 13:52:47
6 */ 6 */
7 7
8 'use strict'; 8 'use strict';
@@ -13,6 +13,8 @@ const logger = global.yoho.logger; @@ -13,6 +13,8 @@ const logger = global.yoho.logger;
13 const rp = require('request-promise'); 13 const rp = require('request-promise');
14 const Promise = require('bluebird'); 14 const Promise = require('bluebird');
15 const co = Promise.coroutine; 15 const co = Promise.coroutine;
  16 +const sign = require('./sign');
  17 +const md5 = require('md5');
16 18
17 /** 19 /**
18 * 微信支付相关工具类 20 * 微信支付相关工具类
@@ -122,9 +124,12 @@ const tools = { @@ -122,9 +124,12 @@ const tools = {
122 total_fee: params.totalFee, 124 total_fee: params.totalFee,
123 trade_type: 'JSAPI', 125 trade_type: 'JSAPI',
124 openid: params.openId, 126 openid: params.openId,
125 - sign: '', // TODO 签名算法  
126 sign_type: 'MD5', 127 sign_type: 'MD5',
127 }; 128 };
  129 +
  130 + let signStr = md5(sign.raw(unifiedParams) + WxPayConfig.KEY).toUpperCase();
  131 +
  132 + _.assign(unifiedParams, {sign: signStr});
128 } 133 }
129 }; 134 };
130 135
@@ -111,6 +111,7 @@ module.exports = { @@ -111,6 +111,7 @@ module.exports = {
111 WxPayConfig: { 111 WxPayConfig: {
112 APPID: 'wx75e5a7c0c88e45c2', 112 APPID: 'wx75e5a7c0c88e45c2',
113 MCHID: '1227694201', 113 MCHID: '1227694201',
  114 + KEY: '7e6f3307b64cc87c79c472814b88f7fb',
114 APPSECRET: 'ce21ae4a3f93852279175a167e54509b' 115 APPSECRET: 'ce21ae4a3f93852279175a167e54509b'
115 } 116 }
116 }; 117 };