<form @submit="applePay" >
<view class="btn-index-apple">
<button formType="submit">Apple支付</button>
</view>
</form>
<script>
var iapChannel;
var IAPOrders = ['5078739907929812'];
export default {
data() {
return {
}
},
onLoad() {
// 获取支付通道
plus.payment.getChannels((channels) => {
for(var i in channels){
var channel=channels[i];
console.log(JSON.stringify(channel))
if(channel.id==='appleiap'){
iapChannel=channel;
iapChannel.requestOrder(IAPOrders, function(event) {
console.log(JSON.stringify(event))
for (var index in event) {
var OrderItem = event[index];
var title='Title:' + OrderItem.title + 'Price:' + OrderItem.price + 'ProductID:' + OrderItem.productid
console.log(title);
}
}, function(errormsg) {
console.log("获取支付通道失败:" + errormsg.message);
});
}
}
},function(e){
console.log("获取支付通道失败:"+e.message);
});
},
methods: {
/**
* 苹果支付
*/
applePay(){
var orderInfo = { productid: “5078739907929812” };
plus.payment.request(iapChannel, orderInfo, function(e){
//这里的e包括了验证数据,可以发送到服务器端进行验证
console.log(JSON.stringify(e));
}, function(){
console.log("支付失败")
});
}
}
}
</script>
梦亦
兄弟 解决了吗?
2019-11-25 14:47