Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requestPurchase Does Not Return Error or Success Status #2700

Open
pixlerSanjay opened this issue Mar 7, 2024 · 2 comments
Open

requestPurchase Does Not Return Error or Success Status #2700

pixlerSanjay opened this issue Mar 7, 2024 · 2 comments

Comments

@pixlerSanjay
Copy link

// 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 pixlerSanjay changed the title requestPurchase Endpoint Does Not Return Error or Success Status requestPurchase Does Not Return Error or Success Status Mar 7, 2024
@janisievins
Copy link

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

@joomoodle
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants