Hello,
I’m trying to implement a non-consumable receipt validation at the start-up of the game, to check if the non-consumable is still valid. By valid, I mean the user still has access the content and the entitlement is still active. This is for Google Play only.
From the Debug.Logs (“Purchase 1” to “Purchase 8”), I’ve realized that, no matter if non-consumable is still valid or not, CrossPlatformValidator returns the IAPSecurityException.
If the non-consumable is still valid, there is also an “Already recorded transaction” log from Unity.
Can you help how to solve this?
thanks,
public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
{
Debug.Log("OnInitialized: PASS");
m_StoreController = controller;
m_StoreExtensionProvider = extensions;
CheckIfOwned();
}
void CheckIfOwned()
{
Debug.Log("Purchase 1");
foreach (var item in m_StoreController.products.all)
{
var validator = new CrossPlatformValidator(GooglePlayTangle.Data(),
AppleTangle.Data(),
Application.identifier);
Debug.Log("Purchase 2");
try
{
Debug.Log("Purchase 3");
// On Google Play, result has a single product ID.
// On Apple stores, receipts contain multiple products.
var result = validator.Validate(item.receipt);
// For informational purposes, we list the receipt(s)
//Debug.Log("CustomMsg: Receipt is valid. Contents:");
Debug.Log("Purchase 4");
foreach (IPurchaseReceipt productReceipt in result)
{
////Debug.Log("CustomMsg: " + productReceipt.productID);
////Debug.Log("CustomMsg: " + productReceipt.purchaseDate);
////Debug.Log("CustomMsg: " + productReceipt.transactionID);
Debug.Log("Purchase 5");
if (String.Equals(productReceipt.productID, removeAds, StringComparison.Ordinal))
{
RemoveAdsValid(true);
Debug.Log("Purchase 6");
}
else
{
RemoveAdsValid(false);
Debug.Log("Purchase 7");
}
}
}
catch (IAPSecurityException)
{
Debug.Log("Purchase 8");
//Debug.Log("CustomMsg: Invalid receipt, not unlocking content");
//validPurchase = false;
//DefaultConfiguration();
}
}
}