Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.then(() => {
if (Platform.OS === 'ios') {
RNIap.finishTransactionIOS(get(purchase, 'transactionId'));
} else if (Platform.OS === 'android') {
RNIap.consumePurchaseAndroid(token);
}
this.setState({ isProcessing: false });
if (fetchData) {
fetchData();
}
})
.catch(err =>
})
if (res.result)
RNIap.finishTransactionIOS(purchase.transactionId)
break
case 'android':
res = await Api._post(`${endpoint}/google/inapp`, {
userId,
product_id: purchase.productId,
token: purchase.purchaseToken,
etc: purchase.dataAndroid
})
if (res.result)
RNIap.consumePurchaseAndroid(purchase.purchaseToken)
break
}
if (res.result)
return true
else
throw new Error('invalid_receipt')
}