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
// 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
The text was updated successfully, but these errors were encountered:
pixlerSanjay
changed the title
requestPurchase Endpoint Does Not Return Error or Success Status
requestPurchase Does Not Return Error or Success Status
Mar 7, 2024
// 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
The text was updated successfully, but these errors were encountered: