...
|
...
|
@@ -2,7 +2,7 @@ |
|
|
* @Author: Targaryen
|
|
|
* @Date: 2017-01-03 17:42:41
|
|
|
* @Last Modified by: Targaryen
|
|
|
* @Last Modified time: 2017-02-20 10:15:03
|
|
|
* @Last Modified time: 2017-02-20 17:46:16
|
|
|
*/
|
|
|
|
|
|
'use strict';
|
...
|
...
|
@@ -15,6 +15,7 @@ const Promise = require('bluebird'); |
|
|
const co = Promise.coroutine;
|
|
|
const sign = require('./sign');
|
|
|
const md5 = require('md5');
|
|
|
const moment = require('moment');
|
|
|
const common = require('./common');
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -108,9 +109,13 @@ const tools = { |
|
|
out_trade_no: 'YOHOBuy_' + params.orderCode,
|
|
|
total_fee: params.totalFee * 100,
|
|
|
trade_type: 'JSAPI',
|
|
|
time_start: moment().format('YYYYMMDDHHmmss'),
|
|
|
time_expire: moment().add(2, 'hours').format('YYYYMMDDHHmmss'),
|
|
|
spbill_create_ip: params.ip,
|
|
|
openid: params.openId,
|
|
|
sign_type: 'MD5'
|
|
|
};
|
|
|
|
|
|
let signStr = md5(sign.raw(unifiedParams) + '&key=' + WxPayConfig.key).toUpperCase();
|
|
|
|
|
|
_.assign(unifiedParams, { sign: signStr });
|
...
|
...
|
@@ -158,13 +163,14 @@ const Wechat = { |
|
|
/**
|
|
|
* 异步拉起微信支付相关处理
|
|
|
*/
|
|
|
pay(user, order, openId) {
|
|
|
pay(user, order, openId, ip) {
|
|
|
|
|
|
return co(function* () {
|
|
|
let unifiedOrderResult = yield tools.unifiedOrder({
|
|
|
orderCode: order.order_code,
|
|
|
totalFee: parseFloat(order.payment_amount),
|
|
|
openId: openId
|
|
|
openId: openId,
|
|
|
ip: ip
|
|
|
});
|
|
|
|
|
|
if (unifiedOrderResult) {
|
...
|
...
|
|