Hi guys.
I’m working with Unity IAP plugin. When app starting, i want to check a non-consumable product was bought or not. This is the code i used:
public bool IsPurchased (string productID)
{
Product product = m_StoreController.products.WithID (productID);
if (product != null && product.hasReceipt) {
return true;
}
return false;
}
Even i have already bought a non-consumable one but the product.hasReceipt alway return false on iOS platform (sandbox).
I expected it should alway return true as i bought a non-consumable product.
Somebody tell me why?
Thank you in advance.
2 Answers
2
I found a solution to work around this problem by using apple receipt. This is the snip code i use. Hope it can help you guys
var builder = ConfigurationBuilder.Instance (StandardPurchasingModule.Instance ());
var receiptData = Convert.FromBase64String (builder.Configure<IAppleConfiguration> ().appReceipt);
var receipt = new AppleValidator (AppleTangle.Data ()).Validate (receiptData);
foreach (AppleInAppPurchaseReceipt productReceipt in receipt.inAppPurchaseReceipts) {
if (productReceipt.productID.Equals (productID)) {
return true;
}
}
return false;
I still don’t understand why product.hasReceipt return false 
var receiptData = Convert.FromBase64String (builder.Configure ().appReceipt); return "This is a fake receipt. When running on an apple store, a base64 encoded App Receipt would be ... " and throw FormatException. I need to test IAP before the app is on Appstore. what should I do???
– peter_kes