weixin-pay icon indicating copy to clipboard operation
weixin-pay copied to clipboard

公众号支付取回的值为undefined

Open Shakell opened this issue 6 years ago • 0 comments

想要达到的效果: 想在后端拿到用于前端调起微信内支付(公众号支付)的相关参数

目前的效果: 取回的信息为中不正确,包含undefined,没有相关错误提示

使用接口的代码为:

router.get('/wexin/jsapi/:data', async function(req,res,next) {
	try {
                //我先在这里通过一些操作取到openid
		const data = JSON.parse(req.params.data);
		wxpay.getBrandWCPayRequestParams({
			openid: openid,
			body: '公众号支付测试',
		        detail: '公众号支付测试',
			out_trade_no: data.orderId,
			total_fee: data.total_fee,
			spbill_create_ip: '192.168.2.210',
			notify_url: 'https://47.75.40.253/wechat/callback',
		}, function(err, result){
			console.log(result);
		});
	} catch (e) {
		console.log(e);
	}
})

得到的结果:

{ appId: 'wxbbbe3315cf3d4d71',
  timeStamp: '1531245546',
  nonceStr: undefined,
  package: 'prepay_id=undefined',
  signType: 'MD5',
  paySign: 'D3FA8F7B5D32C50E9863CFF0D71809FA' }

其中nonceStr为undefined,prepay_id应该是未正确生成。

Shakell avatar Jul 10 '18 18:07 Shakell