5***@qq.com
5***@qq.com
  • 发布:2018-04-24 10:11
  • 更新:2018-04-26 12:12
  • 阅读:2722

mui支付设置要怎么设置呢?本地调试是好的,打包了就支付失败,返回-100

分类:MUI

mui支付设置要怎么设置呢?本地调试是好的,打包了就支付失败,返回-100。还有打包后点微信支付后直接跳到支付宝。是不是打包的包名有关系,我用的是mui提供的支付接口

HTML:

<button class="bottom-fixed-right mui-pull-right" style="border: none;border-radius: 0;" id="pay">  
    付款  
</button>

JS:

var wxChannel = null; // 微信支付  
var aliChannel = null; // 支付宝支付  
var channel = null;  
mui.init();  
    // 1. 获取支付通道  
    mui.plusReady(function() {  
    // 获取支付通道  
          plus.payment.getChannels(function(channels) {  
              aliChannel = channels[0];  
              wxChannel = channels[1];  
          }, function(e) {  
            alert("获取支付通道失败:" + e.message);  
    });  
var ALIPAYSERVER = 'http://demo.dcloud.net.cn/helloh5/payment/alipay.php?total=0.01';  
var WXPAYSERVER = 'http://demo.dcloud.net.cn/payment/wxpayv3.HBuilder/?total=1';  
                // 2. 发起支付请求  
function pay(id) {  
    var PAYSERVER = '';  
    if(id == 'alipay') {  
        PAYSERVER = ALIPAYSERVER;  
        channel = aliChannel;  
    } else if(id == 'wxpay') {  
        PAYSERVER = WXPAYSERVER;  
        channel = wxChannel;  
    } else {  
        plus.nativeUI.alert("不支持此支付通道!", null, "捐赠");  
        return;  
    }  
    var xhr = new XMLHttpRequest();  
    xhr.onreadystatechange = function() {  
        switch(xhr.readyState) {  
            case 4:  
            if(xhr.status == 200) {  
                plus.payment.request(channel, xhr.responseText, function(result) {  
                    plus.nativeUI.alert("支付成功!", function() {  
                        mui.back();  
                    });  
                }, function(error) {  
                    plus.nativeUI.alert("支付失败:" + error.code);  
                });  
            } else {  
                alert("获取订单信息失败!");  
            }  
                break;  
            default:  
                break;  
        }  
    }  
    xhr.open('GET', PAYSERVER);  
    xhr.send();  
}  

    document.getElementById('pay').addEventListener('tap', function() {  
        var radioType = $('input[name=radio1]:checked').val();  
        if(radioType == "zhifubao") {  
            pay("alipay")  
        } else if(radioType == "wechat") {  
            pay("wxpay")  
        } else {  
            mui.alert("请选择付款方式")  
        }  
    })
2018-04-24 10:11 负责人:无 分享
已邀请:
DCloud_UNI_CHB

DCloud_UNI_CHB

打包的话,你需要申请自己的支付参数,客户端和服务端都需要配置成自己的参数,详细参考支付插件配置

另外,支付渠道的获取顺序不是固定的,如下判断肯定不正确

plus.payment.getChannels(function(channels) {  
          aliChannel = channels[0];  
          wxChannel = channels[1];  
      }, function(e) {  
        alert("获取支付通道失败:" + e.message);  
});
  • 5***@qq.com (作者)

    按照你们提供的IOS SDK在xcode上运行的时候,点击支付一直崩溃,进不了支付宝APP,支付宝的scheme和xcode里面支付宝的URL Scheme分别应该设置成什么?

    2018-04-27 08:43

  • 骁骑

    使用的是什么时候下载的SDK?

    2018-04-27 10:53

该问题目前已经被锁定, 无法添加新回复