2

Currently, I have auto renewable subscription setup. But i want to create non renewable subscription in order to subscribe again at the end each billing period.

In google play console there is no option to create non renewable subscription like iOS as follow as below.

iOS create plan page

Please guide me how to create non renewable subscription in google play console.

2 Answers 2

3

A non renewable subscription is actually a normal consumable One-time product.

the only difference between subscription and One-time product, is that the subscription is recurring (renewed)

from Google Play's billing system overview

You can use Google Play's billing system to sell the following types of digital content:

One-time products: A one-time product is content that users can purchase with a single, non-recurring charge to the user's form of payment.

One-time products can be either consumable or non-consumable:

A consumable product is one that a user consumes to receive in-app content, such as in-game currency. When a user consumes the product, your app dispenses the associated content, and the user can then purchase the item again.

A non-consumable product is a product that is purchased only once to provide a permanent benefit. Examples include premium upgrades and level packs.

Subscriptions: A subscription is a product that provides access to content on a recurring basis. Subscriptions renew automatically until they're canceled. Examples of subscriptions include access to online magazines and music streaming services.

1
  • you are welcome, was my answer useful to you?
    – Jabbar
    Nov 15, 2021 at 15:50
0

This can be helpful to you !

//First, you need to initializes
private void Initialize(){
    billingClient = BillingClient.newBuilder(context)
            .setListener(new PurchasesUpdatedListener() {
              @Override
              public void onPurchasesUpdated(@NonNull @NotNull BillingResult billingResult, List<Purchase> list) {
                // Google Play calls this to deliver the result of the purchase operation to this listener
                if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null){
                  for(Purchase purchase : list){
                    // since we have only passes a productId at LaunchPurchaseFlow
                    activity.runOnUiThread(new Runnable() {
                      @Override
                      public void run() {
                        GotPurchase(purchase);
                        if(isAutoAcknowledge && !isSubscription){
                            HandleNonConsumable(purchase);
                        }
                      }
                    });
                  }
                }else if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED){
                  activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                      PurchaseCancelled();
                    }
                  });
                }else{
                  activity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                      PurchaseFailed(billingResult.getResponseCode());
                    }
                  });
                }
              }
            })
            .enablePendingPurchases()
            .build();
  }
// To start connection
public void StartConnection(){
    billingClient.startConnection(new BillingClientStateListener() {
      @Override
      public void onBillingServiceDisconnected() {
        activity.runOnUiThread(new Runnable() {
          @Override
          public void run() {
            BillingServiceDisconnect();
          }
        });
      }
      @Override
      public void onBillingSetupFinished(@NonNull @NotNull BillingResult billingResult) {
        if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
          activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
              BillingClientReady();
            }
          });
        }
      }
    });
  }
// To launch purchase flow use this method, productId is your product id and skuType can be subs or inapp . If you need for subs then pass skuType as subs
public void LaunchPurchaseFlow(String productId, String skuType){
    String idOfProduct = isTest ? "android.test.purchased" : productId;
    isSubscription = skuType.equals(BillingClient.SkuType.SUBS);
    if(billingClient.isReady()){
      List<String> skuList = new ArrayList<>();
      skuList.add(idOfProduct);
      SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder()
              .setSkusList(skuList)
              .setType(skuType)
              .build();
      billingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() {
        @Override
        public void onSkuDetailsResponse(@NonNull @NotNull BillingResult billingResult, List<SkuDetails> list) {
          if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null){
              BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
                      .setSkuDetails(list.get(0))
                      .build();
              billingClient.launchBillingFlow(activity , billingFlowParams);
          }else{
            FailedToLaunchPurchaseFlow(billingResult.getResponseCode());
          }
        }
      });

    }else{
      OnError("Billing Client is not ready");
    }
  }

If you are doing for InApp purchase ie, either consumable or non-conumable, you should handle the purchase like this

// Consumable
public void HandleConsumable(Object purchase){
    if(purchase instanceof Purchase){
      Purchase purchase1 = (Purchase) purchase;
      if(purchase1.getPurchaseState() == Purchase.PurchaseState.PENDING){
        PurchaseStatePending();
      }else if(purchase1.getPurchaseState() == Purchase.PurchaseState.UNSPECIFIED_STATE){
        PurchaseStateUnspecified();
      }else{
        if(!purchase1.isAcknowledged()){ // TO know if payment is acknowledged, if not it means the payment is not successful/acknowledged yet.
          ConsumeParams consumeParams = ConsumeParams.newBuilder()
                  .setPurchaseToken(purchase1.getPurchaseToken())
                  .build();
          ConsumeResponseListener listener = new ConsumeResponseListener() {
            @Override
            public void onConsumeResponse(@NonNull @NotNull BillingResult billingResult, @NonNull @NotNull String s) {
              if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK){
                activity.runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                    PurchaseSuccess();
                  }
                });
              }else{
                activity.runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                    PurchaseFailed(billingResult.getResponseCode());
                  }
                });
              }
            }
          };
          billingClient.consumeAsync(consumeParams , listener);
        }
      }
    }else{
      OnError("purchase is not an instance of Purchase");
    }
  }

// Non-Consumable or Acknowledged
public void HandleNonConsumable(Object purchase){
    if(purchase instanceof Purchase){
      Purchase purchase1 = (Purchase) purchase;
      if(purchase1.getPurchaseState() == Purchase.PurchaseState.PENDING){
        PurchaseStatePending();
      }else if(purchase1.getPurchaseState() == Purchase.PurchaseState.UNSPECIFIED_STATE){
        PurchaseStateUnspecified();
      }else if(purchase1.getPurchaseState() == Purchase.PurchaseState.PURCHASED){
        if(!purchase1.isAcknowledged()){
          AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
                  .setPurchaseToken(purchase1.getPurchaseToken())
                  .build();
          AcknowledgePurchaseResponseListener listener = new AcknowledgePurchaseResponseListener() {
            @Override
            public void onAcknowledgePurchaseResponse(@NonNull @NotNull BillingResult billingResult) {
              if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK){
                activity.runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                    PurchaseSuccess();
                  }
                });
              }else{
                activity.runOnUiThread(new Runnable() {
                  @Override
                  public void run() {
                    PurchaseFailed(billingResult.getResponseCode());
                  }
                });
              }
            }
          };
          billingClient.acknowledgePurchase(acknowledgePurchaseParams , listener);
        }
      }
    }else{
      OnError("purchase is not an instance of Purchase");
    }
  }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.