Solved

Eligibility of introductory offers



Show first post

36 replies

Badge +4

@Jonah I’m sorry I missed your questions!! I’m super late to reply, but: `package.storeProduct.discounts` relates to Promotional Offers, whereas `checkTrialOrIntroDiscountEligibility` relates to Introductory Offers. To get the Introductory Offers, use `package.storeProduct.introductoryDiscount`. 

 

@Petri `checkTrialOrIntroDiscountEligibility` is currently not available in our Android API, although we do have plans to introduce it later this year. 


Is there some other way to to check eligibility if checkTrialOrIntroDiscountEligibility is not available on Android? (we are using the Flutter SDK)

Badge +5

@cody If the user has never purchased anything, will there be a receipt available to parse?

Userlevel 3
Badge +7

HI @atineoSE ,

 

Unfortunately I don’t know of another way to consistently test user eligibility except for creating a new sandbox user each time. That is usually our solution to this issue.   

Badge +4

Shall we use TrialOrIntroPriceEligibilityChecker’s checkEligibility function to check for trial eligibility for iOS 14 +
Edit: Okey found checkTrialOrIntroDiscountEligibility

Badge +4

Is this available in Android SDK? I could not find anything related to `checkTrialOrIntroDiscountEligibility` in the Android API?

Userlevel 5
Badge +8

@Jonah I’m sorry I missed your questions!! I’m super late to reply, but: `package.storeProduct.discounts` relates to Promotional Offers, whereas `checkTrialOrIntroDiscountEligibility` relates to Introductory Offers. To get the Introductory Offers, use `package.storeProduct.introductoryDiscount`. 

 

@Petri `checkTrialOrIntroDiscountEligibility` is currently not available in our Android API, although we do have plans to introduce it later this year. 

Badge +5

@cody

I would also like to know what happens for new users who don’t have any receipt on their device … 

Badge +5

@ian-l 

Many thanks, that helps a lot!

Badge +3

@Jonah I’m sorry I missed your questions!! I’m super late to reply, but: `package.storeProduct.discounts` relates to Promotional Offers, whereas `checkTrialOrIntroDiscountEligibility` relates to Introductory Offers. To get the Introductory Offers, use `package.storeProduct.introductoryDiscount`. 

 

@Petri `checkTrialOrIntroDiscountEligibility` is currently not available in our Android API, although we do have plans to introduce it later this year. 

 

@Andy Are there any updates on this already? I am using Capacitor and just trying to implement Trials but checking if somebody is eligible seems still quite sensitive to errors, especially because Android needs a workaround. Thank you as always for your great work, I highly appreciate it.

Badge +3

@Andy I am so sorry to disturb again but do you have any hint on how to test this (because my pricingPhases is always only having 1 entry which is the subscription itself and I guess it’s because the Play Account had a subscription already and when I use a fresh Google Play account it’s also not shown maybe because there needs to be a payment method attached?).

Alternatively it would help a lot already to know how the answer would look like because mine is only looking like this:

Thank you so much, I really appreciate it and if it helps and I know that it works I am happy to post my code here for the both platforms check so that others might benefit from it as well. Testing trial is a lot harder than expected though… ;-)

Manuel

Badge +3

I think I finally found a working solution which is checking for trial eligibility. Since I am not sure how exactly iOS handles this, I am testing for all returned introEligibilityStatuses and a user is eligible for me if he/she is eligible for all products while excluding the products that might not have a trial which is why I am testing for INELIGIBLE and UNKNOWN and not the other way around.

For Android it seems that an entirely fresh Play Account is needed. Important to know is that you could have been subscribed quite a few times to the app with the current RevenueCat ID and only the Play Account matters to be eligible. If you care about that you would need to check for that as well if a user has been subscribed in the past.

The following code is using TypeScript and Capacitor but the approach might be similar for other tech stacks.

/**
* Checks if the user is eligible to see a trial or intro discount. Will return true if the user is eligble but none of the current offerings have a trial or intro discount.
*/
async isEligibleForTrial(): Promise<boolean> {
const offering = (await this.getOfferings()).current,
productIdentifiers = [];

if (offering.availablePackages === null) {
return false;
}

for (const availablePackage of offering.availablePackages) {
productIdentifiers.push(availablePackage.product.identifier);
}

if (this.platform.is('ios')) {
// Purchases.checkTrialOrIntroductoryPriceEligibility is only available for iOS
const introEligibilityStatuses = await Purchases.checkTrialOrIntroductoryPriceEligibility({
productIdentifiers: productIdentifiers
});

// a user is only eligible if he is eligible for all products (prevents a user from using a monthly trial after an annual trial ran out)
let isNotEligibleCount = 0;
for (const id of productIdentifiers) {
isNotEligibleCount +=
introEligibilityStatuses[id].status === INTRO_ELIGIBILITY_STATUS.INTRO_ELIGIBILITY_STATUS_INELIGIBLE ||
introEligibilityStatuses[id].status === INTRO_ELIGIBILITY_STATUS.INTRO_ELIGIBILITY_STATUS_UNKNOWN
? 1
: 0;
}
return isNotEligibleCount === 0;
} else if (this.platform.is('android')) {
// a user on Android is eligible if one of the subscription options has a freePhase entry (it's always null if the user isn't eligible)
for (const availablePackage of offering.availablePackages) {
for (const subscriptionOption of availablePackage.product.subscriptionOptions) {
if (subscriptionOption.freePhase !== null && subscriptionOption.freePhase.price.amountMicros === 0) {
return true;
}
}
}
}

// for now we only check the status for iOS and Android, anything else is false by default
return false;
}

 

Reply