Search code examples
androidin-app-billingsubscription

Android BillingFlowParams accept multiple subscriptions


In an attempt to display several subscription options, I don't see where I can pass an array of SkuDetails to Billing flow. Is that correct? Does the Billing UI not handle multiple SkuDetails?

Log.d(TAG_BILLING, "Getting SKU Details");
        billingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() {
            @Override
            public void onSkuDetailsResponse(BillingResult billingResult,
                                             List<SkuDetails> skuDetailsList) {
                Log.d(TAG_BILLING, "Details Returned an RC of : " + billingResult.getResponseCode());
                SkuDetails mySKU = null;
                if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && skuDetailsList != null) {
                    for (SkuDetails skuDetails : skuDetailsList) {
                        mySKU = skuDetails; // <-- Tests a single one
                        String sku = skuDetails.getSku();
                        String price = skuDetails.getPrice();
                        Log.d(TAG_BILLING, "SKU: " + sku + " and price: " + price);
                    }
                    BillingFlowParams flowParams = BillingFlowParams.newBuilder()
                            .setSkuDetails(mySKU) // <-- want to pass multiple but wont take a list
                            .build();
                    BillingResult responseCode = billingClient.launchBillingFlow(WebViewActivity.this, flowParams);                }
                else {
                    Log.d(TAG_BILLING, "NO SKU's found");
                }

            }

What am I missing to allow the UI to show multiple Subscription options?


Solution

  • What am I missing to allow the UI to show multiple Subscription options?

    The billing library does not have the means to display a list of purchase options, you have to code and display your own list

    // <-- want to pass multiple but wont take a list .build();

    Items can only be purchased one by one, so BillingFlowParams and launchBillingFlow() only accepts one sku and not a list