public void buyBasic()

in ClassyTaxiJava/app/src/main/java/com/sample/android/classytaxijava/ui/BillingViewModel.java [135:154]


    public void buyBasic() {
        boolean hasBasic = BillingUtilities
                .deviceHasGooglePlaySubscription(purchases.getValue(), Constants.BASIC_SKU);
        boolean hasPremium = BillingUtilities
                .deviceHasGooglePlaySubscription(purchases.getValue(), Constants.PREMIUM_SKU);
        Log.d("Billing", "hasBasic: " + hasBasic + ", hasPremium: " + hasPremium);
        if (hasBasic && hasPremium) {
            // If the user has both subscriptions, open the basic SKU on Google Play.
            openPlayStoreSubscriptionsEvent.postValue(Constants.BASIC_SKU);
        } else if (hasBasic && !hasPremium) {
            // If the user just has a basic subscription, open the basic SKU on Google Play.
            openPlayStoreSubscriptionsEvent.postValue(Constants.BASIC_SKU);
        } else if (!hasBasic && hasPremium) {
            // If the user just has a premium subscription, downgrade.
            buy(Constants.BASIC_SKU, Constants.PREMIUM_SKU);
        } else {
            // If the user dooes not have a subscription, buy the basic SKU.
            buy(Constants.BASIC_SKU, null);
        }
    }