应用程序内购买屏幕正在返回:
错误是:
发生了意外错误。请稍后再试。驳回
正如你所看到的,其中一半也是黑色。
Buy.js:
/*GOOGLE's CODE
...
*/
/*CODE FOR IN-APP PURCHASES*/
var prodButPrefix = "btnProdID-";
var statusDiv;
function init() {
console.log("App Init");
statusDiv = $("#status");
// getProductList();
}
$("#div1").click(function() {
checkIfBought("package2016");
});
/*****************************************************************************
* Get the list of purchased products from the Chrome Web Store
*****************************************************************************/
var purchased = false;
function getLicenses() {
console.log("google.payments.inapp.getPurchases");
console.log("Retreiving list of purchased products...");
google.payments.inapp.getPurchases({
'parameters': {env: "prod"},
'success': onLicenseUpdate,
'failure': onLicenseUpdateFailed
});
}
function checkIfBought(sku_init){
getLicenses();
function getLicenses() {
console.log("google.payments.inapp.getPurchases");
console.log("Retreiving list of purchased products...");
google.payments.inapp.getPurchases({
'parameters': {env: "prod"},
'success': onLicenseUpdate,
'failure': onLicenseUpdateFailed
});
}
function onLicenseUpdate(response) {
console.log("onLicenseUpdate", response);
var licenses = response.response.details;
var count = licenses.length;
for (var i = 0; i < count; i++) {
var license = licenses[i];
if(sku_init == licenses[i].response.details.sku){ //if purchased
purchased = true;
}
addLicenseDataToProduct(license);
}
console.log("");
}
function onLicenseUpdateFailed(response) {
console.log("onLicenseUpdateFailed", response);
console.log("Error retreiving list of purchased products.");
}
if(purchased == false){
buyProduct("package2016");
}
}
/*****************************************************************************
* Purchase an item
*****************************************************************************/
function buyProduct(sku) {
console.log("google.payments.inapp.buy", sku);
//var sku = "";
google.payments.inapp.buy({
'parameters': {'env': 'prod'},
'sku': sku,
'success': onPurchase,
'failure': onPurchaseFailed
});
}
function onPurchase(purchase) {
console.log("onPurchase", purchase);
var jwt = purchase.jwt;
var cartId = purchase.request.cardId;
var orderId = purchase.response.orderId;
console.log("Purchase completed. Order ID: " + orderId);
getLicenses();
}
function onPurchaseFailed(purchase) {
console.log("onPurchaseFailed", purchase);
var reason = purchase.response.errorType;
console.log("Purchase failed. " + reason);
}
这是在控制台中打印的内容:
google.payments.inapp.buy package2016
当我关闭应用内付款屏幕时,会打印出来:
onPurchaseFailed Object {request:Object,response:Object} 购买失败。 PURCHASE_CANCELED
答案 0 :(得分:4)
我通过电子邮件向Chrome Dev支持,他们说:
在Chrome网上应用店中,您不能购买自己的 应用程序/扩展。要测试您的项目,您需要访问它 来自不同的帐户。 (不是来自您的开发者帐户)。
答案 1 :(得分:0)
您可能必须确保不更改/更新他们提供的buy.js中的extension-id(nmmhkkegccagdldgiimedpiccmgmieda)。
另外,请将onPurchaseFailed对象字符串化并分享,以便我帮助确认问题。