Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/google-chrome/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google chrome 应用内购买在chrome扩展中不起作用_Google Chrome_Google Chrome Extension_In App Purchase - Fatal编程技术网

Google chrome 应用内购买在chrome扩展中不起作用

Google chrome 应用内购买在chrome扩展中不起作用,google-chrome,google-chrome-extension,in-app-purchase,Google Chrome,Google Chrome Extension,In App Purchase,应用内购买屏幕将返回: 错误是: 发生意外错误。请稍后再试。解雇 正如你所看到的,它的一半也是黑色的 Buy.js: /*GOOGLE's CODE ... */ /*CODE FOR IN-APP PURCHASES*/ var prodButPrefix = "btnProdID-"; var statusDiv; function init() { console.log("App Init"); statusDiv = $("#status"); //

应用内购买屏幕将返回:

错误是:

发生意外错误。请稍后再试。解雇

正如你所看到的,它的一半也是黑色的

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);
}
/*谷歌的代码
...
*/
/*应用内购买代码*/
var prodButPrefix=“btnProdID-”;
var statusDiv;
函数init(){
console.log(“appinit”);
statusDiv=$(“#status”);
//getProductList();
}
$(“#div1”)。单击(函数(){
支票购买(“包装2016”);
});
/*****************************************************************************
*从Chrome网络商店获取已购买产品的列表
*****************************************************************************/
购买的var=假;
函数getLicenses(){
log(“google.payments.inapp.getPurchases”);
console.log(“采购产品检索列表…”);
google.payments.inapp.getPurchases({
'参数':{env:“prod”},
“成功”:仅限LicenseUpdate,
“失败”:仅限LicenseUpdateFiled
});
}
功能检查(sku_init){
getLicenses();
函数getLicenses(){
log(“google.payments.inapp.getPurchases”);
console.log(“采购产品检索列表…”);
google.payments.inapp.getPurchases({
'参数':{env:“prod”},
“成功”:仅限LicenseUpdate,
“失败”:仅限LicenseUpdateFiled
});
}
仅限函数LicenseUpdate(响应){
日志(“onLicenseUpdate”,响应);
var licenses=response.response.details;
var count=licenses.length;
对于(变量i=0;i
这是控制台中正在打印的内容:

google.payments.inapp.buy package2016

当我关闭应用内支付屏幕时,会打印:

onPurchaseFailed对象{请求:对象,响应:对象} 购买失败。已取消购买


您可能必须确保不更改/更新buy.js中提供的扩展id(nmmhkkegcagldgiimedpiccmgmieda)


另外,请将onPurchaseFailed对象字符串化并共享,以便我可以帮助确认问题。

我向Chrome开发支持人员发送了电子邮件,他们说:

在Chrome网络商店中,您不允许购买自己的 应用程序/扩展。为了测试您的项目,您需要访问它 来自不同的帐户。(不是从您的开发者帐户)


请仔细检查您是否正确地遵循了本文提供的步骤。@KENdi您认为我在“创建和管理您的虚拟商品”部分犯了错误吗?我的代码看起来还好吗?@I-你能帮我吗?