当前位置:网站首页>Wechat applet access wechat payment process
Wechat applet access wechat payment process
2022-07-25 03:36:00 【Snow falling Xiaoxuan Han】
One 、 Basic introduction
1、 Payment scenario : Click the payment button to invoke the wechat payment pop-up , Complete the payment after entering the correct password .
2、 The basic flow : Click the pay button to generate an order first , Then call wechat on the back end api Interface to place unified orders , Send the data returned by the interface back to the front end to pull up the payment operation , Then asynchronously notify the payment result .
Two 、 Configuration information
1、 Wechat public platform configuration
Click on the function – Wechat payment , Connect with the registered wechat merchant platform 
1、 Wechat merchant platform configuration
(1) Set up certificates and keys
Log in to wechat merchant platform , Click on the account center – API Security , Set the certificate and two keys ( Here, the two keys are set to the same .
(2) apply JSAPI payment
① Click on Product Center – My product , Click Apply JSAPI payment .
② Fill in the payment authorization directory
The payment authorization directory needs to be filled in the development configuration ( Backend server domain name )
3、 ... and 、 coded
1、 Get the user's openId
There must be wechat users openid To wake up the payment function .openid Provided by wechat official account , It is the only user ID generated by wechat for consumers .
Access method :https://blog.csdn.net/m0_46613429/article/details/125868514
2、 obtain prepay_id And payment signature verification paySign
Merchants first call the interface in the applet to generate a pre payment transaction order in the background of wechat payment service , Return the correct prepaid transaction and raise the payment .
(1) Call the interface to generate an advance payment order and get the order id
orderInsert(data).then(res => {
if (res.data.code === 1) {
this.getPayInfo(res.data.data.id)
} else {
wx.showToast({
title: res.data.msg,
icon: 'none'
})
}
})
(2) By order id Call the interface to get the parameters required for user payment
getPayInfo(id) {
unifiedOrder({
id}).then(res => {
if(res.data.code === 1) {
this.payMoney(res.data.data)
} else {
wx.showToast({
title: res.data.msg,
icon: "error"
})
}
}
}
(3) adopt wx.requestPayment Method calls the start payment function 
payMoney(moneyData) {
wx.requestPayment({
timeStamp: moneyData.timeStamp,
nonceStr: moneyData.nonceStr,
package: moneyData.packageValue,
signType: moneyData.signType,
paySign: moneyData.paySign,
success(res) {
},
fail(res) {
wx.showToast({
title: " Failure to pay !",
icon: "error"
})
}
})
}
Four 、 Process summary
(1) Applet get wechat openId And the order number is sent to the backstage
(2) Backstage basis openId Sign with the order number post Wechat unified single interface
(3) Get the information returned by wechat in the background xml The string parses the secondary signature and returns it to the front end
(4) Front end micro channel payment API
边栏推荐
- Moveit2 - 8. Motion planning API
- Many local and municipal supervision departments carried out cold drink sampling inspection, and Zhong Xue's high-quality products were all qualified
- Day 9 (capture traffic and routing strategy)
- Idea configuration
- Take a note: Oracle conditional statement
- Acwing 870. approximate number
- Calculation method of confusion matrix
- Skywalking distributed link tracking, related graphics, DLJD, cat
- Experience sharing of system architecture designers in preparing for the exam: how to prepare for the exam effectively
- Unified return data format
猜你喜欢

300. Longest increasing subsequence

What is technical support| Daily anecdotes

Chrome process architecture

Flowlayout in compose

mysql_ Record the executed SQL

Image processing based on hog feature

Swagger key configuration items
![[file upload] parse text files and store them in batches through JDBC connection (dynamic table creation and dynamic storage)](/img/9c/0305f7256ab6037d586c8940b9dc76.png)
[file upload] parse text files and store them in batches through JDBC connection (dynamic table creation and dynamic storage)

Pytorch deep learning practice lesson 8 importing data

Li Kou 343 integer partition dynamic programming
随机推荐
Introduction to Apache Doris grafana monitoring indicators
基于SSH婴幼儿产品销售系统
Network security - comprehensive penetration test -cve-2018-10933-libssh maintain access
Codewars notes
Li Kou 343 integer partition dynamic programming
Imeta | ggclusternet microbial network analysis and visualization nanny level tutorial
JS common interview questions
Moveit2 - 7. Scenario planning ROS API
Experience sharing of system architecture designers in preparing for the exam: how to prepare for the exam effectively
MIM command
How is the virtual DOM different from the actual DOM?
Time complexity and space complexity
[file upload] parse text files and store them in batches through JDBC connection (dynamic table creation and dynamic storage)
mysql_ Master slave synchronization_ Show slave status details
Unity: text input box for numerical judgment
What is technical support| Daily anecdotes
C language introduction practice (9): completion judgment
Take a note: Oracle conditional statement
VMware installation
Deep learning method of building a model from zero