本文介绍了应用内购买不适用于Chrome扩展程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应用内购买屏幕正在返回:



错误是:

正如您所看到的,其中一半也是黑色的。



Buy.js:

  / * GOOGLE的代码
...
* /



/ *应用内购买代码* /


var prodButPrefix =btnProdID-;
var statusDiv;

函数init(){
console.log(App Init);
statusDiv = $(#status);
// getProductList();


$ b $(#div1)。click(function(){
checkIfBought(package2016);
});


/ ************************************* ****************************************
*获取购买清单Chrome网上应用店的产品
**************************************** ************************************* /
var purchased = false;
函数getLicenses(){
console.log(google.payments.inapp.getPurchases);
console.log(购买产品的退货列表...);
google.payments.inapp.getPurchases({$ b $'参数':{env:prod},
'成功':onLicenseUpdate,
'失败':onLicenseUpdateFailed
});
}

函数checkIfBought(sku_init){
getLicenses();
函数getLicenses(){
console.log(google.payments.inapp.getPurchases);
console.log(购买产品的退货列表...);
google.payments.inapp.getPurchases({$ b $'参数':{env:prod},
'成功':onLicenseUpdate,
'失败':onLicenseUpdateFailed
});
}

函数onLicenseUpdate(响应){
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){//如果购买
购买= true;
}
addLicenseDataToProduct(license);
}
console.log();
}

函数onLicenseUpdateFailed(响应){
console.log(onLicenseUpdateFailed,response);
console.log(购买产品的错误检索清单);
}

if(purchased == false){
buyProduct(package2016);
}
}



/ *********************** ************************************************** ****
*购买一件商品
********************************** ******************************************* /


函数buyProduct(sku){
console.log(google.payments.inapp.buy,sku);
// var sku =;
google.payments.inapp.buy({
'参数':{'env':'prod'},
'sku':sku,
'成功':onPurchase ,
'失败':onPurchaseFailed
});
}


功能on购物(购买){
console.log(onPurchase,购买);
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);

$ / code>

这是在控制台中打印的内容:

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


解决方案

我通过电子邮件发送Chrome Dev支持,他们表示: b


The In-App purchases screen is returning:

Screenshot of In-App screen

The error is:

And as you can see, half of it is also black.

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);
}

This is what is being printed in the console:

When I close the In-App payment screen this is printed:

解决方案

I emailed Chrome Dev support, they said:

这篇关于应用内购买不适用于Chrome扩展程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 22:06