当前位置:网站首页>uniapp 微信小程序 点击按钮调用微信支付
uniapp 微信小程序 点击按钮调用微信支付
2022-04-21 10:25:00 【公孙元二】
实现效果:
点击按钮后唤起支付方式选择:
在这里我选择“微信支付”

输完成密码后完成支付:

需求:
计算金额和创建支付订单等操作都在后端完成,前端只要将后端传过来的签名、时间戳、随机字符串等参数传给微信的api,即可在小程序唤起支付弹窗。
代码:
// 调用微信支付
callPayMent(data){
wx.requestPayment({
//调起支付
'timeStamp': data.timeStamp,
'nonceStr': data.nonceStr,
'package': data.packageData,
"signType": "RSA",
'paySign': data.paySign,
'success': function (res) {
// 接口调用成功的回调函数
console.log('支付成功:',res);
//TODO 跳转订单
// wx.navigateTo({
// url: '/pages/myOrder/myOrder?type=1&list=2',
// })
},
'fail': function (res) {
// 接口调用失败的回调函数
console.log('支付失败:' + JSON.stringify(res));
}
})
},
微信支付官方文档:https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_5_4.shtml#menu1
版权声明
本文为[公孙元二]所创,转载请带上原文链接,感谢
https://blog.csdn.net/Amnesiac666/article/details/124314760
边栏推荐
猜你喜欢
随机推荐
Ant a-table tree table cascade selection
Cilcate环境搭建
UVM和SystemVerilog中的返回值使用方法
每日一题(2022-04-19)——字符的最短距离
openCV——模板匹配
L1-052 2018我们要赢 (5 分)
shell脚本修改文件名和权限
A tool that is easier to use and more powerful than Navicat!
SQL:树形三层职业分类表的SQL文件
JS初练——弹弹球与墙壁碰撞处理实例
JS - complete Gobang layout in 70 lines
我再测试下定时的
zsh: segmentation fault 解决方法
MKL与VS2019配置方法
Transaction isolation level and mvcc
L1-045 宇宙无敌大招呼 (5 分)
Pytorch学习笔记(2)一元线性回归、计算图示例
About incorrect deletion of operations in notes
Talk about the safety factor of futures online account opening
信号与系统2022春季学期:作业内容与参考答案









