wechat.js
1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* @author: xiaoxiao.hao<xiaoxiao.hao@yoho.cn>
* @date: 2017/3/23
*/
'use strict';
const helpers = global.yoho.helpers;
module.exports = class extends global.yoho.BaseModel {
constructor(ctx) {
super(ctx);
}
pay(user, order, info) {
let options = {
order_code: order.order_code,
payment_code: info.id,
app_key: 'yohopc'
};
return this.get({
api: global.yoho.ServiceAPI,
url: 'payment/weixin_data',
data: options
}).then(result => {
if (result && result.code === 200 && result.data) {
let url = `/shopping/newpay/weixin?url=${result.data.codeUrl}&code=${order.order_code}`;
return {
code: 200,
data: {
href: helpers.urlFormat(url)
}
};
} else {
return {
code: 400,
message: result.message
};
}
});
}
};