当前位置:网站首页>Applet starts wechat payment
Applet starts wechat payment
2022-07-25 13:37:00 【|Liu Zhao|】
Preparation conditions :
1. You must complete applet certification Check the certification related instructions
2. After applet authentication , Can be in the small program background , Wechat payment menu bar , Apply for wechat payment .

Front end payment process :
1. Use wx.login Get temporary login credentials code, And send it to Back end obtain openId
wx.login({
success (res) {
if (res.code) {
// Initiate request , Exchange for openId
wx.request({
url: '',
data: {
code: res.code
}
})
}
}
})
2. take openId And the corresponding required product information Send to back end , Exchange for Back end signature Etc
wx.request({
url: '',
data: {
openId: '',
num: 1,
id: '111'
}
})3. The information returned by the applet after receiving the back-end signature ( It must include initiating wechat payment wx.requestPayment Parameters of ), Call again wx.requestPayment Initiate wechat payment
wx.requestPayment({
// Time stamp
timeStamp: '',
// Random string
nonceStr: '',
// Unified order interface returns prepay_id Parameter values
package: '',
// Signature type
signType: '',
// Signature
paySign: '',
// Call successful callback
success () {},
// Failed callback
fail () {},
// Interface call end callback
complete () {}
}) Be careful : In the above information timeStamp、nonceStr、prepay_id、signType、paySign It is recommended that all parameters be returned by the server ( This will ensure the consistency of signature data as much as possible ), The applet side does nothing
Back end technical support :
1. According to the applet end through wx.login Acquired code, Return to current user openId
2. according to openId And related product information ( Goods details : amount of money 、 Quantity, etc ), Call wechat official unified order interface , Return the relevant data after signature .
边栏推荐
猜你喜欢

嵌入式代码如何进行重构?

Nodejs link MySQL error: Er_ NOT_ SUPPORTED_ AUTH_ MODEError: ER_ NOT_ SUPPORTED_ AUTH_ MODE

uniapp处理后台传输图片

G027-op-ins-rhel-04 RedHat openstack creates a customized qcow2 format image

How can information security engineers prepare for the soft exam in the second half of 2022?

Uncaught SyntaxError: Octal literals are not allowed in strict mode.

ThreadLocal&Fork/Join

Brpc source code analysis (III) -- the mechanism of requesting other servers and writing data to sockets

0710RHCSA

从输入网址到网页显示
随机推荐
Uniapp handles background transfer pictures
JS Array indexOf includes sort() 冒号排序 快速排序 去重和随机样本 random
What is your revenue rank among global developers in 2022?
hcip第八天笔记
MLIR原理与应用技术杂谈
Numpy快速入门
0716RHCSA
ThreadLocal&Fork/Join
Friends let me see this code
mujoco_py中文文档
面试官问我:Mysql的存储引擎你了解多少?
stable_ Baselines quick start
QGIS loading online map: Gaode, Tiandi map, etc
Leetcode 113. path sum II
The interviewer asked me: how much do you know about MySQL's storage engine?
@wrap 装饰器
hcip第十天笔记
刷题-洛谷-P1075 质因数分解
刷题-洛谷-P1035 级数求和
Uncaught SyntaxError: Octal literals are not allowed in strict mode.