无法在Android中的应用购买商品数据中显示 [英] Unable to display in app purchase product data in android

查看:73
本文介绍了无法在Android中的应用购买商品数据中显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,我可以接收有关iOS设备而不是Android设备的产品信息.

So far I'm able to receive my product information for an iOS device but not Android.

这是我在组件模块中的代码:

Here is my code in the component module:

  registerProduct() {
    this.inAppPurchase.verbosity = this.inAppPurchase.DEBUG;
    this.inAppPurchase.register({
      id: 'android.prod',
      type: this.inAppPurchase.NON_CONSUMABLE
    });
    this.registerHandlersForPurchase('android.prod');
    this.inAppPurchase.refresh();
  }

  registerHandlersForPurchase(productId) {
    const self = this.inAppPurchase;
    this.inAppPurchase.when(productId).updated((product) => {
      if (product.loaded && product.valid && product.state === self.APPROVED && product.transaction != null) {
        product.finish();
      }
    });
    this.inAppPurchase.when(productId).registered((product: IAPProduct) => {
      // alert(` owned ${product.owned}`);
    });
    this.inAppPurchase.when(productId).owned((product: IAPProduct) => {
      // alert(` owned ${product.owned}`);
      product.finish();
    });
    this.inAppPurchase.when(productId).approved((product: IAPProduct) => {
      // alert('approved');
      product.finish();
    });
    this.inAppPurchase.when(productId).refunded((product: IAPProduct) => {
      // alert('refunded');
    });
    this.inAppPurchase.when(productId).expired((product: IAPProduct) => {
      // alert('expired');
    });
  }

这是控制台日志

[store.js] DEBUG: state: android.prod -> registered
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: store.trigger -> triggering action refreshed
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2781 InAppBilling[js]: setup ok
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2781 InAppBilling[js]: load ["android.prod"]
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2781 InAppBilling[js]: listener: {"type":"ready","data":{}}
/pages-profile-profile-module-es2015.js:178 this.currentUser Ice Berg
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: plugin -> ready
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2781 InAppBilling[js]: getAvailableProducts()
unpkg.com/ionicons@4.5.10-0/dist/ionicons/svg/ios-chevron-forward.svg:1 Failed to load resource: the server responded with a status of 404 ()
/pages-profile-profile-module-es2015.js:210 ionViewDidEnter
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: plugin -> loaded - []
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: state: android.prod -> invalid
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: iabGetPurchases()
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2781 InAppBilling[js]: getPurchases()
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2781 InAppBilling[js]: listener: {"type":"setPurchases","data":{"purchases":[]}}
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: iabSetPurchases: []
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: inappbilling.getPurchases() -> Success
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG:                             -> object
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG:                             -> []
/plugins/cc.fovea.cordova.purchase/www/store-android.js:2012 [store.js] DEBUG: iabUpdatePurchases: []

iOS中的区别在于这是有效的:[store.js]调试:状态:android.prod->有效

The difference in iOS is that this is valid: [store.js] DEBUG: state: android.prod -> valid

当我浏览页面时,代码是:

and when I naviage to the page here is the code:

  setupProducts() {

    this.androidProduct = this.inAppPurchase.get('android.prod');
    console.log('product reg', JSON.stringify(this.androidProduct));
  }

product reg {"id":"android.prod","alias":"android.prod","type":"non consumable","group":",状态":无效",标题":null,描述":null,"priceMicros":null,"price":null,"currency":null,"countryCode":null,已加载":true,"canPurchase":false,拥有":false,"introPrice":null,"introPriceMicros":null,"introPricePeriod":null,"introPriceNumberOfPeriods"null,"introPricePeriodUnit":null,"introPriceSubscriptionPeriod":null,"introPricePaymentMode":null,"ineligibleForIntroPrice":null,打折":[],下载":falsefalse,"additionalData":null,"transaction":null,"valid":false}

product reg {"id":"android.prod","alias":"android.prod","type":"non consumable","group":"","state":"invalid","title":null,"description":null,"priceMicros":null,"price":null,"currency":null,"countryCode":null,"loaded":true,"canPurchase":false,"owned":false,"introPrice":null,"introPriceMicros":null,"introPricePeriod":null,"introPriceNumberOfPeriods":null,"introPricePeriodUnit":null,"introPriceSubscriptionPeriod":null,"introPricePaymentMode":null,"ineligibleForIntroPrice":null,"discounts":[],"downloading":false,"downloaded":false,"additionalData":null,"transaction":null,"valid":false}

在寻找解决方案时,我读到的一件事是BILLING_KEY ...,但Google Play控制台中没有billing_key.我已将产品添加到Google Play,并将.apk上传到了封闭测试Beta跟踪.

One thing I've read in the searching for solutions is a BILLING_KEY...but there's no billing_key in the Google Play Console. I've added my product to Google Play and I've uploaded my .apk into the Closed Testing Beta Track.

我的InApp产品在Google Play控制台中显示为有效.

My InApp product shows Active in Google Play Console.

离子-v6.0.1

科尔多瓦-v9.0.0(cordova-lib@9.0.1)

cordova -v 9.0.0 (cordova-lib@9.0.1)

"cc.fovea.cordova.purchase":"^ 10.1.1",

"cc.fovea.cordova.purchase": "^10.1.1",

所以我不确定如何注册Android产品,以使其处于活动状态而不是非活动状态,并检索产品信息.

So I'm not sure how to register the Android product so that it's active instead of inactive and retrieve the product information.

任何帮助将不胜感激.

推荐答案

您可以在Google Play控制台(新)中的获利设置">下找到Android计费密钥.许可以"MIIBxxxxxxxxxxxxxx"开头.

You can find the Android Billing Key in Google Play Console (new), under Monetization Setup > Licensing, starting with "MIIBxxxxxxxxxxxxxx".

您还需要运行命令ionic cordova插件add cc.fovea.cordova.purchase --variable BILLING_KEY ="MIIBxxxxxxxxxx(您自己的帐单密钥)"在终端中.

You also need to run the command ionic cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="MIIBxxxxxxxxxx (your own billing key)" in terminal.

这篇关于无法在Android中的应用购买商品数据中显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆