IAP Manager - Easier In App Purchases for Google Play and Apple App Store

If you are planning to add IAPs to your game have a look at this module as an option to use if your needs are simple / use it as a supplement to existing examples and documentation on IAP.

There are no docs right now, just look at the example/source to see how it works. The main thing about it is if you use the same product ids for Google Play and Apple App Store it should just work.

This only has support for Google Play and Amazon App Store, but everything else could be added. Pull requests welcome!

9 Likes

Hello, i’ve some problem with this example.
I tried to bundle it for Android (with no changes) and it failed with following error:

/extension-iap/src/iap_android.cpp
    	Line 310: too few arguments to function call, expected 5, have 3
            dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails
            ~~~~~~~~~~~~~~~~~~~                      ^
    	Line 310: 'JsonToLua' declared here
        int JsonToLua(lua_State* L, dmJson::Document* doc, int index, char* error_str_out, size_t error_str_size);
        ^
    	Line 346: too few arguments to function call, expected 5, have 3
                dmScript::JsonToLua(L, json, strlen(json)); // throws lua error if it fails
                ~~~~~~~~~~~~~~~~~~~                      ^
    	Line 346: 'JsonToLua' declared here
        int JsonToLua(lua_State* L, dmJson::Document* doc, int index, char* error_str_out, size_t error_str_size);
        ^
    warning: [options] bootstrap class path not set in conjunction with -source 8
	Note: /tmp/job3777207153139679010/upload/extension-iap/src/java/com/defold/iap/IapGooglePlay.java uses unchecked or unsafe operations.
	Note: Recompile with -Xlint:unchecked for details.
	For the full log, see /home/admin/iap_manager-master/build/armv7-android/log.txt

I also tried to implement extension_iap library to my game project and it gave to me the same error message while bundling. Don’t you know, what’s wrong?
Thank you (-:

@kovarskic if you are using the one of the more recent versions of extension-iap (Releases · defold/extension-iap · GitHub) they only work with Defold 1.4.0 and above. Which version of Defold and extension-iap are you using?

…yes, it was the problem. I updated from 1.3.6 and now it works nicely.

2 Likes

hey @Pkeod I’m trying to understand the logic in your iap manager.

is there any reason not to do it that way? (updated lines 100-105)

elseif iap.get_provider_id() == iap.PROVIDER_ID_GOOGLE then
	if M.consumable_products[transaction.ident] then
		iap.finish(transaction) --- this
	else
		if M.VERBOSE then print("IAP Manager", "Transaction Acknolwedged") end
		iap.acknowledge(transaction)
	end
end

I see that there is a method iap_manager.get_next_consumale() that calls finishing transaction.

are there any reasons to call it for the consumable products manually rather than immediately in iap_listener() ?

update:
oh, may be auto-finish transactions in the game.projects?

It’s been a few years since I made this, and it’s possible some IAP stuff has changed too so I can’t give good answers. If you figure out what you’re trying to do please explain in another post!