Question

You're currently subscribed to this.

  • 22 November 2023
  • 2 replies
  • 47 views

Badge +6

We just released our app.  1 user reported this issue where they subscribed, but then see this error message:

 

I don’t know why this happens.  Here is my flow inside Expo/React Native app:

 

  1. Wrap app in providers
    <PurchaseProvider setPurchasesChecked={setPurchasesChecked}>
    <AuthProvider>
    <Stack/>
    </AuthProvider>
    </PurchaseProvider>

     

  2. Inside the PurchaseProvider getCustomerInfo:

    useEffect(
    function initPurchaseConfig() {
    const initialize = async () => {
    try {
    Purchases.setLogLevel(Purchases.LOG_LEVEL.VERBOSE);
    await Purchases.configure({ apiKey: APIKEY });

    const info = await Purchases.getCustomerInfo();
    const { isActive } = info?.entitlements.active[entitlementName] || {};

    setIsActive(!!isActive);
    } catch (e) {
    setMessage(['error', (e as Error).message]);
    } finally {
    setIsReady(true);
    setPurchasesChecked(true);
    }
    };

    initialize();
    },
    [setMessage, setPurchasesChecked]
    );

    Note the isActive variable, which gets exported from Provider so that routes can be determined

  3. We check if they are paywall eligible, and determine the route:
    if (paywallEligible) {
    if (isActive) {
    if (!hasUser) {
    return router.replace('signIn');
    }
    if (
    lastSegment === 'signIn' ||
    lastSegment === 'register' ||
    lastSegment === 'paywall'
    ) {
    return router.replace('(tabs)');
    }

    if (hasUser) {
    return;
    }

    return;
    }

    return router.replace('paywall');
    }
    if (!hasUser) {
    return router.replace('signIn');
    }
    if (lastSegment === 'signIn') {
    return router.replace('(tabs)');
    }

    In this case, if not isActive, they will get redirect to paywall, which lets them purchase.  

  4. After they purchase we also set isActive to true

    const purchase = async (purchasePackage: PurchasesPackage) => {
    try {
    await Purchases.purchasePackage(purchasePackage);
    getInfo();
    setIsActive(true);
    return router.replace('');
    } catch (e) {
    if (
    (e as PurchasesError).code ===
    Purchases.PURCHASES_ERROR_CODE.PURCHASE_CANCELLED_ERROR
    ) {
    return;
    }

    setMessage(['error', (e as Error).message]);
    }
    };
  5. When I exit the app & come back, I see the “You're currently subscribed to this.” message.

it’s hard to replicate.  What could this be?


2 replies

Userlevel 4
Badge +6

Hi @lucksp,

Is the user who reached out to you with this error a brand new user from the production release, or were they previously a tester for you? I’m curious if you’ve been able to reproduce this issue using an entirely new sandbox user, with no previous history on your app. 

My recommendation here would be to open a ticket with us using the form at this link so that you can share app user ids and debug logs with us. You can enable debug logs by following this guide.

Badge +6

Yes, brand new user from prod release.  

 

I was able to replicate randomly 1 time (as seen in screenshot above).  I am hoping it was a glitch in the matrix, but I will go and open a ticket.


Does my code look correct?

Reply