Cordova In-app Purchase Plugin
Last updated
Was this helpful?
Last updated
Was this helpful?
This Cordova/PhoneGap plugin is used for In-App purchases on iOS, Android and Windows apps.
Repository:
Plugin ID/package name: cordova-plugin-purchase
Tested version: "10.5.0
From the IDE menu, go to Config → Manage Cordova Plugins .
Click the Import Cordova Plugin button. Then, you can choose to import the plugin using a ZIP file or a URL/package name.
The store
API is mostly events based. As a user of this plugin, you will have to register listeners to changes happening to the products you register.
The core of the listening mechanism is the when()
method. It allows you to be notified of changes to one or a set of products using a query mechanism:
The updated
event is fired whenever one of the fields of a product is changed (its owned
status for instance).
This event provides a generic way to track the status of the purchases, to unlock features and to refresh the views accordingly.
The verbosity
property defines how much the code in the store.js
file writes to the console. Available values:
store.QUIET
or 0
to disable all logging (default)
store.ERROR
or 1
to show only the error messages
store.WARNING
or 2
to show also the warnings
store.INFO
or 3
to show also the information messages
store.DEBUG
or 4
to show also the internal debugging messages.
Example
Register a product to the store.
Parameter
Name
Type
Description
product
JSON Object
Product information
Example
Load the product data from the servers and restore whatever has already been purchased by the user.
Example
Retrieve a product by its id
or alias
.
Name
Type
Description
id
String
Product ID
alias
String
Product name
Example
Return Value
Promise
Example
Register an error handler.
Example
Register the callback to be called when the store is ready to be used.
If the store is already ready, callback is executed immediately. store.ready()
without arguments will return the ready
status.
Example
This section describes some of the main functions used in the . For complete API references, please refer to the .
Register a callback for a product related event. For more details about this api, please refer to .