Subscription Error - "The item you were attempting to purchase could not be found"
Description
I am encountering an issue when attempting to request a subscription using the react-native-iap library in my Expo React Native app. The subscription request fails with the error message: "The item you were attempting to purchase could not be found."
Steps to Reproduce
- Initialize the in-app purchase connection and fetch the subscription details.
- Attempt to request a subscription using the fetched product details and subscription offers.
Code Snippet
import * as RNIap from 'react-native-iap';
import { useEffect, useState } from 'react';
import { Button, View, Text } from 'react-native';
const App = () => {
const [products, setProducts] = useState([]);
const initIAP = async () => {
try {
const result = await RNIap.initConnection();
console.log('IAP connection result:', result);
await RNIap.flushFailedPurchasesCachedAsPendingAndroid();
const request = { skus: ['dorm_deal_1'] };
const fetchedProducts = await RNIap.getSubscriptions(request);
setProducts(fetchedProducts);
console.log('Fetched products:', fetchedProducts);
} catch (err) {
console.log('IAP initialization error:', err, err.message);
}
};
useEffect(() => {
initIAP();
return () => {
RNIap.endConnection();
};
}, [useIsFocused()]);
const subscribe = async () => {
try {
if (products.length > 0) {
const product = products.find(p => p.productId === 'dorm_deal_1');
if (product && product.subscriptionOfferDetails) {
const subscriptionOffers = product.subscriptionOfferDetails.map(offer => ({
sku: product.productId,
offerToken: offer.offerToken,
}));
console.log('Requesting subscription for product ID: dorm_deal_1 with offers:', subscriptionOffers);
const request = {
sku: 'dorm_deal_1',
subscriptionOffers,
};
const result = await RNIap.requestSubscription(request);
console.log(result, "result");
if (result && typeof result === 'object') {
console.log('Subscription result:', result);
} else {
console.warn('Invalid subscription result:', result);
}
} else {
console.warn('No subscription offers available for product ID: dorm_deal_1');
}
} else {
console.warn('No products available for subscription');
}
} catch (err) {
console.warn('Subscription error:', err, JSON.stringify(err.message));
}
};
return (
<View>
<Button title="Subscribe" onPress={subscribe} />
{products.length > 0 && <Text>Product is valid: {JSON.stringify(products)}</Text>}
</View>
);
};
export default App;
Logs
LOG Requesting subscription for product ID: dorm_deal_1 with offers: [{"offerToken": "AarRn8pLX3OymDFBdywYOYrVglI4B3/kk4F0yjO1ZTE182iAPFwJxemReMaihMBw6a/et8df5bdJeL7gl2H28ba5ig==", "sku": "dorm_deal_1"}]
WARN Subscription error: [Error: The item you were attempting to purchase could not be found] "The item you were attempting to purchase could not be found"
Additional Context
- The product ID
dorm_deal_1is correctly set up in the Google Play Console and is active. - The subscription offers are fetched and logged correctly before making the subscription request.
- The error occurs when calling
requestSubscriptionwith the fetched subscription offers.
Expected Behavior
The subscription request should succeed, and the user should be able to subscribe to the product dorm_deal_1.
Actual Behavior
The subscription request fails with the error message: "The item you were attempting to purchase could not be found."
Environment
- react-native-iap version: ^12.15.4
- React Native version: 0.74.5
- Expo version: ~51.0.34
- Platform: Android
Steps Taken
- Verified the product ID and subscription offers in the Google Play Console.
- Ensured the product is active and available for purchase.
- Used test accounts for testing the subscription.
Any help or guidance on resolving this issue would be greatly appreciated. Thank you!
Do you find any solution? I encountered a common problem because when I submitted my Google store, the screenshot of the auditor showed this error. I don't know if it was normal.
I’m closing all issues reported in versions below 14, as the library now supports the new architecture with NitroModules and has been completely revamped.