Hello,
I'm trying to test Windows Store purchases (using Unity IAP) - but some receipts return as invalid.
Here's the result of the failed validation from the dashboard:
"EventName": "player_receipt_validation", "PaymentProvider": "Windows Store", "PaymentType": "ReceiptValidation", "ReceiptContent": "<?xml version=\"1.0\"?><Receipt Version=\"1.0\" CertificateId=\"A656B9B1B3AA509EEA30222E6D5E7DBDA9822DCD\" xmlns=\"http://schemas.microsoft.com/windows/2012/store/receipt\"><ProductReceipt PurchasePrice=\"USD0\" PurchaseDate=\"2017-09-06T21:19:25.800Z\" Id=\"3b6f06b0-74a7-492c-8418-98b8fada16ea\" AppId=\"SPT.PlaytheShow_xhagv60wx4y2m\" ProductId=\"test\" ProductType=\"Durable\" PublisherUserId=\"FIRBmGkslmaT/gPPpxcrZNrR6J9XCNlC0520pXeEtU0=\" MicrosoftProductId=\"7a31d10d-4d6a-4f3e-9f40-0136eb10002d\" MicrosoftAppId=\"7a31d10d-4d6a-4f3e-9f40-0136eb10002d\" ExpirationDate=\"9999-12-31T23:59:59.999Z\" /><Signature xmlns=\"http://www.w3.org/2000/09/xmldsig#\"><SignedInfo><CanonicalizationMethod Algorithm=\"http://www.w3.org/TR/2001/REC-xml-c14n-20010315\" /><SignatureMethod Algorithm=\"http://www.w3.org/2001/04/xmldsig-more#rsa-sha256\" /><Reference URI=\"\"><Transforms><Transform Algorithm=\"http://www.w3.org/2000/09/xmldsig#enveloped-signature\" /></Transforms><DigestMethod Algorithm=\"http://www.w3.org/2001/04/xmlenc#sha256\" /><DigestValue>Q73Qo5D9H+tbtLKMbM4GH1hju1u9GrVku27FGIKlfSk=</DigestValue></Reference></SignedInfo><SignatureValue>U9m3dRFXr2u+olO9q77kLo+fRkGbXimVRdDyLsFr9dXh6aLO2rWLCbRSFUJI/IsN/Xg2EUoTslPukTqJrGNcesgvsHdnfsvRxI5y+a2qdNPT2tEZRwkbetC7zWmAiAjWRI4ge4jTVWHcOLYuferm6IBYmbFhkeDOBEHaOIA1Jbnhq9TXw9SOJc4b0CHzSuudXSqwXioy6qdivWyPCWz54dbdUorJJIaFRKCsNkixKBVU6k/tgi7+1uM7rDNM4HhyW17KgP2c4gLH5QXcOASzwUSYhFgDqFmnnFfSsZ1q/mhSZO5G8QYnz+rmPpbmmxXmvCmtx70f+qtEqPhek3lVJw==</SignatureValue></Signature></Receipt>", "Valid": false, "Error": "Invalid receipt", "EventNamespace": "com.playfab", "EntityType": "player", "Source": "PlayFab", "TitleId": "1990", "EventId": "c45d95ef10d84aa8a25c70dd1f00ecff", "EntityId": "A5CA6E9F2B931740", "SourceType": "BackEnd", "Timestamp": "2018-01-24T20:53:35.843666Z", "History": null, "CustomTags": null, "Reserved": null
In my request I make sure to pass the currency code and price (converted from dollars to cents) directly from the Unity purchase data. I also made sure the price matches the item in our primary catalog.
Am I missing something?
Thanks!
Answer by Brendan · Jan 25, 2018 at 02:50 AM
How exactly are you getting this receipt? It's missing some required elements - ReceiptDate and ReceiptDeviceId, specifically (https://docs.microsoft.com/en-us/windows/uwp/monetize/use-receipts-to-verify-product-purchases). Without those, the receipt is not valid and cannot be processed.
That's interesting...
I'm getting the receipt via the UnityReceipt payload as briefly mentioned in this doc.
Here's the relevant code:
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { //Parse Unity receipt JSON for actual Windows Store receipt var receipt = JsonConvert.DeserializeObject<UnityReceipt>(args.purchasedProduct.receipt); playfab.ValidateReceipt(receipt.payload, args.purchasedProduct.metadata.localizedPrice, args.purchasedProduct.metadata.isoCurrencyCode, receipt.store, args.purchasedProduct.definition.id); }
The receipt.payload is the string I'm passing into ValidateWindowsReceiptRequest as the Receipt.
Thanks Brendan.
It's not clear to us why the ReceiptDate and ReceiptDeviceId would be missing, when they are part of the Receipt element. Without knowing the internals of Unity's code, it's not relaly possible for us to say what, if anything, is being done on the receipt data. Can you post that question to the Unity team?
ValidateWindowsStoreReceipt error 500 (ServiceUnavailable) 1 Answer
PlayFabClientAPI.RestoreIOSPurchases restore more items than bought ones. 1 Answer
PayPal Payment Redirect 1 Answer
Coupon response doesn't include currencies 1 Answer
GetCatalogItems returns empty properties (discarded in the past) 1 Answer