question

Justin avatar image
Justin asked

Does ValidateGooglePlayPurchase require a UnityIAP Receipt to be Parsed before sending?

Does ValidateGooglePlayPurchase require a UnityIAP Receipt to be Parsed before sending?

I read the following question and followed the link.

https://community.playfab.com/questions/957/211251827-Using-Unity-IAP-need-help-validating-.html

It suggests that the receipt coming from UnityIAP would have to be parsed before sending it to PlayFab for validation. Is that still true or is that method outdated?

It seems like the documentation here, https://api.playfab.com/documentation/Client/method/ValidateGooglePlayPurchase#request-properties , requires the "Original" receipt returned from Google is what needs to be sent.

So, when I build the ValidateGooglePlayPurchaseRequest I pass the PurchaseEventArgs "arg.purchasedProduct.receipt" into the "ReceiptJson" field. Using Android Studio Logcat and a Google Nexus 5, I can see my flow works as intended (google purchase works and returns a proper successful purchase reply). However, the Validation fails, so I looked at the events on PlayFab Playstream and in the info feild for the Validation request the "ReceiptJson" field shows up but the data has many extra //// in the body of the receipt compared to the Google Play receipt in the valid purchase response. So I am not sure what is happening but obviously with the extra //// everywhere the Validation will fail.

If Unity IAP args.purchasedProduct.receipt is not the "Original", then I can only assume that what is meant by the "Original" is actually when using Google Play Billing which requires Javascript to interact with.

So, do I need to to parse the Unity IAP receipt and then feed it into the request fields?

I can post my code here or give an idea of my purchase flow if needed.

Here is the Logcat of the Google purchaseData and the receipt I get from UnityIAP..

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

·
Andy avatar image
Andy answered

I'm not sufficiently familiar with UnityIAP to know for sure whether the receipt they provide is exactly what we expect. Based on the screenshot you provided, though, we expect something that looks like the "Purchase data". It looks like the receipt provided by Unity IAP may be wrapping that in some additional context that we don't expect.

We expect a Google Play Receipt to look something like this (after being turned into a string):

"ReceiptContent": "{\"orderId\":\"GPA.1111-1111-1111-11111\",\"packageName\":\"com.your.domain\",\"productId\":\"yourProductId\",\"purchaseTime\":1544226568937,\"purchaseState\":0,\"developerPayload\":\"{\\\"developerPayload\\\":\\\"\\\",\\\"is_free_trial\\\":false,\\\"has_introductory_price_trial\\\":false,\\\"is_updated\\\":false}\",\"purchaseToken\":\"lmobpkheflecbmcfmdhgeckb.AO-K1Owbh66GcRNQ019ipb7_UYBQO07KHU4cocdbIpmYOG-MkENsyR17kw3os-dRVzL9PkNSkuM5QQX9fygVOS5YWvr1oAfMRhkno3fWAoSBKzVvcohEagAmhObXnvcDWLoDuAcngvtPY87p0dv4B6YmE3oipogKo6-iBOFV-0_y_HRkzDJ0o8Q\"}"
1 comment
10 |1200

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

Justin avatar image Justin commented ·

Just a follow up for this. In the first link I provided Brendan gave this link: http://answers.unity3d.com/questions/1191677/getting-unity-iap-receipt-data-to-validate-with-pl.html which IS still a valid way to get the correct info when using UnityIAP.

I can only assume that other IAP packages are doing the same but directly from Google Billing. I only have experience with C# so I am stuck using a middle man IAP for now. UnityIAP seems to be working good for our needs at this time.

0 Likes 0 ·

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.