当前位置:网站首页>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',
})
}
})
},
边栏推荐
- 福元医药上交所上市:市值105亿 胡柏藩身价超40亿
- 关于我
- [shutter] dart data type (dynamic data type)
- Timing / counter of 32 and 51 single chip microcomputer
- Sword finger offer 27 Image of binary tree
- VScode知识点——常见报错
- ROS知识点——消息过滤器 ( message_filters)
- 【Leetcode】14. Longest Common Prefix
- 体验居家办公完成项目有感 | 社区征文
- Soul, a social meta universe platform, rushed to Hong Kong stocks: Tencent is a shareholder with an annual revenue of 1.28 billion
猜你喜欢

博客主题 “Text“ 夏日清新特别版

Geoserver: publishing PostGIS data sources

【Leetcode】13. Roman numeral to integer

Microservice architecture practice: Construction of scalable distributed database cluster
![[web technology] 1233 seconds understand web component](/img/42/c98d8112dc4ece0a92dda97647be5c.jpg)
[web technology] 1233 seconds understand web component

Ap和F107数据来源及处理

After meeting a full stack developer from Tencent, I saw what it means to be proficient in MySQL tuning

深度之眼(三)——矩阵的行列式

Believe in yourself and finish the JVM interview this time

【Leetcode】14. Longest Common Prefix
随机推荐
PCL知识点——体素化网格方法对点云进行下采样
The difference of message mechanism between MFC and QT
【Leetcode】13. Roman numeral to integer
Microservice architecture practice: Construction of highly available distributed file system fastdfs architecture
Eth data set download and related problems
一年頂十年
Goodbye, shucang. Alibaba's data Lake construction strategy is really awesome!
绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东
【Leetcode】14. Longest Common Prefix
What is generics- Introduction to generics
VScode知识点——常见报错
剑指 Offer 27. 二叉树的镜像
[leetcode] 14. Préfixe public le plus long
Seven charts, learn to do valuable business analysis
Explanation of traceroute command
【Leetcode】14. 最長公共前綴
Visibilitychange – refresh the page data when the specified tab is visible
牛客JS2 文件扩展名
智能垃圾桶(五)——点亮OLED
GeoServer:发布PostGIS数据源