Iap.list products undocumented limit

#1

Hello!
I discovered strange behavior in iap.list function. More than 20 entries of product ids trigger an error:

E/defold  ( 9303): ERROR:IAP: Failed to parse product response (0)
D/defold  ( 9303): DEBUG:SCRIPT: 
D/defold  ( 9303): { --[[0x7f4b977a20]]
D/defold  ( 9303):   error = { --[[0x7f4b977900]]
D/defold  ( 9303):     error = "failed to parse product response",
D/defold  ( 9303):     reason = 0
D/defold  ( 9303):   }
D/defold  ( 9303): }

While 20 entries or less works as expected:

D/defold  ( 8878): DEBUG:SCRIPT: 
D/defold  ( 8878): { --[[0x7f4b21da90]]
D/defold  ( 8878):   products = { --[[0x7f4b21d630]]
D/defold  ( 8878):     shop_money_01 = { --[[0x7f4b21d6c0]]
D/defold  ( 8878):       price = 2.22,
D/defold  ( 8878):       currency_code = "USD",
D/defold  ( 8878):       title = "#1 Few rubies (30)",
D/defold  ( 8878):       ident = "shop_money_01",
D/defold  ( 8878):       description = "Use to buy energy or accelerate craft",
D/defold  ( 8878):       price_string = "$2.22",
D/defold  ( 8878):       skuDetailsToken = "...some sku token..."
D/defold  ( 8878):     }
D/defold  ( 8878):   }
D/defold  ( 8878): }

Code to reproduce:

iap.list(
    {
        --doesn't matter is there unique ids or not
        --bug found on unique ids
        --just comment one random entry to get iap.list working
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
        "shop_money_01",
    },
    function(_, products, error)
        pprint({ products = products, error = error })
    end
)

Tested on Android. And I am assuming that same bug will be on IOS, because native APIs doesn’t have any limits in this functionality

3 Likes

#2

Usually, an error like this appears if a user request information for the invalid item with iap.list() (the item you don’t have in Google play console or element wasn’t activated). Could you please check the same using only valid and activated items?

1 Like

#3

From his source

--doesn't matter is there unique ids or not
--bug found on unique ids
1 Like

#4

In example I am using just one product_id but 21 times. This product_id is totally valid. And Its triggers an error. But if I request equal or less than 20 product_ids it works and responds with valid data. If i request just this one, without duplicates, the result is the same as if there will be duplicates. But in request must be less or equal than 20 elements. I already added code in project to bypass this limit with internal queue. This behavior is undocumented and seems really weird because platform APIs doesn’t have any limits in this functionality

1 Like

#5

I can’t really see in the code why it would fail on the 21’st product.
We malloc the memory, so there’s no upper limit on the buffer.
And it shouldn’t run out of memory, since it’s only 21 items.

The “response” is 0, which means that parsing went ok.
The printout comes after it figured it has 0 parsed nodes, and why that is, I don’t know.

Can you get the response after 20/21 products respectively, when doing explicit Graph API calls?

0 Likes

#6

Graph API? Did you mean Facebook Graph API? We don’t use facebook for payments. Bug reproduces on Android

1 Like

#7

There actually seems to be a 20 item limit to the getSkuDetails call:

The solution would in the case of Defold(*) be to make multiple iap.list() requests and combine the results.

* = We do plan to move iap.* into an extension and at that point open up for contributions.

1 Like

#8

Also mentioned here:

1 Like

#9

I’ve updated the IAP manual with a note mentioning this.

1 Like

#10

Heh, yeah, I think I mixed the api’s in my head a bit :slight_smile:
Would’ve thought that Android would have some testing framework similar to it though, but I guess not.

1 Like