Skip to content

module InAppBilling.API

Mohammad Naghavi edited this page Jul 4, 2014 · 25 revisions

Class: module:InAppBilling

module:InAppBilling

new module:InAppBilling()

Source:

Members

ERR_INVALID_PRODUCT_ID

invalid product id passed

Source:

ERR_INVALID_PURCHASE_ID

invalid purchase id passed

Source:

ERR_PRODUCT_NOT_LOADED

the prduct to be bought is not loaded

Source:

Methods

buy(success, fail, productId)

Buy or subscribe to an item. The product should be loaded before this call. You can either load items at init or by calling loadProductDetails.

Parameters:
Name Type Description
success buySuccessCallback

the callback for successful purchse

fail errorCallback

the callback for failed purchase

productId string

the product's ID to be bought

Source:

consumeProduct(success, fail, productId)

Consume an item. The product should be of consumable type.

Parameters:
Name Type Description
success consumeProductSuccessCallback

callback for successful consumption

fail type

callback for failed consumption

productId type

id of the already bought product (not the purchase itself)

Source:

getLoadedProducts(success, fail)

Get all the loaded products. Products should be loaded before this call. You can either load items at init or by calling loadProductDetails.

Parameters:
Name Type Description
success getLoadedProductsSuccessCallback

callback for successful query

fail errorCallback

callback for failed query

Source:

getPurchases(success, fail)

This will return bought products in a chronological order (oldest first) that are not cunsumed or the subscriptions that are not expired. Following items will not appear on this list: - consumable products which has been consumed - products which have been cancelled (as possible in iOS) - subscriptions that are expired

This is best practice to always look at this list on startup to activate products in your application.

Parameters:
Name Type Description
success getPurchasesSuccessCallback
fail errorCallback
Source:

getVerificationPayload(success, fail, purchaseId)

This will return a verification payload for one purchase. Depending on the platform it means either the purchaseToken of one single purchase (on PlayStore) or the application receipt (on iTunes).

Parameters:
Name Type Description
success type
fail type
purchaseId type
Source:

init(success, fail, options, productIds)

This initiates the plugin, you can optionally pass in one or multiple product IDs for their details to be loaded during initialization.

Parameters:
Name Type Description
success initSuccessCallback

the success callback

fail errorCallback

the failure callback

options Object

options for configuring the plugin

Properties
Name Type Argument Description
showLog Boolean <optional>

[true] wether to show logs or not, this is strongly recommended to be set to false for production

productIds Object

an optional list of product IDs to load after initialization was successful

Source:

loadProductDetails(success, fail, productIds)

Get details for a list of product ids. This will also load the products' details if they are not already loaded. Will only return the product details for the valid product ids. Will also return the items which have been loaded

Parameters:
Name Type Description
success loadProductDetailsSuccessCallback

callback for successful query

fail errorCallback

callback for failed query

productIds String | Array.<String>
Source:

<private> log(msg)

This function accepts and outputs all the logs, both from native and from JS this is intended to make the debuging easier, you only need to have access to JS console output.

Parameters:
Name Type Description
msg String
Source:

restore(success, fail)

on iOS: Asks store to re-queue previously processed transactions. Use this with caution and don't call it again until you get the callback either on success or on failure.

on Android: This will do the same as getPurchases

Parameters:
Name Type Description
success restoreSuccessCallback
fail errorCallback
Source:

Generated with wicked.
  • Installation
  • [Stores setup](Stores setup)
  • [Purchase verification](Purchase verification)
  • [Testing plugin](Automatic tests)
  • [API documentation](API documentation)
  • Debugging

Philosophy

  • Roadmap
  • [Compatibility issues](Compatibility issues)

API

Clone this wiki locally