当前位置:网站首页>Uniapp H5 page calls wechat payment
Uniapp H5 page calls wechat payment
2022-07-02 17:24:00 【Jiuwujiuwu】
/* payment */
<!--
1. Click the payment button to trigger payOrder
2.postJSON Is the encapsulated request method , Parameters subData It is based on the backend
3.api It is the back-end payment interface that returns the corresponding things of the order
4. Trigger wechat payment api
-->
// Pay now
payOrder(order_id,order_money){
let that=this;
let subData={
user_id:uni.getStorageSync('userInfo').user_id, // user id
payment_mode:2, // Payment type ,
money:order_money, // Pay the amount
pay_type:1, // Order payment
order_id:order_id // Order id
}
postJSON(api,subData,res=>{
if(res.data.status==1){
console.log(' Get payment parameters :'+res.data.data.timeStamp)
console.log(' Get payment parameters :'+res.data.data.nonceStr)
console.log(' Get payment parameters :'+res.data.data.package)
console.log(' Get payment parameters :'+res.data.data.paySign)
that.payApi(res.data.data.timeStamp,
res.data.data.nonceStr,
res.data.data.package,
res.data.data.paySign)
}else{
that.$toast(res.data.message,'none');
}
});
},
// payment
payApi(timeStamp,nonceStr,packages,paySign){
let that=this;
uni.requestPayment({
'timeStamp':timeStamp, // Backstage return
'nonceStr': nonceStr,// Backstage return , Random string , The length is 32 Less than characters .
'package': packages,// Backstage return , Unified order interface returns prepay_id Parameter values
'signType': 'MD5', // Signature type
'paySign': paySign,// Backstage return , Signature
"success":function(res){
// Operation after successful payment , Pop up prompt or jump to the success page
uni.redirectTo({
url: 'url',
})
},
"fail":function(err){
// Payment failed operation , Pop up prompt or jump to the success page
uni.showToast({
title: ' Failure to pay ',
icon: 'none'
})
uni.redirectTo({
url: 'url',
})
}
})
},
边栏推荐
- Seven charts, learn to do valuable business analysis
- Leetcode question brushing record | 933_ Recent requests
- A few lines of code to complete RPC service registration and discovery
- The beginning of life
- 剑指 Offer 24. 反转链表
- Method of C language self defining function
- 牛客JS2 文件扩展名
- Interpretation of key parameters in MOSFET device manual
- Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
- 畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权
猜你喜欢

酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东

871. Minimum refueling times

The construction of scalable distributed database cluster and the partition design of oneproxy sub database

Eth data set download and related problems

畅玩集团冲刺港股:年营收2.89亿 刘辉有53.46%投票权

Qwebengineview crash and alternatives

Sword finger offer 24 Reverse linked list

超卓航科上市:募资9亿市值超60亿 成襄阳首家科创板企业

QStyle实现自绘界面项目实战(二)

几行代码搞定RPC服务注册和发现
随机推荐
What is generics- Introduction to generics
Shutter: action feedback
Configure lamp+supervisor
Nexus Introduction and Xiaobai use idea Packaging and Upload to Nexus 3 private service detailed tutoriel
ETH数据集下载及相关问题
【Leetcode】14. Longest Common Prefix
Error when uploading code to remote warehouse: remote origin already exists
智能垃圾桶(五)——点亮OLED
LSF basic command
【Leetcode】14. 最长公共前缀
JS20 数组扁平化
Usage of sprintf() function in C language
VScode知识点——常见报错
uniapp H5页面调用微信支付
福元医药上交所上市:市值105亿 胡柏藩身价超40亿
Changwan group rushed to Hong Kong stocks: the annual revenue was 289million, and Liu Hui had 53.46% voting rights
深度之眼(二)——矩阵及其基本运算
2020 "Lenovo Cup" National College programming online Invitational Competition and the third Shanghai University of technology programming competition (a sign in, B sign in, C sign in, D thinking +mst
伟立控股港交所上市:市值5亿港元 为湖北贡献一个IPO
Win10 system uses pip to install juypter notebook process record (installed on a disk other than the system disk)