API for managing In-App Purchases via the Big Fish Android SDK.
More...Inherits LifecycleObserver.
|
static final String | NOTIFICATION_PURCHASE_FAILED = "NOTIFICATION_PURCHASE_FAILED" |
| Purchase failed.
|
|
static final String | NOTIFICATION_PURCHASE_PRODUCTINFORMATION = "NOTIFICATION_PURCHASE_PRODUCTINFORMATION" |
| Got product information.
|
|
static final String | NOTIFICATION_PURCHASE_REVOKED = "NOTIFICATION_PURCHASE_REVOKED" |
| SKU Revoked.
|
|
static final String | NOTIFICATION_PURCHASE_SUCCEEDED = "NOTIFICATION_PURCHASE_SUCCEEDED" |
| Purchase succeeded.
|
|
static final String | NOTIFICATION_PURCHASE_SUCCEEDED_WITH_RECEIPT = "NOTIFICATION_PURCHASE_SUCCEEDED_WITH_RECEIPT" |
| Purchase succeeded with purchase object.
|
|
static final String | NOTIFICATION_RESTORE_COMPLETED = "NOTIFICATION_RESTORE_COMPLETED" |
| Restore completed.
|
|
static final String | NOTIFICATION_RESTORE_FAILED = "NOTIFICATION_RESTORE_FAILED" |
| Restore failed.
|
|
static final String | NOTIFICATION_RESTORE_SUCCEEDED = "NOTIFICATION_RESTORE_SUCCEEDED" |
| Restore succeeded.
|
|
API for managing In-App Purchases via the Big Fish Android SDK. This is a static class, so all methods are called in the following manner:
API for managing In-App Purchases via the Big Fish Android SDK.
Definition: bfgPurchase.java:52
static bfgPurchase sharedInstance()
sharedInstance
Definition: bfgPurchase.java:112
If you are using the
bfgPurchase interface, you should become an observer of the following events:
- NOTIFICATION_BILLING_INITIALIZE_SUCCEEDED
- NOTIFICATION_BILLING_INITIALIZE_FAILED
- NOTIFICATION_PURCHASE_PRODUCTINFORMATION
- NOTIFICATION_PURCHASE_PRODUCTINFORMATION_FAILED
- NOTIFICATION_PURCHASE_ASKUSER
- NOTIFICATION_PURCHASE_FAILED
- NOTIFICATION_PURCHASE_SUCCEEDED
- NOTIFICATION_RESTORE_COMPLETED
- NOTIFICATION_RESTORE_FAILED
- NOTIFICATION_RESTORE_SUCCEEDED
- NOTIFICATION_PURCHASE_SUCCEEDED_WITH_RECEIPT (Suggested use for server-side receipt verification)
- NOTIFICATION_PURCHASE_REVOKED (Amazon Only)
- NOTIFICATION_PURCHASE_CONSUMPTION_SUCCEEDED (Google Only)
- NOTIFICATION_PURCHASE_CONSUMPTION_FAILED (Google Only)
- NOTIFICATION_POST_CURRENT_INVENTORY_SUCCEEDED (Google Only; only when retrieving Google inventory)
- NOTIFICATION_POST_CURRENT_INVENTORY_FAILED (Google Only; only when retrieving Google inventory)
◆ acquireProductInformation() [1/3]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.acquireProductInformation | ( | | ) | |
| abstract |
acquireProductInformation acquireProductInformation is used when productInformation does not return any data.
- Returns
- Boolean true is request for product information sent, false if the user is offline.
◆ acquireProductInformation() [2/3]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.acquireProductInformation | ( | @NonNull List< String > | productIds | ) | |
| abstract |
acquireProductInformation is used when productInformation does not return any data.
- Parameters
ArrayList<String> | productIds identifiers of products that was purchased in game. |
- Returns
- Boolean true is request for product information sent, false if the user is offline.
◆ acquireProductInformation() [3/3]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.acquireProductInformation | ( | @NonNull String | productId | ) | |
| abstract |
acquireProductInformation is used when productInformation does not return any data.
- Parameters
String | productId identifier of product that was purchased in game. |
- Returns
- Boolean true is request for product information sent, false is the user is offline.
◆ beginPurchase() [1/2]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.beginPurchase | ( | | ) | |
| abstract |
beginPurchase Called when a user has selected the "buy" button. Checks that purchase is possible and sends NOTIFICATION_PURCHASE_ASKUSER. The client should respond to message by prompting user with the purchase dialog.
- Returns
- Boolean true if able to begin purchase, false if not.
◆ beginPurchase() [2/2]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.beginPurchase | ( | @NonNull String | productId | ) | |
| abstract |
beginPurchase Begin a purchase of the product identified by the supplied product id. Checks that purchase is possible and sends NOTIFICATION_PURCHASE_ASKUSER. The client should respond to message by prompting user with the purchase dialog.
- Parameters
String | productId The product id to purchase. |
- Returns
- Boolean true if able to begin purchase, false if not.
◆ canStartPurchase() [1/2]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.canStartPurchase | ( | | ) | |
| abstract |
canStartPurchase Test to see if purchase of the default product can be started. Note that the method is not guaranteed to return false for a product that has already been purchased and should not be used as a substitute for maintaining a proper record of prior purchases. The purpose of the method is to determine whether the unavailability of network connectivity or the state of the SDK precludes purchase of an otherwise eligible product. The method will return false if:
- the network is unavailable,
- the SDK services are unavailable,
- a purchase of the product has been initiated and has not completed,
- restoration of prior purchases is underway,
- no product information has been retrieved for the SKU, or
- user is not signed in (Amazon only).
Tip: To find out the exact failure reason, check logcat during debug mode.
- Deprecated:\n Use bfgPurchase#canStartPurchase(String productId) instead
- Returns
- Boolean true if purchase can be started, false otherwise. /
◆ canStartPurchase() [2/2]
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.canStartPurchase | ( | @NonNull String | productId | ) | |
| abstract |
canStartPurchase Test to see if purchase of the specified product can be started. Note that the method is not guaranteed to return false for a product that has already been purchased and should not be used as a substitute for maintaining a proper record of prior purchases. The purpose of the method is to determine whether the unavailability of network connectivity or the state of the SDK precludes purchase of an otherwise eligible product. The method will return false if:
- the product id is invalid (null or empty string),
- the network is unavailable,
- the SDK services are unavailable,
- a purchase of the product has been initiated and has not completed,
- restoration of prior purchases is underway,
- no product information has been retrieved for the SKU, or
- user is not signed in (Amazon only).
Tip: To find out the exact failure reason, check logcat during debug mode.
- Parameters
productId | The product id that is being checked on. |
- Returns
- Boolean true if purchase can be started, false otherwise.
◆ cleanupService()
void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.cleanupService | ( | | ) | |
| inline |
cleanupService Clean up the service. Should be called from onDestroy.
◆ completePurchase()
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.completePurchase | ( | @NonNull String | productId | ) | |
| abstract |
Called when the user has selected to "buy." Adds the payment to SKPaymentQueue. If sent an "askuser" notification, then the code should either call "complete" or "cancel" the purchase, depending upon the user's choice. This method will send a purchase failed notification if the product is already in the active purchases list or there is no Internet connectivity.
- Parameters
String | productId of product to be purchased. |
◆ consumePurchase()
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.consumePurchase | ( | @NonNull String | productId | ) | |
| abstract |
consumePurchase
- Deprecated:\n Use finishPurchase(@Nullable String sku) instead
◆ defineConsumableSKUs()
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.defineConsumableSKUs | ( | @Nullable Set< String > | consumableSKUs | ) | |
| abstract |
defineConsumableSKUs This method is used by the application to specify the product SKUs of purchases that should be consumed automatically. The method should be called on the UI thread.
◆ finishPurchase()
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.finishPurchase | ( | @Nullable String | sku | ) | |
| abstract |
finishPurchase This method reports that a purchase has been awarded. It should be used only for SKUs that have been registered as consumable with a call to defineConsumableSKUs. The method should be called on the UI thread. NOTIFICATION_PURCHASE_CONSUMPTION_SUCCEEDED is sent if the purchase was finished successfully. NOTIFICATION_PURCHASE_CONSUMPTION_FAILED is sent otherwise.
- Parameters
String | sku The SKU for a purchase that the application has successfully awarded to the user. |
◆ getAppstoreName()
abstract String com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.getAppstoreName | ( | | ) | |
| abstract |
getAppstoreName Gets the name of the app store. This should return either "google" or "amazon".
- Returns
- String "google" or "amazon".
◆ getCurrentUser()
abstract String com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.getCurrentUser | ( | | ) | |
| abstract |
getCurrentUser getCurrentUser Gets the current user identifier. This is typically only used by Amazon In-App
Purchase.
- Returns
- String userId, the current user id or null.
◆ getPurchaseStatus()
HashMap< String, Object > com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.getPurchaseStatus | ( | @NonNull String | productId | ) | |
| inline |
Get status of most recent purchase attempt for a product.
- Parameters
productId | Product ID (SKU) to get status for |
- Returns
- Dictionary of purchase status information for the product. The contents of the dictionary include all the keyed/value pairs defined by PurchaseStatus.Key, including: Key.PRODUCT_ID/String, Key.IS_SUCCESSFUL/Boolean, Key.IS_CANCELED/Boolean, Key.IS_RESTORED/Boolean, Key.ERROR_CODE/String
◆ getVolatileInventory()
abstract PublicInventory com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.getVolatileInventory | ( | | ) | |
| abstract |
getVolatileInventory Returns the
PublicInventory, which is an instance of AmazonInventory or GoogleInventory.
- Returns
- The PublicInventory instance associated with the store or null.
◆ handleActivityResult()
boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.handleActivityResult | ( | int | requestCode, | | | int | resultCode, | | | @Nullable final Intent | data | | ) | | |
| inline |
handleActivityResult Handles the onActivityResult case. Returns true if handled fine. Returns false if the activity result was not handled. In the false condition, users should handle the result themselves.
- Parameters
requestCode | integer request code passed from onActivityResult. |
resultCode | integer result code passed from onActivityResult. |
data | Intent object passed from onActivityResult. |
- Returns
- Boolean true if activity result handled, false if unhandled.
NOTE: This method is obsolete and no longer used
◆ postCurrentInventory()
abstract boolean com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.postCurrentInventory | ( | | ) | |
| abstract |
postCurrentInventory postCurrentInventory is used to initiate asynchronous retrieval of a GoogleInventory object from Google Play services. If the retrieval is successful, the inventory will be placed in the argument of a NOTIFICATION_POST_CURRENT_INVENTORY_SUCCEEDED notification.
- Returns
- True if retrieval could be initiated, false if a network connection was unavailable.
◆ productInformation() [1/2]
abstract Hashtable< String, Object > com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.productInformation | ( | | ) | |
| abstract |
productInformation productInformation
- Returns
- Hashtable<String, Object> of SKUs mapped to their respective item information or null.
◆ productInformation() [2/2]
abstract Hashtable< String, Object > com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.productInformation | ( | @NonNull String | productId | ) | |
| abstract |
productInformation productInformation
- Parameters
String | productId. The product id to get the information for. |
- Returns
- Hashtable<String, Object> of SKUs mapped to their respective item information or null.
◆ restorePurchase() [1/3]
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.restorePurchase | ( | | ) | |
| abstract |
restorePurchase Call if the user asks to restore previous purchase of default SKU. This sends a NOTIFICATION_RESTORE_SUCCEEDED with default SKU if the product identified by that SKU has been purchased. After receiving that notification, credit the user with the item. The method will send NOTIFICATION_RESTORE_COMPLETED if the call completes successfully, regardless of whether the product has been purchased. If the method does not complete successfully, it will send NOTIFICATION_RESTORE_FAILED.
◆ restorePurchase() [2/3]
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.restorePurchase | ( | @NonNull List< String > | productIds | ) | |
| abstract |
restorePurchase Call if the user asks to restore previous purchases. This sends a NOTIFICATION_RESTORE_SUCCEEDED with the SKU input for each purchase that can be restored. After receiving each NOTIFICATION_RESTORE_SUCCEEDED notification, credit the user with the appropriate item, based on the SKU in the notification's argument. This is the preferred API to call if the application needs to restore purchases for multiple SKUs. The method will send NOTIFICATION_RESTORE_COMPLETED if the call completes successfully, regardless of whether any products have been purchased. If the method does not complete successfully, it will send NOTIFICATION_RESTORE_FAILED.
- Parameters
String | productId. The product to restore. |
◆ restorePurchase() [3/3]
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.restorePurchase | ( | @NonNull String | productId | ) | |
| abstract |
restorePurchase Call if the user asks to restore a previous purchase. This sends a NOTIFICATION_RESTORE_SUCCEEDED with the SKU input if the purchase can be restored. After receiving that notification, credit the user with the item. This is the preferred API to call if the application needs to restore purchases for only one SKU. In that case, you will usually specify a product SKU that was defined by your producer. The method will send NOTIFICATION_RESTORE_COMPLETED if the call completes successfully, regardless of whether the product has been purchased. If the method does not complete successfully, it will send NOTIFICATION_RESTORE_FAILED.
- Parameters
String | productId. The product to restore. |
◆ resumeUsingService()
void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.resumeUsingService | ( | | ) | |
| inline |
resumeUsingService Resume the service, should be called from onResume.
◆ setCurrentUser()
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.setCurrentUser | ( | @Nullable String | userId | ) | |
| abstract |
setCurrentUser Mutator for current user identifier. This is typically only used by Amazon In-App
Purchase.
- Parameters
String | userId, the current user id. |
◆ setCurrentUserMarketplace()
abstract void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.setCurrentUserMarketplace | ( | @Nullable String | userMarketplace | ) | |
| abstract |
setCurrentUserMarketplace Mutator for current user marketplace. this is typically only used by Amazon In-App
Purchase.
- Parameters
String | userMarketplace, the current user data object. |
◆ setupService()
void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.setupService | ( | @NonNull Activity | activity | ) | |
| inline |
Initial setup of purchase system. Called once per activity creation
- Parameters
activity | Activity that will process purchase requests and completions |
◆ sharedInstance()
static bfgPurchase com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.sharedInstance | ( | | ) | throws IllegalStateException |
| inlinestatic |
sharedInstance Gets the singleton shared object.
bfgManager instantiates the
bfgPurchase object depending on which store you are targeting. In bfg_config.json, specify "google" or "amazon" for the "core/app_store" key. If the key is missing or is otherwise unintelligible, it will default to "google".
- Returns
- bfgPurchase returns the non-null singleton shared object.
- Exceptions
IllegalStateException | if bfgManager has not been initialized. |
◆ stopUsingService()
void com.bigfishgames.bfglib.bfgpurchase.bfgPurchase.stopUsingService | ( | | ) | |
| inline |
stopUsingService Stop using the service, should be called from onPause.