Chris
Chris

Reputation: 1447

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 ?

Upvotes: 0

Views: 337

Answers (1)

Chris
Chris

Reputation: 1447

I found the problem:

When you call .setSubscriptionUpdateParams() you may not specify setObfuscatedAccountId() in the same Builder() call. Obviously google's anti fraud mechanism inhibits the upgrade/downgrade purchase when setObfuscatedAccountId is specified !!! What the f***k.

Upvotes: 0

Related Questions