Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds support for product changes (upgrades/downgrades) and Play Store offer configuration in paywalls.
What's Changed
This PR introduces the data models and logic needed to handle product changes and Play Store offer configuration in paywalls.
New Configuration Models
ProductChangeConfigconfigures how upgrades and downgrades work. Upgrades default toCHARGE_PRORATED_PRICE(Google's recommendation) and downgrades default toDEFERRED. TheSerializableReplacementModeenum maps toGoogleReplacementModefor the different proration options.For Play Store offers,
PlayStoreOfferConfigworks similarly to iOS'sapplePromoOfferProductCode, specifying which Play Store offer to use for a specific package.How Offer Resolution Works
The new
PlayStoreOfferResolverhandles finding the right subscription option based on the configuration. When a package has aPlayStoreOfferConfig, the resolver searches the product's subscription options for one matching the configured offer ID. If it finds a match, it returns aConfiguredOfferresult. If the offer isn't found or no configuration exists, it falls back to the product's default option wrapped in aNoConfigurationresult.How Base Plan Changes Work
When a user with an active subscription purchases a different package, the SDK now checks if both packages grant the same entitlement. If they do, it treats this as a product change rather than creating a parallel subscription.
The
ProductChangeConfigdetermines the replacement mode based on whether it's an upgrade or downgrade (calculated by comparing price per unit time). For upgrades, the defaultCHARGE_PRORATED_PRICEcharges the price difference immediately and keeps the same billing cycle. For downgrades, the defaultDEFERREDmode waits until the current subscription expires before switching to the new plan.This works for any base plan change: monthly to annual, basic to premium, or any other combination where the entitlement stays the same but the underlying product changes.
Variable Processor Updates
VariableProcessorV2now accepts an optionalSubscriptionOptioncontext when processing variables. This means variables can show pricing for specific offers instead of always using the default option. The changes are backward compatible since the parameter is optional.ViewModel Integration
PaywallViewModelImplties everything together. When handling a package purchase, it usesPlayStoreOfferResolverto get the configured offer (if any), then passes the resolved subscription option to the variable processor. This ensures that the pricing displayed in the paywall matches the actual offer the user will get.Why?
This enables three important scenarios:
First, users can now upgrade or downgrade subscriptions with proper proration handling instead of ending up with parallel subscriptions. The
ProductChangeConfigspecifies exactly how to handle the transition.Second, specific promotional offers can be configured in paywalls. This is useful for win-back campaigns, trial extensions, or any scenario where a specific offer should be shown in the paywall instead of just the default.
Third, paywall variables now show accurate pricing for configured offers. Before this, variables would always use the default option's pricing even if a different offer was configured.