question

brendan avatar image
brendan asked

Invalid Format error on Google Play receipt validation

Question from a developer:

When I call ValidateGooglePlayPurchase, I'm getting an "Invalid Format" error. What format should the ReceiptJson parameter be?

Also, should I call consumePurchase in Google before calling ValidateGooglePlayPurchase, or will that cause a problem?

In-Game Economy
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
brendan avatar image
brendan answered

The way receipt validation works, we do a comparison of the Signature to the ReceiptJson as a first step. The Signature is a cryptographic signature of the JSON data, so if anything at all has been changed from what was sent by Google, it won't work. In this case - specifically, the "Invalid Format" error - the issue is that something is malformed about one of the two, most likely the ReceiptJson. Since the ReceiptJson is a string, and assuming you've extracted the Payload "json" to an actual JSON object is pass in the stringified version of that JSON object (ToString() or Stringify(), depending on your implementation). So it should look something like this:

"\"packageName\":\"com.foo.bar\",\"productId\":\"catalogItemIdGoesHere\",\"purchaseTime\":1488892609876,\"purchaseState\":0,\"purchaseToken\":\"fullGoogleTokenGoesHere\"}"

As to consumePurchase, yes, if it's a consumable, you should call that and you can call it before the Google receipt validation step (as shown in our post on receipt validation, here: https://playfab.com/show-me-money-receipt-validation-ios-and-android/). If you don't, the player won't be able to make another purchase of the same item from Google Play.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.