question

brendan avatar image
brendan asked

InvalidReceipt when trying to validate google play purchase

Grogshotgames
started a topic on Mon, 03 August 2015 at 8:46 AM

Hi,

Everytime I try to purchase an item with real money and validate it with Google Play (ValidateGooglePlayPurchase), it returns the error "InvalidReceipt".

I'm using OpenIAB to make the purchases and everything seems correct on that side. Here's a description on how I handle the proccess to make the purchases:

  1. Initialize OpenIAB
  2. Buy an item with openiab's purchase function: OpenIAB.purchaseProduct(itemID); This purchase function returns a Purchase which contains all the necesary info por validating the purchase with google.
  3. Execute the next piece of code:
ValidateGooglePlayPurchaseRequest request = new ValidateGooglePlayPurchaseRequest();
request.ReceiptJson = purchase.OriginalJson;
request.Signature = purchase.Signature;
PlayFabClientAPI.ValidateGooglePlayPurchase(request, OnAndroidSuccessfulPurchase, OnAndroidFailedPurchase);

This returns the "InvalidReceipt" error which I mentioned before.
I have debugged the information that OpenIAB's purchase gave me and everything seems ok, including the OriginalJson and Signature.

Is there something that I can be missing out?

A possible problem could be the price.
RM as I read in the docs, is in $ (1,99), while I'm making my payments in ? (2,41) and my catalog's Json doesn't have reference of this...I don't see any option for adding this neither on the Playfab's Game Manager.

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

Best Answer
Prasad said on Wed, 19 August 2015 at 2:13 AM

Hi,

Interesting update from my side,

I just rechecked every single thing from my end (based on the checklist you provided) just to be very sure. I noticed the 'Google App License Key' in playfab is different from 'Application License Key' in developer console. (Their start and ends were the same, but they were different in between, when i compared it side by side, only then could i notice it).

After correcting this error, it started working correctly on my side.

Hope this will help.

Thanks

Prasad.


16 Comments
Brendan Vanous said on Mon, 03 August 2015 at 2:51 PM

The InvalidReceipt response indicates that when we attempted to validate the receipt with Google, it was rejected by their service.

I did have a quick look at the OpenIAB source: https://github.com/onepf/OpenIAB/blob/1e33bad58553c72bd3bdd6181877fe981dc85c65/library/src/main/java/org/onepf/oms/appstore/googleUtils/Purchase.java

From looking at it, I would say that getOriginalJson() would appear to be returning the correct string, based on a look at mOriginalJson, but I notice that you're using "purchase.OriginalJson", which would seem to imply there's some delta between the code I'm looking at and what yo're using.

The most likely answer here is that the value in OriginalJson isn't what's expected - can you run a quick test and send us the actual string that's being passed in as the ReceiptJson in that call (as well as the Signature, for completeness)?

Brendan


Grogshotgames said on Mon, 03 August 2015 at 3:11 PM

Thanks brendanv!

Here's purchase.OriginalJson value:

{"orderId":"GPA.1373-2239-0698-09640","packageName":"com.grogshot.pirates","productId":"500_gems_pack","purchaseTime":1438639126718,"purchaseState":0,"purchaseToken":"ieigkpnkcchgjhjaibpbcaej.AO-J1OyMBLTSOfMojeSMXuqJqr6qRDVqJv3vAvYsxkjZ0JOM7ggZspo9pWuF_TNU4UbqifuJ8v4xGjQnY8xt_WwKhRiWqTVgWN-_CpVpGhfe275RvG10FzwW-fp1CllicxQsb3ns0Apl"}

I hope this helps to solve the problem


Brendan Vanous said on Mon, 03 August 2015 at 4:44 PM

Thanks - that's helpful. What's the signature in the call? Also, can you tell us what, if any, the differences are between the OpenIAB in GitHub and the version you're using (i.e.: why is it OriginalJson in your code, rather than getOriginalJson())?

Brendan


Grogshotgames said on Mon, 03 August 2015 at 4:52 PM

The signature:

The differences on the OpenIAB code might be that you are looking at the normal OpenIAB, instead of the Unity plugin (made by them). Sorry I should have commented that I use Unity!


Grogshotgames said on Tue, 04 August 2015 at 3:37 PM

Hi Brendan! any updates on this?
My guesses are related with:

  • The price that I have in the Game Manager is 199 RM and when I make the purchase, it says that the real cost is 2,41?. I don't know if the price difference can cause the validation to fail

  • OrderId returned in the receipt looks different than in playfab's docs:

"orderId":"12999763169054705758.1375794066587622" vs "orderId":"GPA.1373-2239-0698-09640"

Brendan Vanous said on Wed, 05 August 2015 at 1:56 AM

Sorry, I'm at Gamescom this week, so my responses are a bit delayed. Can you send us the full request as text (Json and signature)? I'm afraid trying to type the signature from an image is inevitably going to result in errors. The price should be fine - as long as there's a price defined. No price tells us it cannot be purchased. And the OrderId may be okay - we just need to get all the details for a call in a for,at we can use for testing, so that we can see what's going on in the validation process. Brendan


Grogshotgames said on Wed, 05 August 2015 at 3:08 AM

Hi Brendan, I hope you enjoy Gamescom :)

Here's the request as text.

Json:

{"orderId":"GPA.1373-2239-0698-09640","packageName":"com.grogshot.pirates","productId":"500_gems_pack","purchaseTime":1438639126718,"purchaseState":0,"purchaseToken":"ieigkpnkcchgjhjaibpbcaej.AO-J1OyMBLTSOfMojeSMXuqJqr6qRDVqJv3vAvYsxkjZ0JOM7ggZspo9pWuF_TNU4UbqifuJ8v4xGjQnY8xt_WwKhRiWqTVgWN-_CpVpGhfe275RvG10FzwW-fp1CllicxQsb3ns0Apl"}

Signature:

YMR/aDrllPISW4Ddy3Ka+8lgYMltb0eS1N/mshcM7D/5AXW29lobTxoHruFpTE4AtrC0WWK4p59rA3ZPMQ5rK2rYZdHr05R8iDibAuo4BB2Oe+VQ4w/cQ8Rkc16naXJHYvdMMgawrtlbXHzt4+zc1YWuvo+ETDoad82h3GGWPFuZ0RIGPp3deczD2HAIGRUljSDrrMq7YVUEgGQVmMSQEGeOB+UnVs1iFNfga5drLme9JVp5T0h9uGMWS3U24e2C9rWqJblA3ZyGhkWGBdObVWkOXGVS32v41lMem7mCK6DPqOXlwV776lWDny7l35w4Oqn2jPPh+r940ZxJrBCZyQ==

Brendan Vanous said on Mon, 10 August 2015 at 11:20 PM

I've tested this a number of ways now, and I also keep getting the response that the receipt isn't valid. Tracing in, this appears to be due to Google rejecting it. You mentioned that you'd verified the signature in some other way - can you clarify how you did, exactly? When you initiate the purchase, are you passing in an identifying string (the developerPayload)?

Brendan


Grogshotgames said on Thu, 13 August 2015 at 5:53 AM

Hi Brendan!

I do not verify the signature in any other way, I just use OpenIAB for making the purchase via Google Play, but I don't verify the purchase with OpenIAB, I do it with Playfab.

I believe that everything was set up correctly, but just in case, could you please tell me what it should be done to make sure that the validation works? Maybe I'm missing something...


Grogshotgames said on Mon, 17 August 2015 at 5:04 PM

A step by step guide would be great. I didn't find any in the docs or in the video tutorials, (where they focus more on the results rather than how it's done...).

Please help


Brendan Vanous said on Mon, 17 August 2015 at 5:56 PM

The step-by-step for receipt validation is here: https://playfab.com/blog/2015/02/06/show-me-money-receipt-validation-ios-and-android. The problem you're experiencing appears to be specific to the plugin you're using, which isn't something we would be creating a walkthrough for (as we can't control any changes made to a third-party plugin).

The way receipt validation works for Google Play, the signed Receipt Data needs to match the Signature (oversimplification, but I can send you the full info, if needed). So the ways you'd get an InvalidReceipt error are: the Receipt Data or Signature is being modified before it's sent up to us for validation, or the Key (Google App License Key) isn't correct for your title. Can you check your Key versus the one set up for your title in Settings->Secret Keys?

Brendan


Prasad said on Wed, 19 August 2015 at 1:24 AM

Hi,

I am having the exact same issue. The only variable changed here is the IAP plugin. In my case i am using Unibill to perform my purchases. I then try to validate this purchase with playfab api call 'ValidateGooglePlayPurchase', which fails.

The document from Unibill is clearly specifying what data it returns ( which it does) and this data perfectly matches input required for playfab api call.

The playfab api call for ios ' ValidateIOSReceipt' is working fine and returning success when receipt information is provided to it which is returned by Unibill purchase call.

I hope this info will help somehow. Please let me know your opinion on this.


Prasad said on Wed, 19 August 2015 at 2:13 AM

Hi,

Interesting update from my side,

I just rechecked every single thing from my end (based on the checklist you provided) just to be very sure. I noticed the 'Google App License Key' in playfab is different from 'Application License Key' in developer console. (Their start and ends were the same, but they were different in between, when i compared it side by side, only then could i notice it).

After correcting this error, it started working correctly on my side.

Hope this will help.

Thanks

Prasad.


Brendan Vanous said on Wed, 19 August 2015 at 1:43 PM

Glad to hear that. It is indeed the case that the License Key must be exactly the same as the Key in your Google Developer Console. That Key is used by our service to make calls on you behalf securely. If it doesn't match, receipt validation will not work.

Grogshot Games, can you verify that the Key matches?

Brendan


Grogshotgames said on Mon, 24 August 2015 at 7:30 AM

That was exactly the problem! There was a character missing in the Playfab's Game Manager section

Thanks Prasad and Brendan for helping out!!


Brendan Vanous said on Mon, 24 August 2015 at 8:10 AM

Great, glad to hear you're back on track. Let us know if you run into any other issues.

Brendan

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.