当前位置:网站首页>小程序调起微信支付
小程序调起微信支付
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及传来的相关商品信息(商品详情:金额、数量等),调用微信官方统一下单接口,返回签名后的相关数据。
边栏推荐
- I2C也可总线取电!
- CDA LEVELⅠ2021新版模拟题一(附答案)
- Arm preliminaries
- Mlx90640 infrared thermal imager temperature measurement module development notes (4)
- CDA Level1知识点总结之业务分析报告与数据可视化报表
- SD/SDIO/EMMC
- FPGA基础进阶
- Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (II)
- ISP图像信号处理
- MLX90640 红外热成像传感器测温模块开发笔记(二)
猜你喜欢

¥ 1-2 example 2.2 put the union of two sets into the linear table

【成长必备】我为什么推荐你写博客?愿你多年以后成为你想成为的样子。

VS无线振弦采集仪蓝牙功能的使用

Introduction to armv8 general timer

ADC introduction

pytorch使用tensorboard实现可视化总结

无线振弦采集仪参数配置工具的设置

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

Swift creates weather app

Store to-do items locally (improve on to-do items)
随机推荐
阿里MQTT物联网平台“云产品流转”实战——两片ESP32通过物联网平台实现远程互操作
Store to-do items locally (improve on to-do items)
[deployment of deep learning model] deploy the deep learning model using tensorflow serving + tornado
CCF 201512-4 delivery
TM1638 LED数码显示模块ARDUINO驱动代码
无线振弦采集仪应用工程安全监测
Development history of convolutional neural network (part)
Terminal definition and wiring of bsp3 power monitor (power monitor)
CCF 201512-4 送货
Swift simple implementation of to-do list
ISP image signal processing
深度学习 段错误(Segment Core/ Exit code 139)情况记录
单目深度估计基础理论和论文学习总结
File -- first acquaintance
ADC introduction
Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (III)
App lifecycle and appledelegate, scenedelegate
ISP图像信号处理
数据分析业务核心
一个可以返回前一页并自动刷新页面的ASP代码.