react-native-iap
react-native-iap copied to clipboard
How to correctly finish transaction for Apple subscription?
Version of react-native-iap
4.6.3
Version of react-native
0.63.4
Platforms you faced the error (IOS or Android or both?)
iOS
Expected behavior
Transaction should be finished and appeared in My subscriptions
Actual behavior
No errors but subscription is not appeared
Tested environment (Emulator? Real Device?)
Real Device, production mode
Steps to reproduce the behavior
await RNIAP.initConnection()
RNIAP.clearProductsIOS()
const products = await RNIAP.getProducts([productId])
RNIAP.purchaseUpdatedListener(async (purchase) => {
// Checking for prod mode first
let result = await RNIAP.validateReceiptIos({
"receipt-data": purchase.transactionReceipt,
"password": env.IOS_IAP_SECRET,
}, false)
// Then for sandbox mode
if (result.status === 21007) {
result = await RNIAP.validateReceiptIos({
"receipt-data": purchase.transactionReceipt,
"password": env.IOS_IAP_SECRET,
}, true)
}
if (result.status !== 0) {
return
}
RNIAP.finishTransaction(purchase, true)
})
RNIAP.purchaseErrorListener(error => {
reject(error)
})
return RNIAP.requestSubscription(productId, false)
I have the same problem! I use RNIAP.finishTransaction(purchase) after the receipt checking everything works until i use getPurchaseHistory() / getAvailablePurchase() when i use the above functions, clicking the subscription button become checking the old receipt validation, instead of showing the purchase
I think you shouldn't be doing the validation in the client side if the user try to intercept the requests with a proxy and override the IOS_IAP_SECRET by Reverse engineering your app this should give premium access or features with a very simple atack
Hi @Ulisses1478 Thanks for your answer, but my question was different. In real life backend checks receipt.
please check my reply on other question #1312 hope this can help you
@PazuC10 What's your version? Your code is almost same as mine
@PazuC10 What's your version? Your code is almost same as mine
iap: 6.0.2, react-native: 0.64.0
Hey there, it looks like there has been no activity on this issue recently. Has the issue been fixed, or does it still require the community's attention? This issue may be closed if no further activity occurs. You may also label this issue as "For Discussion" or "Good first issue" and I will leave it open. Thank you for your contributions.
Use the latest version of the library and use finishTransaction