tvrcgo / weixin-pay

微信支付 Nodejs SDK
MIT License
919 stars 241 forks source link

code enhancement #34

Open cybersky opened 7 years ago

cybersky commented 7 years ago

WXPay.mix('getBrandWCPayRequestParams', function(order, fn){

order.trade_type = "JSAPI";
var _this = this;
this.createUnifiedOrder(order, function(err, data){

//TODO: check data['return_code'] and data['return_msg'] response here, otherwise client will get a callback data with like {..., nonceStr: undefined, package: "prepay_id=undefined"... } without any further debug infomation.

    var reqparam = {
        appId: _this.options.appid,
        timeStamp: Math.floor(Date.now()/1000)+"",
        nonceStr: data.nonce_str,
        package: "prepay_id="+data.prepay_id,
        signType: "MD5"
    };
    reqparam.paySign = _this.sign(reqparam);
    fn(err, reqparam);
});

});