I have been implementing receipt validation, however, I have come across an issue that has me completely stuck. The CrossPlatformValidator has stopped returning anything for my receipts when I validate the receipt.
var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
try
{
// On Google Play, result has a single product ID.
// On Apple stores, receipts contain multiple products.
var result = validator.Validate(e.purchasedProduct.receipt); // <------ this now returns nothing, even if the receipt is present
Debug.Log( validator.Validate(e.purchasedProduct.receipt).Length );
// For informational purposes, we list the receipt(s)
Debug.Log("Receipt is valid. Contents:");
string debug_string = "";
foreach (IPurchaseReceipt productReceipt in result)
{
debug_string += productReceipt.productID + "\n";
debug_string += productReceipt.purchaseDate + "\n";
debug_string += productReceipt.transactionID + "\n\n";
}
Debug.Log( debug_string );
}
catch (IAPSecurityException)
{
Debug.Log("Invalid receipt, not unlocking content");
}
Before it was working fine but now it simply doesn’t return anything.
The Process Purchase is called correctly and all other parts of the IAP system are responding fine.
Could the ios cache receipt desync with the store?
What is the value of “result” ? Can you check “if (result == null)” and “if (result !=null)” . You mentioned “before it was working fine”, what has changed? Can you provide the device logs that contains the Debug.Log statements? How To - Capturing Device Logs on iOS
thank your for responding @JeffDUnity3D
So I have partially solved this and got it working again.
First to answer your questions @JeffDUnity3D .
I have confirmed that I was passing the unity formatted json receipt string, with the store, transaction and the store specific payload, into the validator as instructed by the documentation. And that the hasReceipt field was true. (this was the original confusion, a receipt was present but the validator would not return anything, but it wouldn’t throw an exception either.) Also tried the apple app receipt (which is the payload from what I read), but that threw an expectation as expected.
I even reverted to a previous implementation of the code before it stopped working, but that didn’t fix anything.
However then I changed to a different apple test account and it worked fine, even with my latest implementation. So I can rule out the current implemented code causing anything to not work.
So what I think happened, earlier I accidentally changed the IAP initialization process to add a product identifier with an incorrect product type (all via the configuration builder), (I’m expanding to add support for subscriptions as well as non-consumable). That was the key change the stopped it from working. I found it and corrected it but after it would still not work properly until I changed accounts.
This leads me to believe that it changed something on apples ios end. I can only assume the ios cache for the receipt was corrupted or something.
I’ll test this on another device and report it back here. Otherwise, this thread can be considered partially solved.