Agentz

interface Agentz

Facade pattern - a simple interface for interacting with the main features of the Google Billing Library

Author

rjsuzuki

Functions

Link copied to clipboard
abstract fun cancelOrder(order: Orderz)

A manual option to explicitly cancel an order

Link copied to clipboard
abstract fun completeOrder(order: Orderz)

A manual option to complete an existing Order. This will call the respective function to consume, acknowledge, and/or fulfill a product.

Link copied to clipboard
abstract fun getProduct(sku: String?): Productz?

Return a product that matches the sku (product id). Null if no matching product exists.

Link copied to clipboard
abstract fun getProducts(type: Productz.Type?, promo: Productz.Promotion?): Map<String, Productz>

Return a list of validated products from the inventory. Narrow your search results by providing both or either parameters.

Link copied to clipboard
abstract fun getState(): LiveData<Clientz.ConnectionStatus>

Observe changes to the BillingClient's connection to GooglePlay from the UI thread (in an activity/fragment class). Calling this function automatically checks if client is connected and will attempt to reconnect if need be.

Link copied to clipboard
abstract fun isInventoryReadyLiveData(): LiveData<Boolean>

Checks if the billing client has products loaded. if false, use queryInventory to prepare the client for purchases.

Link copied to clipboard
abstract fun isInventoryReadyStateFlow(): StateFlow<Boolean>
Link copied to clipboard
abstract fun queryInventory(products: Map<String, Productz.Type>): QueryResult<Map<String, Productz>>

Queries database for matching product ids and loads them into the inventory cache.

Link copied to clipboard
abstract fun queryOrders(): QueryResult<Orderz>

This function should be called in the onResume lifecycle of the application/view. Amazon and Google Play use different terminology for similar use-cases, so in order to prevent confusion, this library will always define an Order as a purchase in-progress, and/or incomplete. A receipt will always be a 'completed order' (expired, canceled, or consumed). Handle purchases still remaining from recent history. Observe the liveData object that will emit Orderz objects that require your attention.

Link copied to clipboard
abstract fun queryProduct(sku: String, type: Productz.Type): QueryResult<Productz>

TODO: Implement cache-first strategy and boolean bypass parameter for it.

Link copied to clipboard
abstract fun queryReceipts(type: Productz.Type?): QueryResult<OrderHistoryz>

Returns the available history of 'completed orders' as a mapping of receipt objects. The receipts will list all relevant skus, even if that order is expired, canceled, or consumed. Set parameter to null for all products

Link copied to clipboard
abstract fun startOrder(activity: Activity?, productId: String?, options: Bundle? = null): LiveData<Orderz>

Initiate the purchase flow from the perspective of a user interaction. e.g. a Customer opens your app and selects a product for purchase.