这是控制器,它正确获取商品详细信息价格,但是当我购买任何商品时,它会给出错误(您要求的商品不可购买)
var productIds = ['com.ionicframework.****7.productone','com.ionicframework.***7.producttwo']; //
var spinner = '
';
$scope.loadProducts = function () {
$ionicLoading.show({ template: spinner + 'Loading Products...' });
在应用程序内购买
.getProducts(productIds)
.then(函数(产品){
$ionicLoading.hide();
$scope.products = 产品;
})
.catch(函数(错误){
$ionicLoading.hide();
控制台日志(错误);
});
};
$scope.buy = function (productId) {
$ionicLoading.show({ template: spinner + 'Purchasing...' });
inAppPurchase
.buy(productId)
.then(function (data) {
console.log(JSON.stringify(data));
console.log('consuming transactionId: ' + data.transactionId);
return inAppPurchase.consume(data.type, data.receipt, data.signature);
})
.then(function () {
var alertPopup = $ionicPopup.alert({
title: 'Purchase was successful!',
template: 'Check your console log for the transaction data'
});
alert('consume done!');
$ionicLoading.hide();
})
.catch(function (err) {
$ionicLoading.hide();
[enter image description here][1]
$ionicPopup.alert({
title: 'Something went wrong',
template: JSON.stringify(err)
});
});
};
$scope.restore = 函数 () {
$ionicLoading.show({ template: spinner + '恢复购买...' });
在应用程序内购买
。恢复购买()
.then(函数(购买){
$ionicLoading.hide();
$ionicPopup.alert({
title: 'Restore was successful!',
template: 'Check your console log for the restored purchases data'
});
})
.catch(function (err) {
$ionicLoading.hide();
$ionicPopup.alert({
title: 'Something went wrong',
template: JSON.stringify(err)
});
});
};