当前位置:网站首页>Mui wechat payment pit
Mui wechat payment pit
2022-04-23 13:05:00 【It's never too late to be alone】
var that = this;
var wxChannel = null; // Wechat payment
var aliChannel = null; // Alipay pay
var channel = null; // Payment channel
mui.init()
mui.plusReady(function() {
plus.navigator.setStatusBarStyle('light');
});
// Click to pay
mui('.hotel_footer').on('tap', '.footer_right_true', function() {
if(that.name != null && that.idcard != null) {
// Call hide / Show pop-up layers
mui("#popover").popover('toggle', document.getElementById("div"));
} else {
alert(' Please complete your information ')
}
})
// Click wallet to pay
mui('.mui-table-view').on('tap', '#kzf_money', function() {
// Balance payment
const client = '/BalancePay' // Balance payment
var that = this
api.AjaxReponse(client, {
'access_token': localStorage.getItem('access_token'),
'order_number': localStorage.getItem('order_number')
}, function(data) {
if(data.code == 0) {
localStorage.setItem('order_uuid', data.data)
alert(' Successful payment !')
mui.openWindow({
url: './payment_details.html',
})
} else {
alert(data.msg)
}
})
})
mui.plusReady(function() {
// Access to payment channels
plus.payment.getChannels(function(channels) {
for(var i in channels) {
if(channels[i].id == "wxpay") {
wxChannel = channels[i];
// console.log(JSON.stringify(wxChannel))
} else {
aliChannel = channels[i];
}
}
}, function(e) {
alert(" Failed to get payment channel :" + e.message);
});
})
// Click wechat payment
mui('.mui-table-view').on('tap', '.my_recommend', function() {
pay('wxpay');
})
// Click Alipay payment
mui('.mui-table-view').on('tap', '.integral', function() {
pay('alipay');
})
var pame = 'access_token=' + localStorage.getItem('access_token') + '&order_number=' + localStorage.getItem('order_number')
var ALIPAYSERVER = 'http://demo.dcloud.net.cn/helloh5/payment/alipay.php?total=';
// var WXPAYSERVER = 'http://demo.dcloud.net.cn/payment/?payid=wxpay&appid=HBuilder&total=1';
// 2. Request for payment
function pay(id) {
// Request payment orders from the server
var PAYSERVER = '';
if(id == 'alipay') {
PAYSERVER = ALIPAYSERVER;
channel = aliChannel;
} else if(id == 'wxpay') {
PAYSERVER = WXPAYSERVER;
channel = wxChannel;
} else {
plus.nativeUI.alert(" This payment channel is not supported !", null, " Hotel payment ");
return;
}
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
switch(xhr.readyState) {
case 4:
if(xhr.status == 200) {
// alert(JSON.stringify(JSON.parse(xhr.responseText).data))
// alert(JSON.stringify(xhr.responseText.data))
// console.log(JSON.stringify(xhr.responseText))
var xhrdata = JSON.parse(xhr.responseText).data
// var paydata = {}
//
// paydata.appid = xhrdata.appid;
// paydata.nonce_str = xhrdata.nonce_str;
// paydata["package"] = "Sign=WXPay";
// paydata.partnerid = xhrdata.mch_id;
// paydata.prepayid = xhrdata.prepay_id;
// paydata.sign = xhrdata.sign;
// paydata.timestamp = Date.parse(new Date());
let paydata = { // The payment parameters returned in the background should be all lowercase ( Reminders seen in the Forum )
"appid": xhrdata.appid,
"noncestr": xhrdata.nonce_str,
"package": "Sign=WXPay",// Fix
"partnerid": xhrdata.mch_id,
"prepayid": xhrdata.prepay_id,
"timestamp": xhrdata.timestamp,
"sign": xhrdata.sign
};
// alert(JSON.stringify(xhr.responseText))
plus.payment.request(channel, paydata, function(result) {
plus.nativeUI.alert(" Successful payment !", function() {
back();
});
}, function(error) {
console.log(JSON.stringify(error))
plus.nativeUI.alert(" Failure to pay :" + error.code);
});
} else {
alert(" Failed to get order information !");
}
break;
default:
break;
}
}
xhr.open('POST', PAYSERVER);
xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
xhr.send(pame);
}
notes :mui Wechat payment actually goes app payment , Is not web payment …
版权声明
本文为[It's never too late to be alone]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204231303466163.html
边栏推荐
- 基于uniapp异步封装接口请求简介
- AUTOSAR from introduction to mastery 100 lectures (52) - diagnosis and communication management function unit
- Jupiter notebook installation
- Learning materials
- Free and open source intelligent charging pile SaaS cloud platform of Internet of things
- Hanlp word splitter (via spark)
- Embrace the new blue ocean of machine vision and hope to open a new "Ji" encounter for the development of digital economy
- 数据库中的日期时间类型
- (personal) sorting out system vulnerabilities after recent project development
- CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
猜你喜欢
CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer
Record the problems encountered in using v-print
STM32 is connected to the motor drive, the DuPont line supplies power, and then the back burning problem
Customize the shortcut options in El date picker, and dynamically set the disabled date
Servlet监听器&过滤器介绍
The accuracy and speed are perfectly balanced, and the latest image segmentation SOTA model is released!!!
Custom nail robot alarm
Free and open source intelligent charging pile SaaS cloud platform of Internet of things
JMeter operation redis
CVPR 2022 & ntire 2022 | the first transformer for hyperspectral image reconstruction
随机推荐
教你快速开发一个 狼人杀微信小程序(附源码)
[untitled] make a 0-99 counter, P1 7 connected to key, P2 connected to nixie tube section, common anode nixie tube, P3 0,P3. 1. Connect the nixie tube bit code. Each time you press the key, the nixie
CVPR 2022&NTIRE 2022|首个用于高光谱图像重建的 Transformer
Customize classloader and implement hot deployment - use loadclass
Async void provoque l'écrasement du programme
Subscribe to Alibaba demo send business messages
Record some NPM related problems (messy records)
1130 - host XXX is not allowed to connect to this MySQL server error in Navicat remote connection database
5 free audio material websites, recommended collection
Important knowledge of transport layer (interview, retest, final)
进程虚拟地址空间区域划分
Install nngraph
Process virtual address space partition
World Book Day: I'd like to recommend these books
mysql8安装
There is no need to crack the markdown editing tool typora
基于uniapp异步封装接口请求简介
Kernel error: no rule to make target 'Debian / canonical certs pem‘, needed by ‘certs/x509_ certificate_ list‘
three. JS text ambiguity problem
7_Addmodule和基因加和法add 得到的细胞类型打分在空间上空转对比