Solved

Any way to test trials before going live (React Native)?

  • 8 June 2023
  • 4 replies
  • 177 views

Badge +5

I’m adding iOS Introductory Offers, and I would like to test before going live. However, when following the guide in the docs, the `discounts` field on the product is an empty array. How do I test this introductory offer before going live?

 

Example of the code I’m using for reference:

const purchaseDiscountedIOSPackage = async (purchasePackage) => {
const product = purchasePackage.product;
const discount = product.discounts?.[0];
// product.discounts is empty
if (!discount) {
throw new Error('No discount found on producct');
}
const paymentDiscount = await Purchases.getPromotionalOffer(product, discount);
if (!paymentDiscount) {
throw new Error('No payment discount');
}

try {
const purchaseMade = await Purchases.purchaseDiscountedPackage(pkg, paymentDiscount);
return purchaseMade.customerInfo;
} catch (e) {
if (!e.userCancelled) {
throw e;
} else {
throw new Error('ignore');
}
}
};

const purchase = async () => {
const offering = (await Purchases.getOfferings()).current;
const package = offering.availablePackages[0];
if (package) {
await purchaseDiscountedIOSPackage(package);
}
};

 

icon

Best answer by kaitlin 12 June 2023, 18:46

View original

4 replies

Badge +5

Follow up question: is the code in the docs (https://www.revenuecat.com/docs/ios-subscription-offers#promotional-offers) only valid for Promotional Offers and not Introductory offers? It would be great to get Intro Offers documentation added.

After testing, it seems like Intro Offers are automatically applied by RevenueCat using Purchases.purchasePackage

Userlevel 4
Badge +6

Hi @Cameron!

The discounts field will actually not include Introductory offers - this will be returned in the IntroPrice field instead. Additionally, you’re correct that the code in the docs and that you’re using in your snippet is for Promotional Offers specifically. 

For Introductory Offers, as you said, you can trust that they will be automatically applied if the user is eligible for it. You can always check the offer in the IntroPrice field, and with iOS you can also use checkTrialOrIntroductoryPriceEligibility to check if a user is eligible. 

Badge +5

Hi @kaitlin , amazing thank you for the information!!! 😄

Would I be able to use the IntroPrice value on Android as well to identify whether or not an Android subscription has an introductory price? If so, would I have to use any different code to select that intro offer for the user?

Userlevel 4
Badge +6

Hi @Cameron Napoli,

Yes, introPrice is available for Android! You wouldn’t need to do anything to select the offer - the stores will handle verifying users who are eligible and showing them the offer. 

Reply