Wechat Mini Program

Posted onby admin


Weixin Mini Programs strive to lower the barrier for merchants to build a digital presence within Weixin ecosystem. Leveraging a range of developer tools, infrastructure and operational support, businesses can develop and use Mini Programs to provide better service for their customers. This document describes how merchant or software company integrate Wechat Pay miniprogram payment function by calling Ksher MiniProgram Pay API. Applicable Cases MiniProgram Pay API if for merchants who already verified mini-program on WeChat Open platform, so that who can use Ksher MiniProgram Pay API to integrate payment function.

  1. wx.checkSession


  2. wx.login

  3. wx.getUserInfo

  4. Send code, encryptedData, iv to server

Weixin app api can return user’s nickname and avatar, but not its openid





  1. session_key is the key to decode user’s data
  2. Everytime wx.login() called, session_key will be updated
  3. wx.checkSession() to check if session is valid


  1. Client: wx.login() to get temporaryCode (is called code in weixin’s api return value, and it can be used onece only)

  2. Client: Send temporaryCode to server

  3. Server: Send appid+appsecret+temporaryCode to Weixin’s server, Weixin’s server returns session_key (salt of temporaryCode) and openid (openid is the unique Weixin user id)

  4. Server: return 3rd_session (token; selfDefinedLoginStatus) (maybe can be the same as openid ) that generated according to session_key and openid to client.

  5. Client: Store 3rd_session (token) in persistence

  6. Client: Do request with 3rd_session(token)

  7. Server: Check if user can do request with 3rd_session(token)

Note: Weixin nickName code format is ISO-8859-1, you can convert it with:

Java Backend

Good version: https://my.oschina.net/magicalSam/blog/832895

juejin version: https://juejin.im/post/5ac9b72cf265da23906c486a

Simple version:https://my.oschina.net/ZhenyuanLiu/blog/1838069

Wechat mini program e-commerce

Wechat Mini Program Tutorial





注意:此接口有调整,使用该接口将不再出现授权弹窗,请使用 **<button open-type='getUserInfo'></button> 引导用户主动进行授权操作**

getUserInfo return :

userInfo contains:

We should use session_key , iv to decrypt encryptedData


access_token 是全局唯一接口调用凭据,开发者调用各接口时都需使用 access_token






App decode request

Server side


Please enable JavaScript to view the comments powered by Disqus.

Why WeChat Mini Programs Are Such A Hit

WeChat Mini Programs are just as evolved just as their name and their magnificent ability to transform themselves into whatever they want. The beauty of mini programs is the simplicity of use without the need to download an entire app for the sake of a single function, because, ‘Why buy the cow when all you want is milk’? All you need is WeChat to let you access these intriguing mini programs that are cooler than reality (Highly subjective).

Picture yourself entering a one-stop-store that lets you test, buy or play anything you want! Right from trying out your favourite food to booking trains, flights or hotels. That’s exactly what a mini program lets you do without getting out of your store (the app) and downloading an extra app (that occupies storage) on your phone.

What Is A Mini Program?

Mini Programs are html5 sub-applications within WeChat that carry out a host of functions that depend on the mini program you decide to engage with.

What Does A Mini Program Do?

An interesting fact about the term ‘Mini Program: The sub-applicationsfunction like regular mobile apps but Tencent strangely refrained from callingthem mini apps to avoid disputes with Apple over the use of the term “app”.

Would you believe the extent of its popularity if we told you that Google ran a mini program of its own once upon a time? (Summer of 2018)

1. E-commerce mini programs

Brands and vendors offer sweepstakes, cash rebates, group-buying options, virtual gift cards and live streaming services to 962 million users on WeChat. Major e-commerce players like Alibaba and JD.com devised mini programs to share key product information among WeChat contacts. The integration of WeChat pay further simplifies the whole shopping process and incentivizes those that shop through the program.

2.WeChat Minigames

WeChat mini games are mini programs integrated into WeChat that are designed for gaming. The feature lets users compete with their friends trying to beat their scores on leaderboards. Once the game is over, you get an automatic notification to see which friends you have beaten. This gamification retains users for a longer time, thereby increasing brand engagement. Jump Jump was one such mini program game that challenged the player to jump over different boxes by pressing the screen without falling out. This mini-app reached 100 million users in two weeks.

3. Lifestyle Mini programs

These mini programs let you carry out a range of daily activities like booking a cab, a doctor’s appointment or even a hotel. Tesla ran a mini program that let users book themselves a test drive through the mini app. Bike sharing companies like Mobike have successfully leveraged this feature by letting users avail their service without downloading their app.

What Are The Mini Program Benefits?

– Access

A mini program lets you access it at any given point of time by simply clicking on the ‘mini program’ feature on the discover section of your WeChat app without downloading the app. These lightweight programs are what gave it popularity in the first place

-Brand Benefits

Here’s how Gucci leveraged the feature’s services with gamification: Gucci’s mini program allowed users to put a virtual mask on their selfie or picture. This feature attracted millennial consumers to try it out and show it off to their social networks.

Wechat Mini Program List

Mini programs have an active audience and they work in tandem with the OS that supports WeChat, which is why the time spent on WeChat Mini programs went from 1.6 minutes per day to 9.8 minutes. An survey indicated that 54.7% of JD.com’s mini program users come from Tier 3 or smaller cities as opposed to 43.7% of those using mobile apps.


Some of the most remarkable mini programs were run by Hangzhou plus, McDonald’s discount coupons, Tencent Surveys, Mobike Sleepy Sounds. Mini programs have their own set of advantages like that of simplicity. They are cheap to develop and easy to access which explains its 1 million userbase. Tencent’s WeChat developers are making them more advanced, particularly for gaming and e-commerce purposes, making WeChat become even more dominant in this market. Mini Programs are starting to become a part of daily routines for many WeChat users with Tencent throwing in new complex developments to the feature. With all that being said, what could possibly be the future of this feature? Will it continue as a temporary sub-app? Or will it find a more permanent space?
Tempted To Create Your Own Mini Program?