Android paywall custom package tag #1875
Open
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.
Checklist
purchases-ios
and hybridsMotivation
This is motivated by a need for us to provide discount offers to our users whilst also using the revenuecat footer UI. We run our offer codes using specifically tagged
SubscriptionOption
like so:without this change to allow overriding the
SubscriptionOption
the user is purchasing using the footer component, we cannot apply offer codes in our custom paywall implementation.Description
A new interface has been added to the ui package called
SubscriptionOptionProvider
with a single function:This provider can be provided to the library via the paywall options builder.
If provided, the
PaywallViewModel
will call the function, and if thesubscriptionOption
function returns non-null then it will useawaitPurchase
function that takes aSubscriptionOption
rather than aPackage
.These changes were tested locally by running our app from the branch on our fork, and has been in the production version of our Android app for the past few weeks.
Note that I have not written any unit tests, as I am unsure if required here, but would be more than happy to if you deem necessary! 😄