IAP testing with static responses



I’m doing the last phase of my game. There will be three different coin packs in the game, continuously. I built iap into the game and wanted to test the test product ids starting with “android.test. *”. I built iap based on Defold documentation.
Based on the google documentation (https://developer.android.com/google/play/billing/billing_testing#solo) this should work without uploading the app to the play store. The result was an error:

This version of the application is not configured for market billing.

After I have found no meaning for this mistake, I uploaded the game to the play store. Testers then encountered the following error:

Error retrieving information from server. DF-DFERH-01

To continue:

Since the same error occurred with every tester, I started to suspect the Defold iap solution. After a little reverse engineering I found the cause of the error. The problem is that Google serves fake data for test product ids for both “inapp” and “subs” requests. Defold does not handle this case when the same product id can exist for “inapp” and “subs” requests.
There are four lines in the SkuDetailsThread.run method in the “com.defold.iap.IapGooglePlay” package:

JSONObject products = new JSONObject ();
addProductsFromBundle (IapGooglePlay.this.service.getSkuDetails (3, packageName, "inapp", querySkus), products);
addProductsFromBundle (IapGooglePlay.this.service.getSkuDetails (3, packageName, "subs", querySkus), products);
sr.listener.onProducts (0, products);

In my case, I just wanted to test “inapp” product ids. The first “addProductsFromBundle” call adds the data for the corresponding test product id to the “products” variable. The second “addProductsFromBundle” call (since the test product id is available for both types) overwrites them. The request to Google then goes with a “subs” type that returns an error. If I changed the type from “subs” to “inapp” before the request, the answer did not contain an error and the payment dialog appeared correctly.

I don’t know if I can actually create the same product id for managed products and subscriptions in the play console. If so, it would be useful to distinguish them in Defold.

Currently, this problem only happens to me in test product ids. In real product ids this is not a problem in my case.

However, testing with static responses is not currently working in Defold.



Interesting find! Not sure how to best solve this to be honest. Your real products work though right?



I don’t know yet. The version containing the real product ids has not yet been published on play. During debugging, I saw that the “subs” request returned an empty array (correctly because there are no subscriptions). That’s why I think it will work correctly in this case.

I primarily reported this problem because the iap manual page also mentions the ability to test static responses.

I was looking for the causes of the errors on the internet for two days, but I couldn’t find meaningful (and working) answers. Not even found in Google Docs. Only then did I suspect that there might be a problem in Defold. It was not easy to find out because it was rather elusive.