Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
/*
These item entries are created in App Store Connect and Google Play Console respectively.
If you want to add more or edit their attributes you can do so there.
*/
const items = Platform.select({
ios: [
'dev.expo.products.premium',
'dev.expo.payments.updates',
'dev.expo.payments.adfree',
'dev.expo.payments.gold',
],
android: ['gas', 'premium', 'gold_yearly', 'gold_monthly'],
});
// Get product details
const { responseCode, results } = await getProductsAsync(items);
if (responseCode === IAPResponseCode.OK) {
this.setState({ items: results, history: history.results });
}
// Set purchase listener
setPurchaseListener(({ responseCode, results, errorCode }) => {
if (responseCode === IAPResponseCode.OK) {
for (const purchase of results) {
console.log(`Successfully purchased ${purchase.productId}`);
if (!purchase.acknowledged) {
finishTransactionAsync(purchase, true);
}
}
} else if (responseCode === IAPResponseCode.USER_CANCELED) {
console.log('User canceled');
} else {