Question

Passing oldProductId when GoogleReplacementMode.DEFERRED results in an error purchase

  • 11 July 2024
  • 1 reply
  • 49 views

Badge +4

I attempting to downgrade a purchase with DEFERRED, which was reinstated in Android SDK 8.2.0, the downgrade was not successful and threw the following exception

PurchasesError(code=PurchaseInvalidError, underlyingErrorMessage=Error updating purchases. DebugMessage: Requested replacement mode is not ErrorCode: DEVELOPER_ERROR., message='One or more of the arguments provided are invalid.)

 

I have tried three others.

  • Specifying a GoogleReplacementMode other than DEFERRED.
    • The downgrade here was successful.
    • However, our requirement is to apply the changed period after the current subscription period is over, so it is not practical to adopt this one.
  • Not specifying oldProductId.
    • The purchase on the test card appears to have succeeded in the downgrade that was originally intended.
    • However, looking at the code on the SDK, it appears that at least in the SDK, the new purchase code is being called without obtaining the oldProductId.
      • (I don't know why it's working so well, maybe the PBL side is being clever?)
  • Trying the same case with another app.
    • This one succeeded, but the ID format is compliant with the old PBL
      • The apps that succeeded had IDs like gold_6m, gold_1m
      • The app that fails has a "productId:basePlanId" structure like gold:6m, gold:1m because the product is configured with the new PBL.

Reading the code on the SDK, it seems that only the productId before the ":" is extracted here, which I suspect is the cause of the failure.

https://github.com/RevenueCat/purchases-android/blob/ba5465f69c3e85792fd46ff65d562fdd080f98cc/purchases/src/main/kotlin/com/ revenuecat/purchases/PurchasesOrchestrator.kt#L1142-L1148
 


1 reply

Userlevel 2
Badge +3

Hi @masaibar,

The `productId:basePlanId` format is used internally by RevenueCat but Google expects to only set the `oldProductId` when performing upgrades/downgrades.

(I don't know why it's working so well, maybe the PBL side is being clever?)

If you try to purchase a different base plan within the same subscription, Google will automatically apply the chosen replacement mode in the console and consider it an upgrade/downgrade: https://developer.android.com/google/play/billing/subscriptions#resubscribe_or_switch_plans_within_the_same_subscription

We’re able to reproduce the issue when trying to upgrade/downgrade between different base plans in the same product. Only the `CHARGE_FULL_PRICE` and `WITHOUT_PRORATION` are allowed in that case according to Google’s documentation (link above). Note that this means that the upgrade is performed immediately, so this is only recommended if the upgrade gives the customer the same access.

If you want to perform an upgrade/downgrade to a different “tier”/”access level”, it’s recommended to create a different Google product. In this case, it should allow you to perform a `DEFERRED` downgrade.

Let us know if you have any further questions about this!

 

Reply