English
APP payment function in the capability list of the application details page. For details, refer to [Add Application Function](https://opendocs.alipay.com/open/200/105310#%E6%B7%BB%E5 %8A%A0%E5%BA%94%E7%94%A8%E5%8A%9F%E8%83%BD)For more information, please refer to the official Alipay document App Payment Access Preparation

Notice
Before invoking payment on the app side, a payment order needs to be generated on the business server, please refer to:
For more information, please refer to the official Alipay document Server Access Process
alipay, and the orderInfo attribute value is the order objectThe Alipay payment order object is of String type, and the string data format is "application/x-www-form-urlencoded", that is, the form of key=value, which is connected with the & symbol. An example is as follows:
app_id=2015052600090779&biz_content=%7B%22timeout_express%22%3A%2230m%22%2C%22seller_id%22%3A%22%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22total_amount%22%3A%220.02%22%2C%22subject%22%3A%221%22%2C%22body%22%3A%22%E6%88%91%E6%98%AF%E6%B5%8B%E8%AF%95%E6%95%B0%E6%8D%AE%22%2C%22out_trade_no%22%3A%22314VYGIAGG7ZOYY%22%7D&charset=utf-8&method=alipay.trade.app.pay&sign_type=RSA2×tamp=2016-08-15%2012%3A12%3A15&version=1.0&sign=MsbylYkCzlfYLy9PeRwUUIg9nZPeN9SfXPNavUCroGKR5Kqvx0nEnd3eRmKxJuthNUx4ERCXe552EV9PfwexqW%2B1wbKOdYtDIb4%2B7PL3Pc94RZL0zKaWcaY3tSL89%2FuAVUsQuFqEJdhIukuKygrXucvejOUgTCfoUdwTi7z%2BZzQ%3D
For more information, please refer to the official Alipay document APP payment request parameter description
uni.getProvider({
service: 'payment',
success: function (res) {
console.log(res.provider)
if (~res.provider.indexOf('alipay')) {
uni.requestPayment({
"provider": "alipay", //固定值为"alipay"
success: function (res) {
var rawdata = JSON.parse(res.rawdata);
},
fail: function (err) {
}
});
}
}
});
var orderInfo = ''; //从服务器获取的订单
//Get Alipay payment object
plus.payment.getChannels(function(channels){
for (var i in channels) {
var channel = channels[i];
if (channel.id === 'alipay') {
alipaySev = channel;
}
}
//Initiate payment
plus.payment.request(alipaySev, orderInfo, function(result){
var rawdata = JSON.parse(result.rawdata);
}, function(e){
});
}, function(e){
});
注意
支付宝客户端沙箱版进行支付,切换方法参考该 问答评论区