Skip to main content
Samsung Developer Program

Initializing OpenIAB for Your Service App Environment

Use the following procedure to initialize OpenIAB for your service app environment. 

OpenIAB Options can be specified in an OpenIabHelper.Options.Builder instance. To customize options for initializing OpenIAB, start by creating an OpenIabHelper.OptionsBuilder instance inside the onCreate() method of MainActivity.java. Create an OpenIabHelper instance using the builder instance as a parameter.

MainActivity.java
public void onCreate(Bundle savedInstanceState) {
    ...
    OpenIabHelper.Options.Builder builder = new
        OpenIabHelper.Options.Builder().setStoreSearchStrategy(OpenIabHelper.Options.SEARCH_STRATEGY_BEST_FIT).setVerifyMode
        (OpenIabHelper.Options.VERIFY_SKIP);
    mHelper = new OpenIabHelper(this, builder.build());
    ...
    }
}

NOTE: To determine the app store to purchase an item from, certain option settings are used which can override and be overridden by other factors. For details, see Determining the App Store.

verifyMode

Controls whether or not to base the item purchase app store determination on the following factors: app store specified in availableStoreNames, availableStores, and/or preferredStores; store key (RSA key) support, required Android manifest permissions, required classes. 

NOTE: Samsung IAP does not support store keys.

  VERIFY_SKIP Do NOT base app store determination on factors.
  VERIFY_EVERYTHING Consider only those app stores that meet the factors. Do not consider those that do not meet the factors and throw an exception.
  VERIFY_ONLY_KNOWN Consider only those app stores that meet the factors. Do not consider those that do not meet the factors but do NOT throw an exception.
 
OpenIabHelper.Options.Builder().setVerifyMode(OpenIabHelper.Options.VERIFY_SKIP)
availableStoreNames App stores (specified in a string array) that under any condition are NOT to be subject to storeSearchStrategy filtering when determining the app store to be used.
  [App store name(s)] App store name(s) in a string array
 
OpenIabHelper.Options.Builder().addAvailableStoreNames(new String[]{OpenIabHelper.NAME_SAMSUNG})
availableStores

App stores (as AppStore objects) that under any condition are NOT to be subject to storeSearchStrategy filtering when determining the app store to be used.

OpenIabHelper.Options.Builder().addAvailableStores(new SamsungApps(this, new OpenIabHelper.
Options()));
preferredStoreNames App stores (specified in a string array) that under any condition are NOT to be subject to storeSearchStrategy filtering when determining the app store that an item is to be purchased from.
  [App store name(s)] Any store name(s) in a string array
 
OpenIabHelper.Options.Builder().addPreferredStoreName(new String[]{OpenIabHelper.NAME_SAMSUNG})
storeSearchStrategy Controls how to determine the app store an item is to be purchased from or that the billing is not supported:
  INSTALLER

Default. Purchase the item either: from the app store that the app was downloaded from, or from the app store specified when side loading via ADB (if supported).

If such an app store does not exist, billing is not supported.

OpenIabHelper.Options.Builder().setStoreSearchStrategy(OpenIabHelper.
Options.SEARCH_STRATEGY_INSTALLER)
  BEST_FIT

Purchase the item from the best app store as determined by app stores with billing available, as specified by checkInventory

If such an app store does not exist, billing is not supported.

OpenIabHelper.Options.Builder().setStoreSearchStrategy(OpenIabHelper.
Options.SEARCH_STRATEGY_BEST_FIT)
  INSTALLER_THEN_BEST_FIT

Follow the process:

  • Purchase the item from either: the app store that the app was downloaded from, or from the app store specified when side loading via ADB (if supported); or
  • When an app store cannot be determined above, purchase the item from the best app store as determined by app stores with billing available, as specified by checkInventory; or
  • If such an app store does not exist, billing is not supported.
OpenIabHelper.Options.Builder().setStoreSearchStrategy(OpenIabHelper.
Options.SEARCH_STRATEGY_INSTALLER_THEN_BEST_FIT)
checkInventory Controls how to determine the app store an item is to be purchased from or that the billing is not supported:
  true Purchase the item from the app store the user most recently purchased an item from and use that app store for the rest of the session OR billing is not supported because the user never purchased any item from any of the app stores being considered.
  false

Default. Purchase the item from the first app store with available billing OR a "billing not supported" error is thrown because there are no app stores in the list with available billing. 

This method makes app store selection faster but risks being unable to find a suitable app store.

 
OpenIabHelper.Options.Builder().setCheckInventory(true)

For testing purposes, the Samsung Galaxy Apps Store can be forced to be selected. This is done through the following method:

SamsungApps.isSamsungForced = true;

If the parameter is set to true, the Samsung Galaxy Apps Store is selected during Open IAB initialization.

SamsungApps.isSamsungForced = true

If the parameter is set to false, the app store is selected depending on the options specified.

SamsungApps.isSamsungForced = false;

 

 

 

 

 

 

 

 

    • Was this article helpful?