Hi all,
My project was setup according to the UnityIAP guide. Everything works perfectly, including Google Play purchases after uploading the APK to the developer’s console.
Unfortunately, I run into a problem parsing the JSON from the “payload” field of the purchase receipt (which I need for server side verification).
In the ProcessPurchase function of IStoreListener, when a purchase completes successfully, the payload value of the receipt (e.purchasedProduct.receipt) appears to have incorrect JSON. This is both when I buy something in the editor to test, and when I make an actual purchase when running on Android.
When I log the receipt of the editor, it looks like this:
{"Store":"fake","TransactionID":"aaa995f8-496a-4781-91f9-41bfdb9a6b6a","Payload":"{ \"this\" : \"is a fake receipt\" }"}
The Google Play receipt looks like this:
{"Store":"GooglePlay","TransactionID":"GPA.1357-7815-3377-93231","Payload":"{\"json\":\"{\\\"orderId\\\":\\\"GPA.1357-7815-3377-93231\\\",\\\"packageName\\\":\\\"com.package.testgame\\\",\\\"productId\\\":\\\"100pts\\\",\\\"purchaseTime\\\":1464037549905,\\\"purchaseState\\\":0,\\\"purchaseToken\\\":\\\"koihbeblaqcpblo.AP-K1Oz--Grhs2FBiwsmKriwu8oYMPLjXrBzBbOs0FiLK4KeUeZ\\\"}\",\"signature\":\"fy45IekU73QBeeDpEFL05qbS\\/TSWA9io23HxfVyaCfOziXe7+5JfxrKSW1H43jTOf8BYw3E7Q==\"}"}
The JSON in the payload has incorrect backslashes (I marked some in red). Which could be the result of escaping the double quotes somewhere in the Unity code. On Android, the purchase gets logged also before it is passed to the ProcessPurchase function, at which time the whole JSON is perfectly fine.
I would like to solve this problem to be able to parse the payload to do server side verification. I already tried the latest beta, but that gave the same result. Also started a whole new project with only the IAP code. The same happens in the IAP Demo scene. I could manually remove the backslashes, but I would much rather find a real fix. If there is no such thing possible on my end, should i send in a bug report for this?
Thanks a lot for the help.