nodejs微信公众号支付开发

2020-06-17 07:31:42易采站长站整理

app.use(bodyParser.xml({
limit: '2MB', // Reject payload bigger than 1 MB
xmlParseOptions: {
normalize: true, // Trim whitespace inside text nodes
normalizeTags: true, // Transform tags to lowercase
explicitArray: false // Only put nodes in array if >1
}
}));

这样你就可以正常的获取到微信的 xml 数据了。

使用方法:


pay.getAccessToken({
notify_url : 'http://demo.com/', //微信支付完成后的回调
out_trade_no : new Date().getTime(), //订单号
attach : '名称',
body : '购买信息',
total_fee : '1', // 此处的额度为分
spbill_create_ip : req.connection.remoteAddress,
}, function (error, responseData) {
res.render('payment', {
title : '微信支付',
wxPayParams : JSON.stringify(responseData),
//userInfo : userInfo
});
});

就到这里吧, 感觉也差不多了。如有不对的地方还请指正。

附上我自己的代码:https://git.oschina.net/anziguoer/wechatPay

本文已被整理到了《JavaScript微信开发技巧汇总》,欢迎大家学习阅读。

为大家推荐现在关注度比较高的微信小程序教程一篇:《微信小程序开发教程》小编为大家精心整理的,希望喜欢。