WeChat payment types: payment code payment, JSAPI payment, native payment, APP payment, mini program payment, face payment, as shown in the figure below:
The hyperlink login is visible.
Each payment type corresponds to a different use caseIf we develop an H5 website in the WeChat official account, we can use JSAPI payment to complete the collection of orders! You need to apply for a WeChat service account to complete JSAPI payment.
I helped my friend write a demo of JSAPI payment before, so I'll sort it out and send it out today. First, let's take a lookRenderings of a website developed by .NET/C# successfully calling JSAPI payments:
JSAPI payment process
(1) Users click on your website link to determine whether the current cookie is invalid and invalid to obtain OpenID (2) Jump to get openid, jump tohttps://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=SCOPE&state=STATE#wechat_redirect This URL, all users jump to the same URL (3) Obtain the user's open ID through the access token and code parameters, address:https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code (4) Output a cookie, and the backend can know the current user's openid based on the cookie (5) Call the unified order interface:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_1, submit the callback address notify_url, and get the prepay_id value (6) JSAPI Adjustment Payment:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=7_7&index=6 (7) After the user pays, the WeChat backend will call the callback interface:https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=9_7
Download the source code and modify itweb.configSince I used an nginx reverse proxy_Layout.cshtmlThe file js and css paths are written dead, and you need to adjust them according to your situation, as shown in the figure below:
Source code download:The hyperlink login is visible.
Review:
Resources:
JSAPI Scenario Introduction:The hyperlink login is visible. JSAPI Payment:The hyperlink login is visible.
|