Hello, everyone, I am dongdong. Today is the weekend again, I have time to write an article again, so I picked up the computer, crackling a wave of output, today to share with you is wechat pay.
1. Do you have any questions?
Because wechat Pay must provide business license and need back-end cooperation (in fact, it can be developed by cloud), many students cannot access wechat pay in their daily study. For those who have never done wechat pay, there must be a lot of doubts. The biggest doubt is how to do the cashier desk? How did you set up that keyboard for the password? Follow this train of thought, will think more and more confused, ha ha ha. For those of you who have done wechat pay, you may have started to laugh. This is…. . However, for those who have never contacted wechat Pay, there will be such doubts. I found that both myself and my friends had similar doubts before we contacted wechat Pay.
When you finish reading this article, you will be on the direct train, do not have to go to the bitter research. Wechat pay is actually very simple, today I will answer your doubts, a simplest wechat pay, for the front end is actually two steps: one is the pre-order interface (back-end), one is the wechat pay API (wechat official).
2. The most important thing for wechat Pay is to understand the payment process:
The logic of wechat payment is that the front end triggers a pre-order interface at the back end. After receiving the request from the front end, the back end adjusts the parameters of the front-end request to the official interface of wechat to place an order, and then the official wechat will return a pre-order ID to the back end. Backend interface through an order after he got the pre order id the pre order id and the front adjustable WeChat pay all parameters of the API to return to the front, the front end with these parameters and the pre order id pay for this API, remove WeChat WeChat pay the components can be adjustable, is the checkout you confuse what to do, in fact, what the company name, amount, Input password is wechat for you to do. As long as you can adjust the cashier, wechat will do the rest for you.
3. Why is wechat Pay designed like this?
WeChat payment why is this logic, is actually WeChat would consider security problems, so the data is the back end to interact with the WeChat, then returns a pre order id, the pre order id is the same and we usually query, he bound the WeChat pay the required amount, payment information such as the company, when tuning WeChat pay API, He will return to data corresponding to the id, and then to apply colours to a drawing on the register, you adjust the interface will trigger, when you can tone up the register is proved successful, on WeChat developer tools, he is a qr code will pop up, then we scan code can pay, when we really machine debugging and line actually, I wouldn’t have a payment of qr code, Will directly adjust the wechat cashier.
Of course, this is just the simplest business logic of wechat payment. In the enterprise, the business process of payment is more complex than this, but it is on the basis of this. When you understand that 1+1=2, 1+2 will be difficult?
4. Wechat official business flow chart:
Key steps:
Step 3 Users place orders and initiate payment. Merchants can place orders and create payment orders through JSAPI.
Step 8 Merchants can activate wechat Payment through JSAPI in wechat browser to initiate payment request.
Step 15 After the user makes a successful payment, the merchant can receive the payment result notification API of wechat Pay.
Step 20 In the case that the merchant does not receive notification of wechat payment result, the merchant needs to actively call the query order API to query the payment result.
Including WeChat payment interface is WeChat official wx requestPayment (Object Object), let’s look at WeChat developers.weixin.qq.com/miniprogram official document…
Tips: the payment API has many parameters, it is necessary to the front to the WeChat, and these parameters are the back-end for you, so you don’t have to worry about, not just to find the back-end, though this part of the parameters of front can also do, but think about security, are generally the back-end to you, here are the main has a parameter is a prepaid id, should pay attention to his transfer to WeChat format.
5. Actual code display of the project:
6 Display of successful payment results:
Well, that’s it for today, and we’ll see you next time!
Previous articles of the author:
Small program Bluetooth unlock, how is the front end directly and hardware data interaction?
What is the lifecycle execution flow for parent and child components?
One day, I found a bug in the Nuggets official.