23 Star 65 Fork 24

秀杰 / 灵动商城node版

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
order.js 1.79 KB
一键复制 编辑 原始数据 按行查看 历史
秀杰 提交于 2017-10-30 17:20 . wxpay
const AV = require('leanengine');
const wxpay = require('./wxpay');
const {
validateSign,
handleError,
} = require('./utils');
class Order extends AV.Object {
get tradeId() { return this.get('tradeId'); }
set tradeId(value) { this.set('tradeId', value); }
get amount() { return this.get('amount'); }
set amount(value) { this.set('amount', value); }
get user() { return this.get('user'); }
set user(value) { this.set('user', value); }
get productDescription() { return this.get('productDescription'); }
set productDescription(value) { this.set('productDescription', value); }
get status() { return this.get('status'); }
set status(value) { this.set('status', value); }
get ip() { return this.get('ip'); }
set ip(value) { this.set('ip', value); }
get tradeType() { return this.get('tradeType'); }
set tradeType(value) { this.set('tradeType', value); }
get prepayId() { return this.get('prepayId'); }
set prepayId(value) { this.set('prepayId', value); }
place() {
return new Promise((resolve, reject) => {
// 参数文档: https://pay.weixin.qq.com/wiki/doc/api/wxa/wxa_api.php?chapter=9_1
wxpay.createUnifiedOrder({
openid: this.user.get('authData').lc_weapp.openid,
body: this.productDescription,
out_trade_no: this.tradeId,
total_fee: this.amount,
spbill_create_ip: this.ip,
notify_url: process.env.WEIXIN_NOTIFY_URL,
trade_type: this.tradeType,
}, function(err, result) {
console.log(err, result);
if (err) return reject(err);
return resolve(result);
});
}).then(handleError).then(validateSign).then(({
prepay_id,
}) => {
this.prepayId = prepay_id;
// return this.save();
});
}
}
AV.Object.register(Order);
module.exports = Order;
NodeJS
1
https://gitee.com/laeser/lendoo-web.git
git@gitee.com:laeser/lendoo-web.git
laeser
lendoo-web
灵动商城node版
master

搜索帮助