**DEMO代码如下. 之前一直是可以的. 突然不行了.
2个回调函数根本不进.
- 能成功取得IAP渠道
- 能取到内购项目
- 到支付那环节就完全进入不了回调函数. 没任何报错.
成功解决将支付小红包一枚. 谢谢**
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<title>Hello H5+</title>
<script type="text/javascript">
var iapChannel;
var IAPOrders = ['QB18', 'QB68', 'QB100'];
function plusReady() {
// 获取支付通道
plus.payment.getChannels(function (channels) {
for (var i in channels) {
if (channels[i].id == 'appleiap') {
iapChannel = channels[i];
iapChannel.requestOrder(IAPOrders, function (event) {
for (var index in event) {
var OrderItem = event[index];
console.log("Title:" + OrderItem.title + "Price:" + OrderItem.price +"Description:" + OrderItem.description + "ProductID:" +
OrderItem.productid);
}
//======
console.log("开始支付");
plus.payment.request(iapChannel, {
"productid": 'QB100',
"username": "appusername",
"quantity": "2"
}, function(result) {
alert(JSON.stringify(result));
}, function(e) {
plus.nativeUI.alert("更多错误信息请参考支付(Payment)规范文档:http://www.html5plus.org/#specification#/specification/Payment.html", null, "支付失败:" + e.code);
});
console.log("结束支付");
//======
}, function (errormsg) {
console.log("获取支付通道失败:" + errormsg.message);
});
}
}
}, function (e) {
console.log("获取支付通道失败:" + e.message);
});
}
document.addEventListener('plusready', plusReady, false);
function getPayedTrances() {
iapChannel.restoreComplateRequest({
"username": "waipptt"
}, function (trancs) {
console.log("获取已经购买项目成功:" + JSON.stringify(trancs));
}, function (errormsg) {
console.log("获取支付通道失败:" + errormsg.message);
});
}
</script>
</head>
</html>
3 个回复
[已删除]
联系我吧
千灯
你好,请问你的问题解决了吗,怎么解决的
1***@qq.com
问题解决了吗?