MUI微信和支付宝支付

参考:https://www.cnblogs.com/H5App/articles/7279373.html

plus API使用步骤:
1. 调用plus.payment.getChannels()获取系统支持的支付通道;
2. 调用plus.payment.request()发起支付请求。

示例代码:

 1 var channel=null;
 2 // 1. 获取支付通道
 3 function plusReady(){
 4     // 获取支付通道
 5     plus.payment.getChannels(function(channels){
 6         channel=channels[0];
 7     },function(e){
 8         alert("获取支付通道失败:"+e.message);
 9     });
10 }
11 document.addEventListener('plusready',plusReady,false);
12  
13 var ALIPAYSERVER='http://demo.dcloud.net.cn/helloh5/payment/alipay.php?total=';//支付宝支付接口
14 var WXPAYSERVER='http://demo.dcloud.net.cn/helloh5/payment/wxpay.php?total='; //微信支付接口
15 // 2. 发起支付请求  在用户输完金额和选完支付方式后可以执行此函数
16 function pay(id){
17     // 从服务器请求支付订单
18     var PAYSERVER='';
19     if(id=='alipay'){
20         PAYSERVER=ALIPAYSERVER;
21     }else if(id=='wxpay'){
22         PAYSERVER=WXPAYSERVER;
23     }else{
24         plus.nativeUI.alert("不支持此支付通道!",null,"捐赠");
25         return;
26     }
27     var xhr=new XMLHttpRequest();
28     xhr.onreadystatechange=function(){
29         switch(xhr.readyState){
30             case 4:
31             if(xhr.status==200){
32                 plus.payment.request(channel,xhr.responseText,function(result){
33                     plus.nativeUI.alert("支付成功!",function(){
34                         back();
35                     });
36                 },function(error){
37                     plus.nativeUI.alert("支付失败:" + error.code);
38                 });
39             }else{
40                 alert("获取订单信息失败!");
41             }
42             break;
43             default:
44             break;
45         }
46     }
47     xhr.open('GET',PAYSERVER);
48     xhr.send();
49 }
原文地址:https://www.cnblogs.com/susutong/p/9869054.html