question

Ivan avatar image
Ivan asked

How to manually validate Android receipt?

Let's say that for some reason (e.g. network latency) the API call ValidateGooglePlayPurchase failed and we have to manually process the purchase to the affected players. Is there a way for us to manually mark a receipt as used using information available to us (e.g. orderId)? If yes, do you have a guide / sample code to retrieve the information required? I can't find any API call in the Google API documentation to retrieve the receipt JSON / signature

apisandroid
10 |1200

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

Tommy Li avatar image
Tommy Li answered

Your problem can be better solved by implementing the receipt reprocessing on the client. If you use Unity IAP, Unity always populates the receipt information in its Product objects. There is no way on the developer side (e.g. a web API) to retrieve any receipt information with order ID.

In my game, I have a manual receipt validation button. When tapped, the app would query all Unity IAP Product objects, fetch the receipt property, filter the duplicated ones and then call ValidateGooglePlayPurchase one by one. Validating a previously-validated receipt has no known harm. Whenever my customer says their purchase has failed, I would ask them to run that button and it has been working.

By the way, if you implement Unity IAP properly, that you return Pending in you ProcessPurchase implementation inside which you call PlayFab to verify the receipt, and if for some reason your processing failed, the transaction and its receipt will be presented to your IStoreListener again next time you reinitialize Unity IAP.

10 |1200

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

Citrus Yan avatar image
Citrus Yan answered

If a receipt is valid and PlayFab were having issue validating it on the backend, usually you can just retry calling ValidateGooglePlayPurchase again.

4 comments
10 |1200

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

Ivan avatar image Ivan commented ·

I'm aware of that, but the ValidateGooglePlayPurchase will have to be called from inside the client because we don't have access to the JSON and the signature. My question is how do we either retrieve those information or validate the purchase using other parameters available to us (e.g. the google play order ID)

0 Likes 0 ·
Citrus Yan avatar image Citrus Yan Ivan commented ·

Which game engine are you using? If it's Unity, we do have a tutorial for using Unity IAP with Android, where you can access these information quite easily:

https://docs.microsoft.com/en-us/gaming/playfab/features/commerce/economy/getting-started-with-unity-iap-android

And, this blog post on Receipt Validation for iOS and Android might also be helpful:

https://blog.playfab.com/blog/show-me-money-receipt-validation-ios-and-android/

0 Likes 0 ·
Ivan avatar image Ivan Citrus Yan commented ·

Yes, I use Unity and I've read both articles. My workflow is very similar to

https://docs.microsoft.com/en-us/gaming/playfab/features/commerce/economy/getting-started-with-unity-iap-android


I think you're not getting my question. Imagine that for some reason, the ValidateGooglePlayPurchase never succeeds (e.g. timeout and the user kills the app in the middle). User then sends a support ticket to me, citing the order ID (e.g. GPA.XXXX) which is available in the Google Pay receipt. I can create a CloudScript automation to call ValidateGooglePlayPurchase, but I don't have access to the receipt JSON and signature because it's in the user's phone. Can I just use the order ID to validate the receipt and grant the item? If not, do I have a way to retrieve it from my side from Google API? Should I create the ability to log the receipt in a text file so that the user can send it to me? What is your recommended workflow for this situation?

0 Likes 0 ·
Show more comments

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.