Skip to main content

Summary: 

App Store in-app purchases not pulling correctly with promotional offer (free trial)

Description:

I am trying to offer users a free trial using RevenueCat and in-app purchases. The line of code throwing the error is:

const selectedPackage = offering.availablePackagess0]; // This is the package object
const product = selectedPackage.product; // Extract the product from the package

let discount: any = null;

if (product.discounts) {
await Purchases.restorePurchases().then((res) => {
console.log('Restore purchases:', res);
});
discount = await Purchases
.getPromotionalOffer(product, product.discountss0])
.catch((error) => {
Alert.alert(
'Error',
'An error occurred while fetching the subscription details. Please try again.'
);
console.log('Error getting discount:', error);
setLoading(false);
return null;
});
}

Specifically, the Purchases.getPromotionalOffer() is throwing the error:
Possible Unhandled Promise Rejection (id: 0): Error: The receipt is not valid.

The debug logs are showing the following:

DEBUG: ℹ️ Skipping products request for these products because they were already cached: h"caregiver"]
DEBUG: ℹ️ Local intro eligibility computed locally. Result: "caregiver": IntroEligibilityStatus.noIntroOfferExists]
DEBUG: ℹ️ Caching trial or intro eligibility for products: o"caregiver"]
VERBOSE: Warming up paywall images cache: mhttps://assets.pawwalls.com/1080318_1714143788.heic]
DEBUG: ℹ️ Skipping products request for these products because they were already cached: "caregiver"]
DEBUG: ℹ️ Loaded receipt from url file:///Users/chrisozgo/Library/Developer/CoreSimulator/Devices/F06530A6-3E89-45A2-8670-E02BFEDD4C48/data/Containers/Data/Application/AB43FE27-9C7B-4902-8B5F-97DAAE53D700/StoreKit/receipt
INFO: ℹ️ Parsing receipt
DEBUG: ℹ️ Vending CustomerInfo from cache.
INFO: ℹ️ Receipt parsed successfully
DEBUG: ℹ️ PostOfferForSigningOperation: Started
DEBUG: ℹ️ There are no requests currently running, starting request POST /v1/offers
VERBOSE: Using etag 'b5783d46c6b42663' for request to 'https://api.revenuecat.com/v1/offers'. Validation time: <null>
DEBUG: ℹ️ API request started: POST '/v1/offers'
ERROR: 😿‼️ The receipt is not valid.
DEBUG: ℹ️ API request failed: POST '/v1/offers' (400): The receipt is not valid.
Request-ID: '806e17d4-8504-4fdc-8398-b21bc32b2e18'; Amzn-Trace-ID: 'Root=1-66cfd287-4ccad90d0d5d8b3b03482a1b'
ERROR: 😿‼️ The receipt is not valid.
DEBUG: ℹ️ PostOfferForSigningOperation: Finished
DEBUG: ℹ️ Serial request done: POST /v1/offers, 0 requests left in the queue

So it has something to do with the "The receipt is not valid" error. The community forum has documentation on this issue, but none of the suggestions has proven helpful. I have checked the configurations with regard to Shared Secrets and p8 files. They seem to be in order.

Any suggestions to help solve the issue would be greatly appreciated!

Hi @flavien-marianacci-538aae and @bbiscoe0218,

Are you using StoreKit 1 or 2? StoreKit 2 should work better for this.


Hi, I would recommend that you create a brand new RevenueCat app user id and Apple Sandbox Tester and try purchasing this again. This will give the user intro eligibility as right now the current one you are testing with does not have any based on the log ‘IntroEligibilityStatus.noIntroOfferExists’. 


It look like we have a similar problem here, but only when the application is download from the store.

The application and revenuecat succeed to get the discounts of our product when the build is download from test flight, but the same thing throw an error when the build is downlaod from iOS.

 

We made an update of an subscribtion offer to add free day for new user.

We are publishing a new version of our app to get some logs on the error. Is there any tips to fix that, it will be good.