当前位置:网站首页>小程序调起微信支付
小程序调起微信支付
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及传来的相关商品信息(商品详情:金额、数量等),调用微信官方统一下单接口,返回签名后的相关数据。
边栏推荐
- FLASH read / write operation and flash upload file of esp8266
- Introducing MLOps 解读(一)
- Exciting method and voltage of vibrating wire sensor by hand-held vibrating wire acquisition instrument
- Swift creates weather app
- Temperature, humidity and light intensity acquisition based on smart cloud platform
- ARMv8通用定时器简介
- CCF 201512-3 drawing
- 无线中继采集仪的常见问题
- Mlx90640 infrared thermal imager temperature measurement module development notes (V)
- SystemVerilog语法
猜你喜欢

从Anaconda到TensorFlow到Jupyter一路踩坑一路填平

CCF 201509-3 template generation system

@5-1 CCF 2019-12-1 reporting

CDA Level1知识点总结之业务分析报告与数据可视化报表

Fundamentals of C language

Mlx90640 infrared thermal imager temperature measurement module development instructions

CDA LEVELⅠ2021新版模拟题二(附答案)

CCF 201509-3 模板生成系统

C语言基础

Mlx90640 infrared thermal imaging sensor temperature measurement module development notes (III)
随机推荐
Creation of adjacency table of undirected connected graph output breadth depth traversal
CCF 201512-4 送货
Store to-do items locally (improve on to-do items)
CCF 201512-3 画图
First knowledge of opencv4.x --- image histogram equalization
Temperature, humidity and light intensity acquisition based on smart cloud platform
CCF 201604-2 俄罗斯方块
Get to know opencv4.x for the first time --- add Gaussian noise to the image
ARMV8体系结构简介
I2C也可总线取电!
NLM5系列无线振弦传感采集仪的工作模式及休眠模式下状态
【建议收藏】靠着这些学习方法,我入职了世界五百强——互联网时代的“奇技淫巧”
CDA LEVELⅠ2021新版模拟题二(附答案)
TensorFlow raw_rnn - 实现seq2seq模式中将上一时刻的输出作为下一时刻的输入
Linked list -- basic operation
ARMv8通用定时器简介
pytorch使用tensorboard实现可视化总结
【Tensorflow2安装】Tensorflow2.3-CPU安装避坑指南!!!
LOAM 融合 IMU 细节之 TransformToEnd 函数
MLX90640 红外热成像传感器测温模块开发笔记(二)