2

Im using in-app subscription in my application. there are 3 subscription available in application i.e, monthly, 6 month and yearly. If user subscribed with monthly I'm showing upgrade subscription on some point. If user try to upgrade its upgrading but after it show pop-up (We are unable to change your subscription plan. Manage subscriptions).But I'm able to get new token and subscription info from the interface(onPurchasesUpdated). Here is the code below using for upgrade.enter image description here

billingClient.querySkuDetailsAsync(params.build()
            ) { billingResult, skuDetailsList ->
                try {
                    if (skuDetailsList != null && skuDetailsList.isNotEmpty() && skuDetailsList.size > 0) {
                        val billingFlowParams = BillingFlowParams.newBuilder()
                                .setSubscriptionUpdateParams(BillingFlowParams.SubscriptionUpdateParams.newBuilder()
                                        .setOldSkuPurchaseToken(token)
                                        .setReplaceSkusProrationMode(IMMEDIATE_WITHOUT_PRORATION).build())
                                .setSkuDetails(skuDetailsList[0])
                                .build()
                        val responseCode = billingClient.launchBillingFlow(requireActivity(), billingFlowParams)
                    } else {
                        CommonUtil.toastShow(requireActivity(), getString(R.string.something_went_wrong))
                    }
                } catch (e: NullPointerException) {
                    CommonUtil.toastShow(requireActivity(), getString(R.string.something_went_wrong))
                }

0

Your Answer

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

Browse other questions tagged or ask your own question.