iaphub / react-native-iaphub

The easiest way to implement IAP (In-app purchase) in your React Native app.
https://www.iaphub.com/
MIT License
319 stars 21 forks source link

Subscriptions are filtered on getProductsForSale() call #95

Closed zkwentz closed 2 years ago

zkwentz commented 2 years ago

Logs:

[Wed Sep 08 2021 12:17:06.554]  ERROR    [Error: E_IAP_NOT_AVAILABLE]
[Wed Sep 08 2021 12:17:06.588]  ERROR    Itunes did not return the product '***.tier1', the product has been filtered, if the sku is valid your Itunes account or sandbox environment is probably not configured properly (https://iaphub.com/docs/set-up-ios/configure-sandbox-testing)
[Wed Sep 08 2021 12:17:06.658]  ERROR    Itunes did not return the product '***.tier2', the product has been filtered, if the sku is valid your Itunes account or sandbox environment is probably not configured properly (https://iaphub.com/docs/set-up-ios/configure-sandbox-testing)
[Wed Sep 08 2021 12:17:06.659]  ERROR    Itunes did not return the product '***.tier3', the product has been filtered, if the sku is valid your Itunes account or sandbox environment is probably not configured properly (https://iaphub.com/docs/set-up-ios/configure-sandbox-testing)

Implementation:

import Iaphub from 'react-native-iaphub';

class Purchase {
  constructor() {
    this._initializeClient();
  }

  _initializeClient = async () => {
    await Iaphub.init({
      appId: '****',
      apiKey: '****',
      environment: 'production',
    });
  }

  getProductsForSale = () => {
    return Iaphub.getProductsForSale();
  }

  setUserId = (uniqueUserId: string) => {
    return Iaphub.setUserId(uniqueUserId);
  }
}

export let purchase = new Purchase();
...
      await purchase.setUserId(user?.attributes.sub);
      const products = await purchase.getProductsForSale();
      console.log(products);
...

Bundle ID, Shared Secret, and Server to Server are set. In addition, I've created these same grouped products with matching SKUs in App Store Connect. They have all required information added including localization (for SKUs and Group), review image, etc and their status is Ready to Submit.

zkwentz commented 2 years ago

Note: These subscriptions are auto-renewable.

zkwentz commented 2 years ago

It seems I missed this critical step:

npm install react-native-iap@5.1.1 --save-exact

Even though it's a dependency of react-native-iaphub and was listed in my package-lock.json, you need it installed so that the pod gets installed in your built app.