当前位置:网站首页>小程序调起微信支付
小程序调起微信支付
2022-07-25 09:24:00 【|刘钊|】
准备条件:
1. 必须完成小程序认证 查看认证相关说明
2.小程序认证以后,可以在小程序后台,微信支付菜单栏,申请微信支付。

前端支付流程:
1.使用 wx.login 获取临时登录凭证code,并将其发送到 后端 获取 openId
wx.login({
success (res) {
if (res.code) {
// 发起请求,换取openId
wx.request({
url: '',
data: {
code: res.code
}
})
}
}
})
2.将 openId以及相应需要的商品信息 发送到后端,换取 后端进行的签名 等信息
wx.request({
url: '',
data: {
openId: '',
num: 1,
id: '111'
}
})3. 小程序端接收后端签名后返回过来的信息(必须要包含发起微信支付 wx.requestPayment 的参数),再调用 wx.requestPayment 发起微信支付
wx.requestPayment({
// 时间戳
timeStamp: '',
// 随机字符串
nonceStr: '',
// 统一下单接口返回的 prepay_id 参数值
package: '',
// 签名类型
signType: '',
// 签名
paySign: '',
// 调用成功回调
success () {},
// 失败回调
fail () {},
// 接口调用结束回调
complete () {}
})注意:以上信息中timeStamp、nonceStr、prepay_id、signType、paySign 各参数均建议必须都由服务端返回(这样会尽最大可能性保证签名数据一致性),小程序端不做任何处理
后端技术支持:
1.根据小程序端通过wx.login获取到的code,返回当前用户openId
2.根据openId及传来的相关商品信息(商品详情:金额、数量等),调用微信官方统一下单接口,返回签名后的相关数据。
边栏推荐
- TensorFlow raw_ RNN - implement the seq2seq mode to take the output of the previous time as the input of the next time
- NLM5系列无线振弦传感采集仪的工作模式及休眠模式下状态
- 【机器翻译】SCONES——用多标签任务做机器翻译
- 无线振弦采集仪应用工程安全监测
- TM1638 LED数码显示模块ARDUINO驱动代码
- CCF 201503-3 Festival
- 工程监测多通道振弦传感器无线采集仪外接数字传感器过程
- Introduction to testbench
- Evolution based on packnet -- review of depth estimation articles of Toyota Research Institute (TRI) (Part 2)
- The economic basis of a hardware siege lion
猜你喜欢

深度估计自监督模型monodepth2论文总结和源码分析【理论部分】

单目深度估计自监督模型Featdepth解读(上)——论文理解和核心源码分析

数字IC设计SOC入门进阶

OC -- packaging class and processing object

Mixed supervision for surface defect detection: from weakly to fully supervised learning

Get to know opencv4.x for the first time --- add Gaussian noise to the image

Solve the Chinese garbled code error of qtcreator compiling with vs

AI模型风险评估 第1部分:动机

T5论文总结

TensorFlow raw_rnn - 实现seq2seq模式中将上一时刻的输出作为下一时刻的输入
随机推荐
CDA LEVELⅠ2021新版模拟题一(附答案)
概率机器人学习笔记第二章
First knowledge of opencv4.x ---- mean filtering
从Anaconda到TensorFlow到Jupyter一路踩坑一路填平
CCF 201509-3 模板生成系统
CCF 201503-4 网络延时
一个硬件攻城狮的经济学基础
Mlx90640 infrared thermal imager temperature measurement module development notes (4)
深度学习 段错误(Segment Core/ Exit code 139)情况记录
ADC introduction
SystemVerilog syntax
FPGA basic advanced
BSP3 电力监控仪(功率监控仪)端子定义和接线
Coredata storage to do list
Terminal definition and wiring of bsp3 power monitor (power monitor)
Creation of adjacency table of undirected connected graph output breadth depth traversal
Temperature, humidity and light intensity acquisition based on smart cloud platform
MLX90640 红外热成像传感器测温模块开发笔记(二)
【机器翻译】SCONES——用多标签任务做机器翻译
Store to-do items locally (improve on to-do items)