Hi everyone,
I'm implementing subscription upgrades and downgrades for Android in my React Native app, using react-native-purchases version 9.4.1. I'm currently running into an issue while testing on a physical device using an internal test track.
What is happening:
When I try to upgrade or downgrade from an active subscription (e.g., "plus") to another plan (e.g., "pro" or "lite"), the purchase flow fails.
-
On Upgrade, I receive the following error from Google Play Billing via
adb logcat:[RevenueCat] 🤖‼️ BillingWrapper purchases failed to update: DebugMessage: Requested replacement mode is not supported for this request. ErrorCode: DEVELOPER_ERROR. -
On Downgrade, I get a more generic
Unknown error..
My Implementation:
I check if the user already has an active subscription, and if so, I pass a second argument to the purchasePackage call to handle the upgrade/downgrade. Here is a snippet of my code:
TypeScript
// Using "react-native-purchases": "9.4.1"
import Purchases, {
PurchasesPackage,
PRORATION_MODE,
GoogleProductChangeInfo // The type I'm currently using
} from 'react-native-purchases';
import { Platform } from 'react-native';
// ... in my purchase function
async function purchasePackage(packageToPurchase: PurchasesPackage) {
if (Platform.OS === 'android') {
const customerInfo = await Purchases.getCustomerInfo();
const activeSubscriptionId = customerInfo.activeSubscriptions.length > 0
? customerInfo.activeSubscriptions[0]
: null;
if (activeSubscriptionId) { // This is an upgrade/downgrade
const oldProductId = activeSubscriptionId.split(':')[0]; // e.g., 'dialory_subscription'
const isUpgrade = /* ... my logic ... */;
const productChangeInfo: GoogleProductChangeInfo = {
oldProductIdentifier: oldProductId,
prorationMode: isUpgrade
? PRORATION_MODE.IMMEDIATE_WITH_TIME_PRORATION
: PRORATION_MODE.DEFERRED,
};
console.log('Attempting Android upgrade/downgrade with:', productChangeInfo);
try {
await Purchases.purchasePackage(packageToPurchase, productChangeInfo);
} catch (e) {
console.error('Purchase failed:', e.message);
}
} else {
// New purchase logic
await Purchases.purchasePackage(packageToPurchase);
}
}
}
TypeScript Compilation Error:
I'm also getting a TypeScript error, which might be related: Argument of type 'GoogleProductChangeInfo' is not assignable to parameter of type 'UpgradeInfo'. Property 'oldSKU' is missing...
This seems to suggest that for version 9.4.1, I should be using the UpgradeInfo type with an oldSKU property, instead of GoogleProductChangeInfo with oldProductIdentifier.
My Question:
-
For
react-native-purchases@9.4.1, is it correct that I should be usingUpgradeInfoandoldSKUfor Android subscription changes? -
Is it likely that the
DEVELOPER_ERRORI'm receiving is a direct result of passing the wrong data structure (oldProductIdentifierinstead ofoldSKU) to the SDK?
Thanks for any help!
