react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

requestPurchase Does Not Return Error or Success Status

Open pixlerSanjay opened this issue 4 months ago • 3 comments

// Function to handle purchase const handlePurchase = async productId => { if (purchaseInProgress) { // If purchase already in progress, return return console.log('purchase already in progress'); } try { setPurchaseInProgress(true); // Set purchase in progress state to true console.log("--------87") const purchase = await RNIap.requestPurchase({sku: productId}); // Purchase the product console.log("--------89") if (!purchase || purchase.purchaseState !== 'purchased') { // If purchase state is not purchased, show error alert Alert.alert( 'Purchase Failed', 'There was an error processing your purchase', ); } else { // If purchase successful, show alert Alert.alert('Purchase Successful', You have purchased ${productId}); } setPurchaseInProgress(false); // Reset purchase in progress state } catch (error) { setPurchaseInProgress(false); // Reset purchase in progress state Alert.alert( 'Purchase Failed', 'There was an error processing your purchase', ); console.error('Purchase error:', error); } };

hello this is my function and when i click on subscribe button this function hit. And also, open sandbox popup with my products but when I entered my sandbox credentials popup hide for some time but again show and i don't got any result or my console.log("--------89") ,that time. if have ant one solution then please response me Thanks

pixlerSanjay avatar Mar 07 '24 13:03 pixlerSanjay

I have faced a similar issue. Error message: The operation couldn’t be completed. (SKErrorDomain error 2.)

iOS version: 17.3.1. react-native-iap version: 12.10.8

janisievins avatar Mar 11 '24 08:03 janisievins

I am facing similar problem in requestSubscription

It does not enter the useEffect of currentPurchase, it is sent undefined and therefore the purchase is not detected

Versión de iOS: 17.0.1 Versión reaccionar-nativa-iap: 12.12.2

joomoodle avatar Mar 13 '24 06:03 joomoodle