Preface:

From the wechat public number to the small program now, more and more content involving wechat development, most of the time we need to know more about wechat development, such as the boss said to do something, involving wechat, we can immediately think of the plan or put forward the feasibility of the analysis? Because the development of wechat has its own set of rules, has its own set of framework, there is a certain convenience it brings, also has its restrictions. This article does not write the introduction, does not write the development process, mainly talks about some recent research and details.

Main Platforms:

  • Open Platform (Document: wechat Open Platform)
  • Public Platform & Small Program (Document: wechat public Platform Document & wechat small program Document)
  • Merchant platform (Document: wechat Payment document)

1) Open platforms include: mobile applications, website applications, public accounts and small programs, and third-party platforms.

    1. Mobile application: Create mobile application and APP association on open platform, and provide wechat payment, sharing to wechat and other functions for app
    2. Website application: enable the website to support login with wechat account
    3. Public number and small program: in the open platform, can bind public number and small program, binding will trigger the unionId mechanism, to help different public number or small program through the user system.
    4. Third party platform: call the interface on behalf of small programs and public accounts to provide operation services and industry solutions

2) The public platform includes subscription number, service number and small program

3) Merchant platform: mainly supports wechat Payment, including online and offline payment application scenarios

The relationship among the three is shown in the figure below. All applications belong to the open platform. The open platform can bind mini programs and public accounts to associate them, and the merchant platform provides payment functions for all applications.

How to understand them better? The so-called process also includes registration. The wechat document is not particularly detailed in most of the time. The document tells us several steps of the process, but we do not know what the content of each process is. Finally, you still have to go through the process to understand, so you want to be more clear about the details, the best way to register. Wechat development related to a lot of content, research and development should pay attention to not only how to call the interface, but also need to pay attention to the relationship between the platform, operation specifications, design specifications and so on.

List some common problems

Wechat authorized OAuth2.0

Wechat authorization is almost the entry interface of all applications under wechat development. After user authorization, we can get user information by requesting wechat back end. The authorization process is roughly as follows:

1. After a third party initiates a wechat authorized login request and a wechat user authorizes a third party application, wechat will pull up the application or redirect it to the third party website with the code parameter of the authorized temporary note; 2. Exchange the access_token through API by adding AppID and AppSecret to the code parameter. 3. Invoke the access_token interface to obtain basic data resources or help users to perform basic operations

Official document: Appsecret is the key used by the application interface, which may lead to high risk consequences such as application data leakage and user data leakage. Stored on the client side, there is a high risk of malicious theft (such as decompiling to get Appsecret).

Speaking of this problem, there was also an accident at that time. Appsecret, the background of wechat public platform, did not have the function of modification, but could only be reset. Wechat also has statistical function in the background. At that time, operation colleagues asked them to give them accounts, so that they could check them in real time. On the second day, we found that the business function was out of order and could not be used. The front-end check was out of order and the back-end check was out of order. How to look at the business logic, it was not the code that changed the problem. It turned out that an operations colleague had clicked on all the functions in the public background and reset AppSecret. The bottom line is, don’t give background permissions to non-r&d colleagues, and if you do, you should warn them in advance.

Message distribution correlation

Products need to be reminded of users, and message notifications are particularly important in normal development, often because the rules of messages can affect the initial product requirements.

  • The public account can send mass messages at a certain frequency (subscription number: once a day, service number: 4 times a month)
  • Public number template message can use specific content template, take the initiative to send messages to users, can bring links, it can be said that there is no limit on the number of times
  • The template message of the applet requires the user to interact with the form component to get the form ID in order to send the template to the user

WeChat share

After the application of mobile apps registered on the open platform is approved, you can get the permission to share and favorites on wechat.

If the following steps are required in a web page:

1. Fill in “JS interface security domain name” in wechat public platform

2. The need to call JS interface pages to introduce the following JS files, support (HTTPS) : res.wx.qq.com/open/js/jwe…

3. Verify the configuration through the injection permission of the Config interface (the configuration signature must be obtained from the backend).

Currently, a public account can fill in three JS interface security domain name addresses. The front-end pages of most companies are deployed under a certain domain name. The back-end can provide only one public account’s signature interface as a public service. The services of other public accounts can invoke this interface under the same domain name to complete JSSDK signature configuration.

WeChat pay

1) In order to use wechat payment, the company subject of our merchant number must be the same as the registered subject such as the small program of our public account, otherwise the merchant number cannot be bound.

2) How to realize the payment of test public account:

A dictionary is generated to store the openId of the test public account and the official public account of the test user. When the test public account invokes payment, the back end will replace the openId of the test public account with the official public account and use the merchant number of the same subject to make normal payment. It’s just a formal payment that calls the callback of the test.

3) Binding merchant number to public number:

Sometimes, some documents of wechat developers are not easy to find, and the entry is relatively deep. For example, at first, I wanted to find out how to bind the merchant number to multiple public accounts, but there were no relevant documents for a long time, and there were no relevant documents in several development documents. And in the background of wechat public platform “wechat pay”, the relevant documents and entrance can not be found. Fortunately, because the company has a merchant number, I logged in and found it. If you are a novice, you may not find the document when doing technical research. At the beginning, I thought that the background of merchant and public accounts could apply for binding with each other, but this function is only available in merchant accounts. After the merchant platform adds the authorization application form, the corresponding public platform background can be seen under [wechat Pay ~ M-A Authorization].

  • Application page for binding merchant Number:

  • Public platform background application authorization page

How the authorization document links pay.weixin.qq.com/static/pay_… , the document entry is as follows (hard to find) :

As for payment, the enterprise back-end should provide a public service for each kind of payment. Whenever a new public account needs to be paid, it only needs to configure the corresponding parameters and call the public service to place an order. If necessary, the front end can also make a wallet page compatible with payment in multiple scenarios. If the account system is opened, the wallet will have the top-up balance, and users can directly choose to deduct the balance. If it is in a non-wechat browser, the wallet should also have alipay and other payment methods. However, the existence of the wallet page will jump again. If the wallet page is used in wechat, the user experience is not as good as the direct call for payment.

Open up account system through open platform

Most of the following applications of an enterprise hope to have an account system, so that the data between each other can be connected, and each public account or the corresponding user under the application has a different openId, so it is impossible to identify the same user between different applications. At this time, wechat open platform is needed. Wechat public accounts, mobile applications, small programs, etc., are all identified by openId to identify the uniqueness of users. Open platforms can bind these applications. After binding, the same user will generate unionID to reflect the uniqueness of users. Details UnionID mechanism.

Currently an open platform can bind:

  • 50 Mobile Apps (Native)
  • 10 web apps
  • There are 50 public accounts of the same subject company and 5 public accounts of different subject companies
  • 50 applets of the same principal company and 5 applets of different principal company

Principal Registration Restrictions

I have been looking for how many public accounts a company can register, but I have not found any explanation in the developer documents of the public platform. Results this piece of content in QQ customer service that website kf.qq.com/faq/120911V…

Account transfer

The main public number can not be replaced once the audit is completed. If you need to change, only A new public account can be registered for migration, migration can only migrate part of the data, A user in different public account openId is not the same principle, if A public account to B public account, need to perform an openId conversion, the official interface, see details: kf.qq.com/faq/170221a… . Applets cannot be migrated at this time.

conclusion

Wechat development is prone to many pits, more than technology, and its volume is getting bigger and bigger, the front and back end should understand the whole development process, development configuration, operation rules and so on, otherwise it is easy to do not know who the problem is, the efficiency of solving the problem will be very low, and even each other. Wechat ecological functions are constantly iterating, developer technical documents and various policies are also changing from time to time, which we need to pay attention to all the time.