godotengine / godot-google-play-billing

Godot Android plugin for the Google Play Billing library
MIT License
138 stars 39 forks source link

purchases_updated does not return original data needed for receipt validation #27

Open Colorfulmoose opened 2 years ago

Colorfulmoose commented 2 years ago

purchases_updated uses your custom utils to convert the received purchases data into a dictionary (very useful, except in this case...)

For receipt validation (in my case through Playfab) I need to pass the original JSON from the purchase data in the exact format it was received - on their end, it looks like Google converts this to a hash using your private developer key and compares it to the signature, which should match. Changing the order or formatting of their data, or leaving out pieces of it, makes it so that won't work. Is there any way to change purchases_updated or create a new callback that returns the original purchase data?

My understanding of this may be somewhat naïve, so I hope I explained it well, and I'm open to other solutions!

natetrost commented 2 years ago

I believe the need for the original json is specific to the Playfab receipt validation implementation. Adding it to the Purchase dictionary should be possible in a future release, if you wanted to make a local build with the feature I think all you would need to do is add the following line to the convertPurchaseToDictionary function in GooglePlayBillingUtils.java:

dictionary.put("original_json", purchase.getOriginalJson());

And then use the original_json key to retrieve the string to pass to Playfab.

Colorfulmoose commented 2 years ago

Ah, ok! I will try that. Thanks!

Colorfulmoose commented 2 years ago

Ok, I have results: On the most current version of this repo, I was unable to get the plugin to work in godot (with my changes or not) but when I rolled back to the stable release version, I was able to make this change and PlayFab is happy. Thanks for the suggestion @natetrost !

natetrost commented 2 years ago

Glad to hear it, the current version of the repo hasn't rolled out into a release yet, it does have an API change, which isn't reflected in the tutorial docs since it isn't the current release yet. I suspect that might have been where you ran into problems before rolling back to 1.0.1.