I'm using this in-app-purchase package by RevenueCat and everything is working fine except the restore purchase.
This is the steps that I took to test it.
- Install App in production from App Store
- Purchase a non-consumable book and get the access
- Uninstall the app
- Reinstall the app from App Store again
- Click "Restore Purchase" option on the book that I just bought but it's saying no previous purchase found even though I already see that transaction in RevenueCat Dashboard.
I have 5 different non-consumable books so I created 5 different entitlement in RevenueCat (Screenshot below).
I checked it like this to make sure I only give access if a user purchase the selected book
if (purchaserInfo.entitlements.all[widget.bookIdentifier]?.isActive == true || purchaserInfo.entitlements.active.containsKey(widget.bookIdentifier) || purchaserInfo.allPurchasedProductIdentifiers.contains(widget.bookIdentifier))
Here is the full code. This is my Restore Purchase text button
TextButton(
onPressed: () async {
try {
CustomerInfo purchaserInfo =
await Purchases.getCustomerInfo();
if (purchaserInfo
.entitlements
.all[widget.bookIdentifier]
?.isActive ==
true ||
purchaserInfo.entitlements.active
.containsKey(
widget.bookIdentifier) ||
purchaserInfo
.allPurchasedProductIdentifiers
.contains(widget.bookIdentifier)) {
purchaseController.toggleBookPurchase(
selectedBook.id!,
selectedBook.bookCoverPic!,
selectedBook.bookClass!,
selectedBook.bookIdentifier!,
selectedBook.bookChapters!);
} else {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(
content: Text(
"Sorry, no previous purchase found for ${purchaserInfo.originalAppUserId}")));
}
} catch (e) {
CustomerInfo purchaserInfo =
await Purchases.getCustomerInfo();
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text(
"Sorry, no previous purchase found for ${purchaserInfo.originalAppUserId}")));
}
},
)