question

Ben avatar image
Ben asked

How to validate google receipt with unreal blueprint?

Hi

I am currently trying to implemented in app purchases on my android application but i get google validation to work. what i have done is i made a purchase request then i first extracted the signature from receipt data and parse it in to the request. I however cannot seem to find the receipt json please help

unrealandroid
untitled.png (193.3 KiB)
10 |1200

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

Turner avatar image
Turner answered

In your GetSubstring node there is nothing plugged in to the Source String pin. Because of this, the signature string that is being passed into the ClientValidateGooglePurchaseRequest struct is probably empty. It might be worth running that signature through a print string to verify that it isn't an empty string.

The reason why your Receipt Data might look a bit foreign to you is because it is Base64 encoded. If you were to put your Receipt data in a Base64 decoder, it would look more like you'd expect! Though Unreal should be handling the encoding/decoding for you so you shouldn't have to worry about that.

If you are still having issues after you address the missing Source String, I'd love to see a couple more screenshots of your blueprint so we can see what's going on.

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

As I see it, receipt json should reside in the Receipt Data, what will happen if you pass it to receipt json?

7 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.

Ben avatar image Ben commented ·

when i assign receipt data to receipt json it will give out an error saying the receipt is invalid. I tried printing out the receipt data but it dose not look like the the one shown in the example that was given

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

Which example are you referring to? And, what does the receipt data you printed out look like exactly, can you share that?

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

from what i understand the receipt suppose to look something like this instead

"ReceiptJson":"{\"orderId\":\"12999763169054705758.1375794066587622\",\"packageName\":\"com.playfab.android.testbed\",\"productId\":\"com.playfab.android.permatest.consumable\",\"purchaseTime\":1410891177231,\"purchaseState\":0,\"purchaseToken\":\"eaflhokdkobkmomjadmoobgb.AO-J1OwoLkW2cqvBcPEgk6SfGceQpOHALMUFmJYeawa-GuDFtl3oKct-5D28t_KvNscFiJOFiWXIS74vJBYg-CGFJgyrdbxalKEMPzXZrg5nLomCME-jIVFAUrzcPah-_66KPImG5ftsMJKI9uzldqEF9OPcakUEmt-kWoXAsl_6-9HH0gBCwh4\"}",

In my unreal log i can see that the purchase data is the string that seems to match the one shown in the example but i have no idea how to access it. Really appreciate if you can point me in the right direction been stuck on this for awhile

1 Like 1 ·
output-ss.png (19.3 KiB)
Show more comments
Show more comments
Ben avatar image Ben commented ·

oh ok i will look into that

0 Likes 0 ·
Ben avatar image Ben commented ·

Still having trouble with this issue is there another possible method to go around validating google store receipts?

0 Likes 0 ·
ichris avatar image
ichris answered

Hi @Ben did you get this to work? I'm trying to set up Receipt Validation in Unreal but I can't find any online documentation on the Unreal Engine technical side.

If you've been successful would you mind sharing Blueprint screenshots? It would be extremely helpful.

Thank you

10 |1200

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

zhangyuejun avatar image
zhangyuejun answered

in unreal 4.25, this works,

#include "Misc/Base64.h"

.........

TSharedPtr<FJsonObject> JsonObject; TSharedRef< TJsonReader<> > Reader = TJsonReaderFactory<>::Create(InIAPProductInfo.ValidationInfo);

if (FJsonSerializer::Deserialize(Reader, JsonObject)) {

FString receiptData = FString("");

FString strsignature = FString("");

receiptData = JsonObject->GetStringField(TEXT("receiptData"));

strsignature = JsonObject->GetStringField(TEXT("signature"));

FBase64::Decode(receiptData, receiptData);

...........

Hope it helps

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.