## Demand arises from It was a sunny morning , The writer is carrying a handsome backpack as usual , Comb your hair like an adult , Put on a smart suit and go to the bus stop , On the way to work , Good luck , The bus will arrive soon , After brushing the bus code, I got involved in the sea of people with the help of external forces, waiting silently for the next time for the external force to help me get off .
The morning is always fast , After lunch, I was preparing to lie on the table for lunch break when I received a wechat push fee deduction notice .
Received this kind of inexplicable deduction notice , My first feeling was that the number was stolen , Who stole my bus code ？ But the next second , A programmer's intuition tells himself that developers should not make such low-level mistakes , To some extent, the bus code is equivalent to a payment bar code , Why not rearrange , I personally tested it. It's really a dynamic rearrangement .
What is the reason ？ Next, let's invite the protagonist of today “ Enjoy before you pay ”, I believe that reading the whole content is very good to explain the previous “ Steal brush ” There's a problem . ## Concept Enjoy first, pay later, literally means to enjoy the service first and then pay , Great for user experience , At the end of the service, you don't have to worry about paying , The deduction is made automatically by the system , Especially for some high-frequency scenarios , Like bike sharing , Subway, bus, etc . ## Use scenarios 1. Transportation ： Didi taxi , Bike sharing, etc , After the user gets off the car, the system will pay automatically , Save user time ; 2. The new retail ： Some smart containers , When you close the door after you select the goods, the system will make deduction , I used it before e Home smart container , The experience is very good ; 3. Limited network environment ： For example, when the bus goes through some bad road sections , Unable to deduct fees in real time , But we can't delay the passengers , This situation is very suitable for storing offline orders inside the card machine , When the network is good, send the order data to the server, and the system will make up for it （ This is the reason for the delay in bus fare deduction mentioned above , In the morning, it should be that the Internet is not good, and the order is not synchronized ）; ## Usage flow The author's city can use wechat bus code for payment when taking subway or bus , You need to open it before using it , The opening process is as follows ： Steps 1： Open the ride code applet , The first time will prompt to open !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143521297-1529890172.png) Steps 2： Click on “ To open up ", This will bring you to a guide page , Check the agreement and then click “ Open now ” !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143537520-216403621.png) Steps 3： And then it comes to “ Open secret free payment ”, Click on “ Open secret free payment ” It means the opening process is over !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143557668-1532836524.png) !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143614545-1437266015.png) At this time, your bus code has been opened , It means you can use it to take the subway 、 It's a bus , Here is a flow chart to understand the overall process . !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143632739-106088260.png) ## Core point There are several core points in the whole process that deserve attention ： 1. Open secret free payment means that the user does not need to enter a password when paying , Automatically deducted by the system , What kind of deduction does the system use ？ The author looked through the relevant documents , Wechat is called entrusted withholding agreement id, Alipay is called withholding agreement number ; 2. The bus swipe card machine needs to store offline orders , When the equipment is disconnected from the network, there will be local , After networking, it will be sent to the cloud for compensation ; 3. Travel code needs to support offline payment , When the user's mobile phone is disconnected, it will not affect the user's riding ; 4. There needs to be a recovery mechanism , When the user has not deducted money from the background of the card machine, the user has turned off the secret free payment , It means that the previous order cannot be deducted , As shown in the figure below, users turn off secret free payment in wechat . !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143708844-1954195618.png) ## Process refinement ### Users sign up for secret free payment !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143724105-1877626150.png) User signing process ### The user rides Here are two key points to highlight ： 1. When the user opens the ride code applet , The applet determines different travel code generation strategies according to the user's mobile phone network status , If there is a network, call the back-end service to get the bus code , If there is no network, it will be generated locally , I guess the rule of code generation is qrCode=encrypt(" Users id, Time stamps, etc ”, encryption key), If there is no network, the last encryption of local cache will be used key, Otherwise, the server will be updated dynamically key; 2. After the user swipes the card , Machines will first generate local orders , If there is a network, the local order will be sent to the background service , The purpose of sending here is to prompt the user to “ Successful ride ”, Here's the picture 3.1,3.2 Shown ; !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143750568-198115208.png) User swipe card process ### Bus code backstage deduction 1. Background pull order to be deducted ; 2. Query user withholding agreement id, If the user has terminated the contract, mark the order as payment failure and insert the arrears record to prepare for the next recovery ; 3. If the user does not terminate the contract , Call wechat secret free payment interface , If the payment is successful, the order will be marked as paid successfully , Make a mark for the next step in the payment of a failed order （ The handling here is a little rough , If the user's balance is insufficient, the background can delay the retrying , Until the maximum number of retries , Here, for example, simplify the processing ）; !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143821524-832390552.png) Background deduction process ### Recovery - Remind users to pay back When the user is in arrears, the background helps the platform （ WeChat , Alipay ） Provides the ability to remind users to repay , Delete the user's arrearage record after the user has paid back , If the user fails to repay, the user is limited to continue using the service , The next process will introduce . !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143836325-553262396.png) Remind users to pay back !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143842558-1676793618.png) Arrears record ### Recovery - Limit the use of the service by defaulting users !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143859855-1861703757.png) Restrict the use of services !(https://img2020.cnblogs.com/blog/846817/202011/846817-20201105143906302-89242243.png) Limit the use of service interactions ## Summary “ Enjoy before you pay ” As a more popular way of consumption now , It does bring us a lot of convenience , But the emergence of everything is bound to have advantages and disadvantages , I'd like to briefly talk about my understanding here . ### Advantages ： 1. It's really convenient for individuals , After using the service, you don't have to pay for it , Automatically deducted by the system , The user experience is great ; 2. For businesses, it reduces the settlement cycle , Avoid some situations where you need to make a collection （ The author used to call an online car appointment and forgot to pay , I've received the driver's payment call ）; ### Disadvantages ： 1. For individuals , At the same time, it also brings certain risks , It's like giving your payment password to someone else ; 2. For businesses, they may face certain asset losses , After all, there are so many Laolai in the society ;