Skip to main content

Ready to market your stellar app?

Samsung Developer Program is your gateway to app monetization success.

Learn More

Samsung Developer Program

Purchasing Auto-Recurring Subscription Items

The Auto Supply feature of this application is of the auto-recurring type. This means that the subscription for the gas auto supply is automatically renewed and repurchased after every specified period. The payment cycle and free trial period can be specified when you add the item in the Samsung Seller site. 


Purchasing an Auto-Recurring Subscription Item
  1. In the Trivial Drive UI, click AUTO SUPPLY (ARS).
  2. The button click invokes the function onAutoSupplyButtonClicked() of, which calls OpenIabHelper.launchPurchaseFlow(). InAppConfig.SKU_AUTO_SUPPLY is specified as a parameter.
public void onAutoSupplyButtonClicked(View arg0) {
    if (setupDone == null) {
        complain("Billing Setup is not completed yet");
    if (!setupDone) {
        complain("Billing Setup failed");
    if (!mHelper.subscriptionsSupported()) {
        complain("Subscriptions not supported on your device yet. Sorry!");
    String payload = " ";
    Log.d(TAG, "Auto Supply Subscription");
    mHelper.launchPurchaseFlow(this, InAppConfig.SKU_AUTO_SUPPLY, IabHelper.ITEM_TYPE_SUBS, RC_REQUEST, 
            mPurchaseFinishedListener, payload);

Subscription items can be purchased via 2 IAP methods:

  • launchPurchaseFlow (above) which requires explicitly stating the item type (IabHelper.ITEM_TYPE_SUBS)
  • launchSubscriptionPurchaseFlow(), which automatically has the type IabHelper.ITEM_TYPE_SUBS.


  1. OpenIabHelper.launchPurchaseFlow() calls the launchPurchaseFlow() function of
public void launchPurchaseFlow(Activity act, @NotNull String sku, String itemType, int requestCode, 
                        IabHelper.OnIabPurchaseFinishedListener listener, String extraData) {
    appStoreBillingService.launchPurchaseFlow(act, SkuManager.getInstance().getStoreSku(appstore.getAppStoreName(), sku), 
                        itemType, requestCode, listener, extraData);


  1. AppStoreInAppBillingService.launchPurchaseFlow() is invoked, which starts the billing service for the chosen app store. For Samsung, SamsungAppsBillingService.launchPurchaseFlow() is invoked.
public void launchPurchaseFlow(@NotNull Activity activity, @NotNull String sku, String itemType, int requestCode, 
                        OnIabPurchaseFinishedListener listener, String extraData) {
    String itemGroupId = getItemGroupId(sku);
    String itemId = getItemId(sku);
    Bundle bundle = new Bundle();
    bundle.putString(KEY_NAME_THIRD_PARTY_NAME, activity.getPackageName());
    /* If 12-digit itemGroupId is specified in SKU mapping, bundle will include itemGroupId. If itemGroupId is not specified, 
    third-party package name will be used. (Samsung IAP v3.0) */
    if(!itemGroupId.isEmpty()) {
        bundle.putString(KEY_NAME_ITEM_ID, itemGroupId);
    bundle.putString(KEY_NAME_ITEM_ID, itemId);
    Logger.d("launchPurchase: itemGroupId = ", itemGroupId, ", itemId = ", itemId);
    ComponentName cmpName = new ComponentName(SamsungApps.IAP_PACKAGE_NAME, PAYMENT_ACTIVITY_NAME);
    Intent intent = new Intent(Intent.ACTION_MAIN);
    mRequestCode = requestCode
    mPurchaseListener = listener;
    purchasingItemType = itemType;
    mItemGroupId = itemGroupId;
    mExtraData = extraData;
    Logger.d("Request code: ", requestCode);
    activity.startActivityForResult(intent, requestCode);


  1. After a successful purchase, the result is sent back to via the IabHelper.OnIabPurchaseFinishedListener.
 IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
     public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
         else if (purchase.getSku().equals(InAppConfig.SKU_AUTO_SUPPLY)) {
                 // Bought the auto supply gas subscription
             Log.d(TAG, "Auto supply subscription purchased.");

  • Was this article helpful?