1. 登录支付宝开发者中心,创建应用,开通App支付功能,配置密钥 详见[支付宝官方文档](https://opendocs.alipay.com/open/204/105297/) 2. 在manifest.json文件“App模块配置”项的“Payment(支付)”下,勾选“支付宝支付”项 ![](https://partner-dcloud-native.oss-cn-hangzhou.aliyuncs.com/images/uniapp/payment/alipay_setup_manifest_info.png) 3. 通过服务器生成支付订单,参考: [生成支付订单示例(PHP)](https://github.com/dcloudio/H5P.Server/tree/master/payment/alipayrsa2) [老版本"移动快捷支付"示例代码(PHP)](https://github.com/dcloudio/H5P.Server/tree/master/payment/alipay) [生成支付订单示例(C#)](http://ask.dcloud.net.cn/article/197) 4. 应用中调用支付功能 * uni-app项目示例 ``` js uni.getProvider({ service: 'payment', success: function (res) { console.log(res.provider) if (~res.provider.indexOf('alipay')) { uni.requestPayment({ "provider": "alipay", "orderInfo": orderInfo, //此处为服务器返回的订单信息字符串 success: function (res) { var rawdata = JSON.parse(res.rawdata); console.log("支付成功"); }, fail: function (err) { console.log('支付失败:' + JSON.stringify(err)); } }) } } }); ``` * 5+项目示例 ``` js //获取支付渠道 var alipaySev = null; plus.payment.getChannels(function(channels) { for (var i in channels) { var channel = channels[i]; if (channel.id === 'alipay') { alipaySev = channel; } } }, function(e) { console.log("获取支付渠道失败:" + e.message); }); //发起支付 var statement = orderInfo; //此处为服务器返回的订单信息字符串 plus.payment.request(alipaySev, statement, function(result) { var rawdata = JSON.parse(result.rawdata); console.log("支付成功"); }, function(e) { console.log("支付失败:" + e.message); }); ```