轻应用开发 API

app. wxPay

微信支付

Methods

static register(appId, success, fail)

将该app注册到微信

Parameters:
Name Type Description
appId String

微信支付商户的APPID

success function

成功回调函数

fail function

失败回调函数,返回错误信息

Example
app.wxPay.register('wx70e80fed5356ae88', function(res){
            app.alert(res)
        }, function(err){
            app.alert(err)
        }); 

static startPay(params, success, fail)

调起微信支付

Parameters:
Name Type Description
params Object

微信支付参数
字段有appId,partnerId,prepayId,packageValue,nonceStr,timeStamp,sign
详情请查看微信官方文档:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=4_3

success function

成功回调函数

fail function

失败回调函数,返回错误信息

Example
var obj = {
            appId: "wxf42b1fc0dd6bcc3a",
            partnerId: "1495054112",
            prepayId: "wx171702472605294941a5b4891282591800",
            packageValue: "Sign=WXPay",
            nonceStr: "934af1cb4eec45c1aafb96680e170e65",
            timeStamp: "1581930166",
            sign: "0628171B74DBDBE577093C607EB559EB"
        }
        app.wxPay.startPay(obj, function(res){
            app.alert(res);
        }, function(err){
            app.alert(err);
        })