当前位置:网站首页>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',
})
}
})
},
边栏推荐
- Chmod command principle and usage details [easy to understand]
- 【Leetcode】14. Longest Common Prefix
- Blog theme "text" summer fresh Special Edition
- Sword finger offer 27 Image of binary tree
- 2022 interview questions
- Believe in yourself and finish the JVM interview this time
- JS delete substring in string
- 剑指 Offer 26. 树的子结构
- Nexus简介及小白使用IDEA打包上传到Nexus3私服详细教程
- ETH数据集下载及相关问题
猜你喜欢

Green bamboo biological sprint Hong Kong stocks: loss of more than 500million during the year, tiger medicine and Beijing Yizhuang are shareholders

绿竹生物冲刺港股:年期内亏损超5亿 泰格医药与北京亦庄是股东

剑指 Offer 26. 树的子结构

对接保时捷及3PL EDI案例

How to transfer business data with BorgWarner through EDI?

ETH数据集下载及相关问题

【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

Qstype implementation of self drawing interface project practice (II)

如何与博格华纳BorgWarner通过EDI传输业务数据?
随机推荐
Sword finger offer 27 Image of binary tree
ETH数据集下载及相关问题
Method of C language self defining function
Use of openpose
Eye of depth (III) -- determinant of matrix
Sword finger offer 26 Substructure of tree
Believe in yourself and finish the JVM interview this time
Ocio V2 reverse LUT
Sword finger offer 24 Reverse linked list
Ap和F107数据来源及处理
使用知行之桥的API端口,提供资源供合作伙伴访问
求简单微分方程
牛客 JS3 分隔符
Exploration of mobile application performance tools
2022 interview questions
海思Hi3798MV100机顶盒芯片介绍[通俗易懂]
Sword finger offer 21 Adjust the array order so that odd numbers precede even numbers
默认浏览器设置不了怎么办?
Eye of depth (II) -- matrix and its basic operations
ThreadLocal