获取到channel[{"id":"appleiap","description":"In-App Purchase","serviceReady":true}]
requestOrder failed: {"code":-100,"message":"Payment_appleiap:返回订单信息失败
<template>
<view>
<view class="uni-list">
<radio-group @change="applePriceChange">
<label class="uni-list-cell uni-list-cell-pd" v-for="(item, index) in priceList" :key="index">
{{item.text}}
<radio :value="item.value" :checked="item.checked" />
</label>
</radio-group>
</view>
<view class="uni-padding-wrap">
<button class="ipaPayBtn" @click="requestPayment" :loading="loading" :disabled="disabled">确认支付</button>
</view>
</view>
</view>
</template>
<script>
let iapChannel = null,
productId = 'opiclibraryApp01',
productIds = ['opiclibraryApp01'];
export default {
data() {
return {
title: 'request-payment',
loading: false,
disabled: true,
priceList: [{
value: 'opiclibraryApp01',
text: '支付1元',
checked: true
}, {
value: 'opiclibraryApp01',
text: '支付6元',
checked: false
}]
}
},
onLoad: function() {
plus.payment.getChannels((channels) => {
console.log("获取到channel" + JSON.stringify(channels))
for (var i in channels) {
var channel = channels[i];
if (channel.id === 'appleiap') {
iapChannel = channel;
this.requestOrder();
}
}
if(!iapChannel){
this.errorMsg()
}
}, (error) => {
this.errorMsg()
});
},
methods: {
requestOrder() {
uni.showLoading({
title:'检测支付环境...'
})
iapChannel.requestOrder(productIds, (orderList) => { //必须调用此方法才能进行 iap 支付
this.disabled = false;
console.log('requestOrder success666: ' + JSON.stringify(orderList));
uni.hideLoading();
}, (e) => {
console.log('requestOrder failed: ' + JSON.stringify(e));
uni.hideLoading();
this.errorMsg()
});
},
requestPayment(e) {
this.loading = true;
uni.requestPayment({
provider: 'appleiap',
orderInfo: {
productid: productId
},
success: (e) => {
uni.showModal({
content: "感谢您的赞助",
showCancel: false
})
},
fail: (e) => {
uni.showModal({
content: "支付失败,原因为: " + e.errMsg,
showCancel: false
})
},
complete: () => {
console.log("payment结束")
this.loading = false;
}
})
},
applePriceChange(e) {
productId = e.detail.value;
},
errorMsg(){
uni.showModal({
content: "暂不支持苹果 iap 支付",
showCancel: false
})
}
}
}
</script>
<style>
</style>
AnsonLu
请问1所谓的关联上是什么意思?我在对应的app下面管理已经添加了内购项目。2税务协议我也已经弄好了,但是还是跟你一样获取不到订单信息
2021-07-09 11:09
卢融霜_ (作者)
回复 AnsonLu: iapChannel.requestOrder(
[productId],
orderList => {
//必须调用此方法才能进行 iap 支付
this.disabled = false;
that.priceList = orderList;
uni.hideLoading();
},
e => {
uni.hideLoading();
this.errorMsg();
}
);
productId,保证你APP,内购里有这个 productId 商品标识
2021-07-12 09:17
AnsonLu
回复 卢融霜_: 你好,我在app内购买项目里面已经创建了两个商品,且状态都是准备提交,然后通过你的方法调用requestOrder,总是回进入失败的函数,且提示获取支付通道失败,code:-10, message:Payment_appleiap:返回订单信息失败
2021-07-12 11:53
AnsonLu
回复 卢融霜_: 税务协议状态是有效(等待用户信息),我就填了技术的那一栏,其他的联系信息就没填
2021-07-12 14:35
卢融霜_ (作者)
回复 AnsonLu: 加我微信吧:13718382321
2021-07-12 16:03
卢融霜_ (作者)
回复 卢融霜_: 记得使用,自定义调试基座,签名里面添加测试机器,测试机器进行调用
2021-07-12 16:06