This article is a mirror article of machine translation, please click here to jump to the original article.

View: 8263|Reply: 0

[Source] [Actual combat]. NET/C# WeChat public account JSAPI payment [with source code]

[Copy link]
Posted on 12/26/2021 3:21:34 PM | | | |
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:

WeChat Pay JSAPI URL of the current page is not registered for the solution
https://www.itsvse.com/thread-10190-1-1.html

ASP.NET WEB API responds to WeChat requests
https://www.itsvse.com/thread-5748-1-1.html

.net/c# WeChat public account upload picture [source code]
https://www.itsvse.com/thread-3903-1-1.html

WeChat official account development pictures cannot be displayed on the iOS platform
https://www.itsvse.com/thread-3889-1-1.html

WeChat web version login to send message analysis
https://www.itsvse.com/thread-3517-1-1.html

WeChat official account development VS remote debugging
https://www.itsvse.com/thread-3441-1-1.html

Solution to the jssdk signature error of WeChat official account under China Unicom
https://www.itsvse.com/thread-3245-1-1.html

WeChat prohibits opening web pages in Safari
https://www.itsvse.com/thread-3118-1-1.html

C#/.NET WeChat development to obtain the js-sdk signature
https://www.itsvse.com/thread-3081-1-1.html

WeChat public account development series of tutorials
https://www.itsvse.com/thread-3076-1-1.html

[source code].net/c# WeChat intelligent chat GIS location information scan to get picture function
https://www.itsvse.com/thread-3059-1-1.html

.net does WeChat development to obtain user information and scan function [with source code]
https://www.itsvse.com/thread-3052-1-1.html

Resources:

JSAPI Scenario Introduction:The hyperlink login is visible.
JSAPI Payment:The hyperlink login is visible.




Previous:.NET/C# data desensitization (sensitive information asterisk)
Next:Linux updates system time and time zone
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com