[Android][4.16.3][BP] Read In app purchase information incorrect/incomplete behaviour when success.

In short, the read in app purchase information is succeeding and giving the same info through BreakInAppPurchaseProductInfo wether the product has been bought or not.

  1. Set an in app product, non consumable (like a product meant to remove ads).
  2. Set a tester with license testing enabled in android in google play console, so you can test payments for in app purchases.
  3. Set the behaviour in google play console to RESPOND_NORMALLY in the license test response.
  4. Test the method, you will receive success and then print the all the info with BreakInAppPurchaseProductInfo. You will receive an empty transaction identifier and an empty Receipt data, but you will receive some other data like price and so on.
  5. Buy the game.
  6. Test the method again…you will receive, the EXACT same info than in point 4, so you cannot distinguish wether the product has been bought or not!. Yes, you can store some preferences, but that doesn’t work if you :
  7. Return the product (bought by mistake etc…)
  8. Test the method again… and you will receive a success with the, again, same info.

So, what happens when you install the game in a new device? I have no way to know the product is purchased other than trying to purchase it again (in wich case I receive an “alreadyOwned”.
This is not a big problem but certainly is an unexpected and buggy behaviour.

Any clue how to distinguish if an in app purchase of non-consumable item has been bought or not?

I had this same problem and back then i read that the solution must be implemented through plugin

Thanks, I’m going to search for some plugin (any recommendation?) and I will search for the android java code in search of the bug.

Meanwhile the only reasonable working solution I’ve found is to use preferences storage to save the product bought status.
In case a new instalation on a new device, there is no way to know so only when the user tryes to buy the product again, the bought status is detected automatically and stored in preferences… it’s not perfect and can annoy some user to have to click again in buy button to “enable” their previously paid purchase.

Just FYI,

Figured out what the problem was with UE4 and the issues getting the in app purchased items.

You just have to look at in the engine (16.3), it has the following 4 (four) callbacks:

nativeQueryComplete → when asking for the different products available has been completed
nativePurchaseComplete → when we purchased something
nativeRestorePurchasesComplete → when we restored a purchase
nativeQueryExistingPurchasesComplete → when we ask for the already purchased items!!!

Now if you look to BP available functions there are 3 (three, so one less than above) groups:

So, the issue is that ReadInAppPurchase doesn’t read other than the AVAILABLE items to purchase, it doens’t tell us the already owned items and it never will, it’s called from “nativeQueryComplete” but not from “nativeQueryExistingPurchasesComplete”.

As a conclusion, the bug here is that a BP method for the “nativeQueryExistingPurchasesComplete” callback is missing completely, although the android java part is ready and I guess working fine. So, can anyone tell me how could I create or make it appear the required BP method?

Note: as a workarround, you can manually edit the QueryInAppPurchases method in the java file to call manually the GatherOwnedPurchaseData method and append the needed info into the description field or somewhere else, so it can be later parsed and identified (I append an “[OWNED]” string to identifiers and parse the identifiers in the BP in search of that string). Kind of hacky way to solve it but no other solution found atm, and I tryed several things, including a plugin, no time to go deep into the issue but it should be addressed as a mayor bug for android target (as it affects monetization).

You should also report this on answerhub

Yeah, I did: [BP][Android target][In App Purchases] Missing function - UE4 AnswerHub

Also, I posted the java code for the hacky-workarround here: In app purchases for Android with Unreal Engine 4.16 and Blueprints – AP

I’m hope that geting everything working on ios will be easier XD

I posted in answerhub a lot of issues. They answered “post to the new bug form”

I was experiencing the same problem, but alberto.polo’s hacky workaround worked! Thank you so much for fixing this issues that should REALLY be addressed by Epic. I’m using 4.19.2.

Anyone achieved in app purchase working ?

Hello, just saw your message now.

I’m not planning to make any tutorial in the subject, but there are plenty of them on how to make in app purchases. This post and the blog entry were just to clarify why the standard procedure -as described in many other tutorials- was not working and how to patch it, at least in version 16.3.

It’s kind of a complex procedure cos you need to understand both the android play store interface and unreal engine interface… and then patch the ue4 code!

I don’t know if this issue has been addressed in newer versions and I’m very busy atm to enjoy doing some stuff with UE.

Best regards,