• Sign Up Login
  • Features
    • Game Services
    • Real-time Analytics
    • LiveOps
    • Add-ons
  • Game Services
  • Real-time Analytics
  • LiveOps
  • Add-ons
  • Games
  • Pricing
  • Blog
  • Support
    • Docs
    • Forums
    • Contact
  • Docs
  • Forums
  • Contact
  • Sign Up Login
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges
  • Home /
  • Bugs /
avatar image
Question by jcoriston · Jan 24, 2018 at 09:46 PM · In-Game Economywindows

ValidateWindowsStoreReceipt error 400 Invalid receipt

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!

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment

People who like this

0 Show 2 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image jcoriston · Jan 25, 2018 at 06:38 PM 0
Share

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.

avatar image Brendan ♦♦ jcoriston · Jan 25, 2018 at 07:04 PM 1
Share

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?

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    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

    • PlayFab

      • Features
      • Games
      • Pricing
      • Blog
    • Engineers

      • Documentation
      • Quickstarts
      • API Reference
      • SDKs
      • Usage Limits
    • Support

      • Forums
      • Videos
      • Contact
      • Service Health
      • Terms of Service
    • Social

      • Facebook
      • Twitter
      • LinkedIn
      • YouTube
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • About Microsoft
    • Jobs
    • Accessibility
    • Diversity & inclusion
    • Security
    • Company news
    • © Microsoft 2019
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Post an idea
    • Create an article
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges