Interface PurchaseManager
- All Superinterfaces:
InformationFinder
Items for purchase are referenced by an item identifier integer value. Make sure to register the same identifier on all the IAP services desired for easy porting. The same identifier should be registered in the IAP item setup screen of each IAP service (Google Play IAP, Amazon IAP, iOS IAP, Apple Mac Store IAP, Steam etc). For stores that support textual item identifiers (most of them except Steam) prefix a "item_" before the item identifier number.
Please note due to limitations by the various IAP services you need to manage identifiers on your own. It is not possible for example to retrieve the IAP item list for all the stores. It is also not possible to store icons, downloadable content etc. in some IAP services. Icons and downloadable content have to be either integrated into your application or served by a separate server that you setup. Your application is responsible to display the items for purchase.
-
Method Summary
Modifier and TypeMethodDescriptionvoiddispose()Disposes the purchase manager.voidinstall(PurchaseObserver observer, com.badlogic.gdx.pay.PurchaseManagerConfig config, boolean autoFetchInformation) Registers a purchase observer which handles installs of apps on a new device or aborted purchases from a previous session that were not yet handled by the application.booleanReturns true if the purchase manager is installed (non-disposed) and ready to go.voidRequests to purchase an item.voidRestores existing purchases.Returns the store name.Methods inherited from interface com.badlogic.gdx.pay.InformationFinder
getInformation
-
Method Details
-
storeName
String storeName()Returns the store name. -
install
void install(PurchaseObserver observer, com.badlogic.gdx.pay.PurchaseManagerConfig config, boolean autoFetchInformation) Registers a purchase observer which handles installs of apps on a new device or aborted purchases from a previous session that were not yet handled by the application. The observer is called for all unfinished transactions. The observer is also called for refunds of previous purchased items.Registering an observer is required. If no observer is registered the call to purchase an item will fail with a runtime exception to teach you lesson to always remember to set a purchase observer. The purchase observer is needed to make sure all purchases have been handled and served to the customer.
- Parameters:
observer- The observer which is called whenever purchases have to be handled by the application as well as when the store has been installed.config- The configuration. Please note offers inside the configuration can be updated on the fly (e.g. byautoFetchInformation- tells PurchaseManager to automatically fetch offer details on setup
-
installed
boolean installed()Returns true if the purchase manager is installed (non-disposed) and ready to go. -
dispose
void dispose()Disposes the purchase manager. -
purchase
Requests to purchase an item. The listener will always be called once the purchase has either completed or failed.Note: a GDX runtime exception is thrown if you have not registered a purchase observer.
- Parameters:
identifier- The item to purchase.
-
purchaseRestore
void purchaseRestore()Restores existing purchases.
-