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 =>
export const validatePurchase = async (purchase, userId)=>{
const endpoint = process.env.NODE_ENV == 'production' ? 'https://billing.raindrop.io/v1' : Config.BILLING_DEV_ENDPOINT
let res
switch(Platform.OS) {
case 'ios':
res = await Api._post(`${endpoint}/apple/inapp`, {
userId,
receipt: purchase.transactionReceipt
})
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)