Hello, in my game I am using Unity IAP with PlayFab's receipt validation, but it is not working properly. I can always purchase a product without any errors, but when I try to validate the receipt from google it randomly fails with "Invalid receipt" error. Sending the same receipt immediately after the failed call, I almost always get a successful validation. I tried different versions of Unity, IAP package, PlayFab SDK but without success.
Here is my implementation:
public PurchaseProcessingResult ProcessPurchase (PurchaseEventArgs e) { Debug.Log ("Processing transaction: " + e.purchasedProduct.transactionID); ValidateReceipt (e.purchasedProduct); return PurchaseProcessingResult.Complete; } public void ValidateReceipt (Product product) { Dictionary<string, object> receiptContent = (Dictionary<string, object>)MiniJson.JsonDecode(product.receipt); string payload = receiptContent["Payload"].ToString (); decimal price = product.metadata.localizedPrice; string currency = product.metadata.isoCurrencyCode; Dictionary<string, object> payLoadContent = (Dictionary<string, object>)MiniJson.JsonDecode(payload); string json = payLoadContent["json"].ToString(); string signature = payLoadContent["signature"].ToString(); Debug.Log ("Validating receipt: " + payload); PlayFabClientAPI.ValidateGooglePlayPurchase (new ValidateGooglePlayPurchaseRequest { ReceiptJson = json, Signature = signature, PurchasePrice = (uint)(price), CurrencyCode = currency }, (ValidateGooglePlayPurchaseResult result) => { Debug.Log ("Validation success"); }, (PlayFabError error) => { Debug.Log (error.ErrorMessage); }); }