H5 mall pays in WeChat APP

Foreword: The jsapi payment method must pay attention to the official account, and then use WeChat payment, and the h5 screen as a non-public account needs to use js sdk to evoke WeChat payment.

We recommend the WeChat public platform test link here:
http://mp.weixin.qq.com/debug/cgi-bin/sandbox?t=sandbox/login



1. Get the code
in the frontend get method, or in the background
https:// open.weixin.qq.com/connect/oauth2/authorize?appid=wx87a416348df09713&redirect_uri=http%3A%2F%2F10.88.75.139%3A8082%2Fcheckout%2Fguest&response_type=code&scope=snsapi_base&state=1#wechat_redirect
Here redirect_uri must be urlencode

2. Get openId according to appid, secret, code and get it
in the foreground:
https://api.weixin.qq.com/sns/oauth2/access_token?appid=wx87********f09713&secret=85327124638****** **963b5a50c&code=031mBHO10Uya2C1wPzM104zIO10mBHOm&grant_type=authorization_code
or in the background:
			WechatQueryCommand queryCommand = prepareWechatQueryCommand(variableMap);
			if(WechatQueryCommand.QUERY_METHOD_GET.equals(queryCommand.getQueryMethod())) {
				return URLConnectionUtil.getResponseBodyAsString(prepareWechatQueryCommand(variableMap).toQueryString());
			} else {
				return WechatUtil.post(queryCommand.getQueryUri(), queryCommand.toQueryString());
			}



Token is also included in the above return

parameters
response.setContentType("text/html; charset=UTF-8");
				PrintWriter out = response.getWriter();
				out.print(html);
				out.flush();  
		        out.close();

There will be problems


4. Use js-sdk to evoke WeChat payment service

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326477743&siteId=291194637