Billing library 6.0 error “user not eligible” on upgrade

I have setup two subscriptions each one having one baseplan, like this

SubsA -> Monthly baseplan A

SubsB -> Yearly baseplan B

I can successfully purchase each of them. So my test setup seems to work properly.

However, when I have bought my monthly subscription and I configure an upgrade to yearly subscription I get an error “User is not eligible for this product”.

My (upgrade) code looks like this:

var billingFlowParams = BillingFlowParams.newBuilder()
    .setObfuscatedAccountId(UUID.randomUUID().toString())
    .setProductDetailsParamsList(
        listOf(BillingFlowParams.ProductDetailsParams.newBuilder()
            .setProductDetails(productlist[productId]!!.productDetails!!)
            .setOfferToken(productlist[productId]!!.offerToken!!).build()
        )
    )
    .setSubscriptionUpdateParams(
        BillingFlowParams.SubscriptionUpdateParams.newBuilder()
            // purchaseToken can be found in Purchase#getPurchaseToken
            .setOldPurchaseToken(productlist["subscription_monthly"]!!.purchaseToken!!)
            .setSubscriptionReplacementMode(ReplacementMode.WITH_TIME_PRORATION)
            .build()
    ).build()
val billingResult = billingClient.launchBillingFlow(this, billingFlowParams)

if(billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
    showBillingClientError(billingResult.responseCode)
}

I have checked that my (new) offerToken and (old) purchaseToken are correct. Please note that I have stored my products/purchases/tokens which are returned from queryProductDetailsAsync() and queryPurchasesAsync() in productlist.

What have I missed ?

  • > .setOldPurchaseToken(productlist["subscription_yearly"]!!.purchaseToken!!) if you are upgrading from the monthly subscription, is “subscription_yearly” the right key?

    – 




  • You are right it should read “subscription_monthly”. I have this code twice, once for upgrade and once for downgrade (with appropriate ‘old’ purchase tokens. During asking the question I errounsly copied the wrong part from my code… My tokens are set up correct, but it doesn’t work.

    – 

  • what responseCode do you receive? and debugMessage

    – 

  • I get ResponseCode == OK and an empty debugMessage and at the same time the Play popup shown to the user says “…not eligible”… Interesting: 2 hours ago it worked two times and showed the “change” popup and now it again refuses to work. I suspect problems at Google backend ???

    – 




  • do you mean that your particular case (that you described in the question) worked properly 2 hours ago? maybe some strange things with test purchases then what is the error in the onPurchasesUpdated callback?

    – 

Leave a Comment