In-App Products Module for Android

API Docs for: 1.0.2
Show:

InAppProductsModule Class

Module: Readme

Methods

getProducts

(
  • params
)
Boolean

Available since 1.0.0

Provides details of a list of products referenced by SKUs. A maximum of 20 SKUs can be submitted at a time.

The result of this operation is reported via the receivedProducts event.

Parameters:

  • params Object

    An object with the following properties:

    • SKUs Array of Strings

Returns:

Boolean:

true if the product request was started successfully.

getPurchases

() Boolean

Available since 1.0.0

Returns the products currently owned (purchased but not consumed) by the user.

The result of this operation is reported via the receivedPurchases event.

Returns:

Boolean:

true if the request was started successfully.

getSupportStatus

() Number

Available since 1.0.0

Determines whether billing is supported. Note that the return value is a number, not a simple boolean. On Android, billing may be supported independently for one-time and subscription type items. For sake of simplicity, this function checks both and returns a single number that indicates the level of support. Use the SUPPORT_STATUS_NONE, SUPPORT_STATUS_ONE_TIME, SUPPORT_STATUS_SUBSCRIPTION, SUPPORT_STATUS_ALL, and SUPPORT_STATUS_ERROR constants to interpret the returned value.

Returns:

Number:

See the SUPPORT_STATUS_* constants for possible values.

Properties

autoCompletePurchases

Boolean read-only

Available since 1.0.0

On iOS, this property defines whether the module will automatically mark the purchases completed. On Android, this is a read-only property whose value is always true -- it is only present to enhance parity between the two platforms. We chose true as the constant value of this property because on Android there is no need/ability to separately complete purchases; they are essentially always auto-completed.

state

Number read-only

Available since 1.0.0

The state of the module. Possible values are STATE_NOT_READY and STATE_READY.

On Android, the module is not immediately ready when it's loaded because it needs to start the billing service, and it may go back to a "not ready" state later if the service is stopped. The app must wait for a stateChange event with the state set to STATE_READY before it can use the services of the module.

Constants

ITEM_TYPE_ONE_TIME

String

Available since 1.0.0

One of the possible product types, to be used in a call to the InAppProductsModule/purchase:method method.

ITEM_TYPE_SUBSCRIPTION

String

Available since 1.0.0

One of the possible product types, to be used in a call to the InAppProductsModule/purchase:method method.

PURCHASE_STATE_CANCELED

Number

Available since 1.0.0

One of the possible values of the state property of Purchase objects.

PURCHASE_STATE_PURCHASED

Number

Available since 1.0.0

One of the possible values of the state property of Purchase objects.

PURCHASE_STATE_REFUNDED

Number

Available since 1.0.0

One of the possible values of the state property of Purchase objects.

RESULT_BILLING_UNAVAILABLE

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_DEVELOPER_ERROR

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_ERROR

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_EXCEPTION

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_ITEM_ALREADY_OWNED

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_ITEM_NOT_OWNED

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_ITEM_UNAVAILABLE

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_OK

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_SERVICE_UNAVAILABLE

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

RESULT_USER_CANCELED

Number

Available since 1.0.0

One of the possible values of the result field in various events and callback parameters.

STATE_NOT_READY

Number

Available since 1.0.0

One of the possible values of the state property.

This value means that module not ready to be used.

STATE_NOT_SUPPORTED

Number

Available since 1.0.1

One of the possible values of the state property.

This value means that the app is running in the simulator. This module provides functionality that will not work in the simulator. Please run your tests on an actual device.

STATE_READY

Number

Available since 1.0.0

One of the possible values of the state property.

This value means that module is ready to be used.

SUPPORT_STATUS_ALL

Number

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that all the product types are supported.

SUPPORT_STATUS_ERROR

Number

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that an error occurred while querying the support status.

SUPPORT_STATUS_NONE

Number

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that none of the product types are supported.

SUPPORT_STATUS_ONE_TIME

Number

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that one-time product types are supported.

SUPPORT_STATUS_SUBSCRIPTION

Number

Available since 1.0.0

One of the possible values returned by the getSupportStatus method.

This value means that subscription product types are supported.

Events

purchaseConsumed

Available since 1.0.0

This event returns the result of a consume call.

Event Payload:

  • purchase Purchase

    The Purchase object that this event relates to.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorMessage String

    The error message; only present if an exception (that is, a specific type of error) occurred.

purchaseUpdate

This event is fired when the state of a purchase changes. This can happen after a call to the getPurchases or purchase function.

Event Payload:

  • purchase Purchase
  • errorCode Number

    The error code; only present if an error occurred.

  • errorMessage String

    The error message; only present if an exception occurred.

receivedProducts

Available since 1.0.0

This event returns the result of a getProducts call.

Event Payload:

  • products Array of Products

    An array of Product objects.

  • invalid Array of Strings

    An array of strings holding those product identifiers that were passed on to the getProducts function but are not valid.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorMessage String

    The error message; only present if an exception (that is, a specific type of error) occurred.

receivedPurchases

Available since 1.0.0

This event returns the result of a successful getPurchases call.

Event Payload:

  • purchases Array of Purchases

    An array Purchase objects.

  • errorCode Number

    The error code; only present if an error occurred.

  • errorMessage String

    The error message; only present if an exception occurred.

stateChange

Available since 1.0.0

Notifies the app about a change in the state of the module. See the state property for more information.

Event Payload:

  • state Number
  • errorCode Number
  • errorMessage String