Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot upgrade android in-app subscription. Error: "Something went wrong on our end. Please try again."

Issue:

  • Cannot upgrade current subscription to different subscription.
  • Showing Error: "Something went wrong on our end. Please try again."

Description:

  • Were using play billing library v3.0.3 and we handled subscription upgrade as code below.
BillingFlowParams purchaseParams = BillingFlowParams.newBuilder()
                    .setSkuDetails(skuDetails)
                    .setOldSku(oldSKU, oldPurchaseToken)
                    .setReplaceSkusProrationMode(IMMEDIATE_WITH_TIME_PRORATION)
                    .build();
  • Things were as expected when we launched.
  • Some users reported that they cannot upgrade their subscription.
  • We tested upgrade and same error was encountered: "Something went wrong on our end. Please try again."
  • Then we upgraded to play billing library v4.0.0 thinking it would solve our issue.
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
        .setSubscriptionUpdateParams(SubscriptionUpdateParams.newBuilder()
            .setOldSkuPurchaseToken(oldPurchaseToken)
            .setOldSkuPurchaseId(oldSKU) // This method is not available in lib[4.0.0] but mentioned in docs
            .setReplaceSkusProrationMode(IMMEDIATE_WITH_TIME_PRORATION))
        .setSkuDetails(skuDetails)
        .build();
  • Same error is reported again: "Something went wrong on our end. Please try again."
  • Also new play billing library v4.0.0 does not have method setOldSkuPurchaseId() in class SubscriptionUpdateParams.Builder but mentioned in developer docs

Error Screenshot Attached Below

screenshot

like image 231
Tej Pratap Avatar asked May 25 '21 14:05

Tej Pratap


Video Answer


1 Answers

I had to add an additional .build() to Google's example code

        // Retrieve a value for "skuDetails" by calling querySkuDetailsAsync()
        val flowParams = BillingFlowParams.newBuilder()
                .setSubscriptionUpdateParams(SubscriptionUpdateParams.newBuilder()
                    .setOldSkuPurchaseToken(purchaseTokenOfOriginalSubscription)
                    .setReplaceSkusProrationMode(desiredProrationMode)
                    .build() // <-- MISSING BUILD
                    )
                .setSkuDetails(upgradeOrDowngradeSkuDetails)
                .build();
        val responseCode = billingClient.launchBillingFlow(activity, flowParams)
like image 151
Gabor Szigeti Avatar answered Oct 21 '22 20:10

Gabor Szigeti