I have project which have Google play billing lib implementation "com.android.billingclient:billing:6.0.1"

I want to introduce offers in my project check this link for more details Create and manage offers you will found "Create and manage offers"

Now, I want to know why offers are not getting applied to my subscription whose values is Rs. 1200 and if i have applied 50% off on this subscription from the developer play console then Rs. 600 payment request should be there at user side right (mobile device)?

I want to know about this process, how it's working, how to apply offers from the Console and if required specific code from the Android side then also let me know i'm eager to implement that.

Regards, Nikul V.

I have set offers in the Play Console with 50% off to Rs. 1200 Subscription plan but the same plan is not opening with Rs. 600 payment requests it's still with Rs. 1200 only.

1

There are 1 best solutions below

0
Nikul Vaghani On
billingClient!!.queryProductDetailsAsync(params) { _, p1 ->
            p1[0].subscriptionOfferDetails?.forEach {
                Log.e("buyNewSubscription", "offerId : -> " + it.offerId)
            }


            val flowParams = BillingFlowParams.newBuilder()

                val productDetailsParamsList = listOf(
                    p1[0].subscriptionOfferDetails?.get(0)?.offerToken?.let {
                        BillingFlowParams.ProductDetailsParams.newBuilder()
                            // retrieve a value for "productDetails" by calling queryProductDetailsAsync()
                            .setProductDetails(p1[0])
                            // For One-time product, "setOfferToken" method shouldn't be called.
                            // For subscriptions, to get an offer token, call ProductDetails.subscriptionOfferDetails()
                            // for a list of offers that are available to the user
                            .setOfferToken(it)
                            .build()
                    }
                )
                flowParams.setProductDetailsParamsList(productDetailsParamsList)

            billingClient!!.launchBillingFlow(requireActivity(), flowParams.build())
        }

we can retrieve product details like this. and also offertoken you need to pass like this to apply offer with your subscription.

here p1[0] is product detail object which we required to apply offer so you can check how I get product detail using Google Billing Lib api called "queryProductDetailsAsync"

Best, Nikul