Невозможно отобразить данные о продукте покупки приложения в Android

Пока я могу получать информацию о своем продукте для устройства iOS, но не для Android.

Вот мой код в компонентном модуле:

  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/[email protected]/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] DEBUG: состояние: android.prod -> действительно

и когда я перехожу на страницу, вот код:

  setupProducts() {

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

product reg {"id":"android.prod","alias":"android.prod","type":"не расходуемый","group":"","state":"invalid","title" :null,"description":null,"priceMicros":null,"price":null,"currency":null,"countryCode":null,"loaded":true,"canPurchase":false,"принадлежащий":false ,"introPrice":null,"introPriceMicros":null,"introPricePeriod":null,"introPriceNumberOfPeriods":null,"introPricePeriodUnit":null,"introPriceSubscriptionPeriod":null,"introPricePaymentMode":null,"ineligibleForIntroPrice":null," скидки":[],"загрузка":ложь,"загружено":ложь,"дополнительные данные":нуль,"транзакция":нуль,"действительна":ложь}

В поисках решений я прочитал одну вещь: BILLING_KEY... но в консоли Google Play нет billing_key. Я добавил свой продукт в Google Play и загрузил свой .apk в закрытое бета-тестирование.

Мой продукт InApp отображается как «Активен» в консоли Google Play.

ионный -v 6.0.1

кордова -v 9.0.0 (кордова[email protected])

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

Поэтому я не знаю, как зарегистрировать продукт Android, чтобы он был активным, а не неактивным, и получить информацию о продукте.

Любая помощь будет принята с благодарностью.

0
0
750
1
Перейти к ответу Данный вопрос помечен как решенный

Ответы 1

Ответ принят как подходящий

Вы можете найти платежный ключ Android в консоли Google Play (новая), в разделе «Настройка монетизации» > «Лицензирование», начиная с «MIIBxxxxxxxxxxxxx».

Вам также необходимо запустить команду ionic cordova plugin add cc.fovea.cordova.purchase --variable BILLING_KEY="MIIBxxxxxxxxxx (ваш собственный ключ биллинга)" в терминале.

Другие вопросы по теме