Skip to main content
Question

Problem with multiple subscriptions plan to same user


Forum|alt.badge.img+1

Hi guys,
We are building an app that user can have several groups that each group have a subscription plan (free, bronze, silver, gold).
 

IOS

Subscription Groups

  • Family 1
    • fw1-google-plan1890
    • fw1-google-plan2890
    • fw1-google-plan3890
  • Family 2
    • fw2-google-plan1890
    • fw2-google-plan2890
    • fw2-google-plan3890


Android
Subscription: Plan Bronze
Plans:

  • fw1-google-plan1890
  • fw2-google-plan1890
  • fw3-google-plan1890
  • fw1-google-plan1890
     

 

Subscription: Plan Gold
Plans:

  • fw1-google-plan2890
  • fw2-google-plan2890
  • fw3-google-plan2890
  • fw4-google-plan2890


Related to IOS, this is working well, but in Play Store, we are getting this error when subscribing to the play store: PG-GEMF-01
 



 

This post has been closed for comments

2 replies

wes_clark
RevenueCat Staff
Forum|alt.badge.img+6
  • RevenueCat Staff
  • 235 replies
  • April 4, 2024

Hi! Could you share the code snippet where your Android app has the logic to purchase the first instance of the bronze plan versus the second, so that I can take a look on my end?


Forum|alt.badge.img+1
  • Author
  • New Member
  • 1 reply
  • April 4, 2024

This already works on IOS, so we believe that it is not a logic problem, we only have this error with Google Play.

 const init = async () => {
      try {
        Purchases.setAttributes({ groupUuid, userUuid: String(user?.uuid) });
        Purchases.setLogLevel(LOG_LEVEL.DEBUG);
        if (Platform.OS === 'ios') {
          Purchases.configure({
            apiKey: APIKeys.apple,
            appUserID: `${user?.uuid}-${groupUuid}`,
          });
        } else {
          Purchases.configure({
            apiKey: APIKeys.google,
            appUserID: `${user?.uuid}-${groupUuid}`,
          });
        }
        setIsReady(true);

        await loadOfferings();
      } catch (e) {
        console.error(e);
      }
    };
  async function loadOfferings() {
    const offerings = await Purchases.getOfferings();
    setOferrings(offerings);
  }



This section is used to check whether the user already has a subscription or not, if so, they get all the packages from that current offering, otherwise (if the group is free), they get the packages from the first available offering

  const currentPackages = useMemo(() => {
    const oferingId = subscription?.subscription_plan?.revenue_cat_offering_id;

    if (!oferrings) return [];

    if (oferingId) {
      const currentOferring = oferrings.all?.[oferingId];
      return currentOferring.availablePackages;
    } else {
      const oferindIdAvailable = avaiablePlans[0];
      const currentOferring = oferrings.all[oferindIdAvailable];
      return currentOferring.availablePackages;
    }
  }, [oferrings, subscription, avaiablePlans]);



the variable oferrings is like:

{
    "all": {
        "family1": {
            "annual": [Object],
            "availablePackages": [Array],
            "identifier": "family1",
            "lifetime": null,
            "metadata": [Object
            ],
            "monthly": null,
            "serverDescription": "grupo 1",
            "sixMonth": null,
            "threeMonth": null,
            "twoMonth": null,
            "weekly": null
        },
        "family2": {...



the variable avaiablePlans is like avaiable oferrings: [“family1”, “family2”,”family3”, “family4”,”family5”]

if the user subscribes to a package in the offering family1, The current offering is removed from the availablePlans list


 


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings