当前位置:网站首页>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',
})
}
})
},
边栏推荐
- 2322. Remove the minimum fraction of edges from the tree (XOR and & Simulation)
- uniapp H5页面调用微信支付
- &lt; IV & gt; H264 decode output YUV file
- Eye of depth (II) -- matrix and its basic operations
- Sword finger offer 26 Substructure of tree
- [shutter] dart data type (dynamic data type)
- LeetCode:1380. Lucky number in matrix -- simple
- Smart trash can (V) - light up OLED
- Interpretation of key parameters in MOSFET device manual
- Microservice architecture practice: Construction of scalable distributed database cluster
猜你喜欢
酒仙网IPO被终止:曾拟募资10亿 红杉与东方富海是股东
Baobab's gem IPO was terminated: Tang Guangyu once planned to raise 1.8 billion to control 47% of the equity
Seven charts, learn to do valuable business analysis
si446使用记录(二):使用WDS3生成头文件
体验居家办公完成项目有感 | 社区征文
The poor family once again gave birth to a noble son: Jiangxi poor county got the provincial number one, what did you do right?
Experience home office, feel the completion of the project | community essay solicitation
LeetCode:1380. Lucky number in matrix -- simple
GeoServer:发布PostGIS数据源
Believe in yourself and finish the JVM interview this time
随机推荐
Weili holdings listed on the Hong Kong Stock Exchange: with a market value of HK $500million, it contributed an IPO to Hubei
uniapp H5页面调用微信支付
IPtables中SNAT、DNAT和MASQUERADE的含义
Smart trash can (V) - light up OLED
Ocio V2 reverse LUT
traceroute命令讲解
AP and F107 data sources and processing
云通信接口更新迭代——SUBMAIL API V4正式上线
Seven charts, learn to do valuable business analysis
What is generics- Introduction to generics
Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
一年頂十年
2、 Expansion of mock platform
What if the default browser cannot be set?
简单线性规划问题
The impact of telecommuting on all aspects of our experience | community essay solicitation
IP address translation address segment
Use of openpose
executescalar mysql_ExecuteScalar()
Idea2021.1 installation tutorial