Search code examples
javaandroidin-app-purchasein-app-billingin-app-subscription

Android: How to implement a variable subscription start date Google in App subscriptions


I am implementing a subscription in my app. All my users get 30days trial by default handled by my own scripts. I am trying to implement Google IAP for my app and basically want the Subscription to start when the trial ends (date from my db) or delay the start by a variable amount of day that add up to the trial end date.

I am wondering if this possible or of anyone has pointers to accomplish this.

I am using https://github.com/anjlab/android-inapp-billing-v3

and this is my create billing methods:

    public void startBilling() {
        bp = new BillingProcessor(this, getResources().getString(R.string.play_console_license), this);
        bp.initialize();
        onBillingInitialized();
    }

    public void onBillingInitialized() {

//        Log.d("MainActivity", "onBillingInitialized: ");

        String premium = getResources().getString(R.string.premium);

        TransactionDetails purchaseTransactionDetails = bp.getSubscriptionTransactionDetails(premium);
        bp.loadOwnedPurchasesFromGoogle();

        SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(this);
        String ident = pref.getString("ident", null);

        bp.subscribe(this, premium, ident);

    }

Thanks


Solution

  • You can't do it by your own.

    The only way to achieve this is by using the free trial option and configure it for 30 days (you can't make this period variable). If you want a variable period of time for your free trial, you should create as many IAP as your periods (one IAP with a 1-day-free-trial, ... one IAP with a 30-day-free-trial), but I wouldn't recommend it.

    Good chance with your implementation, In-App Subscriptions aren't easy ^^