uni-app苹果内购⽀付及获取苹果⽀付成功信息先在头部定义商品id 全部商品id (在苹果商店申请的真实商品id)
let iapChannel = null;
var productId = 'lvbi_a';
var productIds = ['lvbi_a'];
进⼊页⾯就判断
//1.获取⽀付渠道
Channels((channels) => {
for (var i in channels) {
var channel = channels[i];
//苹果⽀付
if (channel.id === 'appleiap') {
iapChannel = channel;
}
}
if (!iapChannel) {
}
}, (error) => {
});
requestOrder() {
(orderList) => { //必须调⽤此⽅法才能进⾏ iap ⽀付
uni.hideLoading();
}, (e) => {
uni.hideLoading();
});
},
调接⼝获取真实的商品id
// 获取页⾯内容
getAppleProducts() {
AppleProducts({
openid:this.openid,
token:this.tpken
}).then(res =>{
de == 1){
this.data = res.data;
this.price = this.data.products[0];
productId =
this.data.products[0].product_id;
productIds =
this.data.products_ids;
}
})
},
确定⽀付
topupprice() {
let that = this;
uni.showLoading({});
provider: 'appleiap',
orderInfo: {
productid: productId
},
flutter uniapp 哪个好success: (e) => {
uni.hideLoading();
var  statement = {
productid: productId
}
// ⽀付成功查询订单
quest(iapChannel, statement, function(res){
paysuccers({
data:{
openid:that.openid,
ken,
receipt_data:JSON.stringify(res)
}
}).then(tow =>{
uni.hideLoading();
de == 1){
uni.showToast({
title:tow.msg,
icon:'none'
})
}else{
uni.showToast({
title:tow.msg,
icon:'none'
})
}
})
}, function(){
});
},
fail: (e) => {
uni.hideLoading();
uni.showModal({
content: "⽀付失败,原因为: " + e.errMsg,                            showCancel: false
})
}
})
},