Skip to main content
Samsung Developer Program

Purchase Auto-Recurring Subscription Items

The Auto Supply feature is an auto-recurring subscription item. A subscription for the gas auto supply is automatically renewed and repurchased after every specified period. You can specify the payment cycle and free trial period when you add the item in the Samsung Seller site. 

  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 using either of two IAP methods:

  • launchPurchaseFlow (shown in the previous example), 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 through 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.");