Skip to content
This repository has been archived by the owner on Apr 28, 2022. It is now read-only.

Latest commit

 

History

History
151 lines (117 loc) · 3.11 KB

README.md

File metadata and controls

151 lines (117 loc) · 3.11 KB

OpenIAB-Cordova-Plugin

OpenIAB plugin for Cordova-based frameworks

Cordova Integration

  1. Add Android platform to your project using CLI.
$ cordova platform add android
  1. Add OpenIAB plugin, referencing repo.
$ cordova plugin add https://github.com/onepf/OpenIAB-Cordova-Plugin.git
  1. Build the app.
$ cordova build
  1. Run it.
$ cordova run android

Intel XDK Integration

Import plugin

Import settings

Import settings

Plugin Usage

  1. Include script to your application.
<script type="text/javascript" src="cordova.js"></script>
  1. Simply call openiab object methods, passing callback functions.

a) Map you SKUs. This step is optional.

openiab.mapSku(function(){}, function(error){}, SKU1, openiab.STORE_NAME.GOOGLE, "sku_product");

b) Set some options.

Set store search strategy.

openiab.options.storeSearchStrategy = openiab.STORE_SEARCH_STRATEGY.INSTALLER_THEN_BEST_FIT;

Set available stores to restrict the set of stores to check.

openiab.options.availableStoreNames = [ openiab.STORE_NAME.GOOGLE, openiab.STORE_NAME.YANDEX ];

Set preferred store names (works only for store search strategy OpenIabHelper.Options.SEARCH_STRATEGY_BEST_FIT and OpenIabHelper.Options.SEARCH_STRATEGY_INSTALLER_THEN_BEST_FIT).

openiab.options.preferredStoreNames = [ openiab.STORE_NAME.GOOGLE, openiab.STORE_NAME.YANDEX ];

Set store keys.

openiab.options.storeKeys = [ [openiab.STORE_NAME.GOOGLE, 'your public key'] ];

Set verifying mode (applicable only for Google Play, Appland, Aptoide, AppMall, SlideMe, Yandex.Store).

openiab.options.verifyMode = openiab.VERIFY_MODE.SKIP;

c) Initialize plugin.

openiab.init(function(){}, function(error){}, [ "SKU1", "SKU2", "SKU3" ]);

d) Start purchase.

openiab.purchaseProduct(function(purchase){}, function(error){}, "SKU");

e) Consume consumable SKUs in order to be able to purchase it again.

openiab.consume(function(purchase){}, function(error){}, "SKU");
  1. Use additional methods to get information about SKUs and purchases.

a) Can be used any time after init is finished.

openiab.getPurchases(function(purchaseList){}, function(error){});

b) Get details of the single SKU.

openiab.getSkuDetails(function(skuDetails){}, function(error){}, "SKU");

c) Get details of the SKU list.

openiab.getSkuListDetails(function(skuDetailsList){}, function(error){}, ["SKU1", "SKU2", "SKU3"]);

Also consider to check sample application for cordova or xdk.

Data Structures

purchase =
{
    itemType:'',
    orderId:'',
    packageName:'',
    sku:'',
    purchaseTime:0,
    purchaseState:0,
    developerPayload:'',
    token:'',
    originalJson:'',
    signature:'',
    appstoreName:''
}

skuDetails =
{
  	itemType:'',
    sku:'',
    type:'',
    price:'',
    title:'',
    description:'',
    json:''
}

error =
{
    code:-1,
	message:''
}