You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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*asRNIapfrom'react-native-iap';import{useEffect,useState}from'react';import{Button,View,Text}from'react-native';constApp=()=>{const[products,setProducts]=useState([]);constinitIAP=async()=>{try{constresult=awaitRNIap.initConnection();console.log('IAP connection result:',result);awaitRNIap.flushFailedPurchasesCachedAsPendingAndroid();constrequest={skus: ['dorm_deal_1']};constfetchedProducts=awaitRNIap.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()]);constsubscribe=async()=>{try{if(products.length>0){constproduct=products.find(p=>p.productId==='dorm_deal_1');if(product&&product.subscriptionOfferDetails){constsubscriptionOffers=product.subscriptionOfferDetails.map(offer=>({sku: product.productId,offerToken: offer.offerToken,}));console.log('Requesting subscription for product ID: dorm_deal_1 with offers:',subscriptionOffers);constrequest={sku: 'dorm_deal_1',
subscriptionOffers,};constresult=awaitRNIap.requestSubscription(request);console.log(result,"result");if(result&&typeofresult==='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><Buttontitle="Subscribe"onPress={subscribe}/>{products.length>0&&<Text>Product is valid: {JSON.stringify(products)}</Text>}</View>);};exportdefaultApp;
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_1 is 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 requestSubscription with 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!
The text was updated successfully, but these errors were encountered:
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
Code Snippet
Logs
Additional Context
dorm_deal_1
is correctly set up in the Google Play Console and is active.requestSubscription
with 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
Steps Taken
Any help or guidance on resolving this issue would be greatly appreciated. Thank you!
The text was updated successfully, but these errors were encountered: