Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android paywall custom package tag #1875

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

simonmitchell
Copy link

@simonmitchell simonmitchell commented Oct 9, 2024

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-ios and hybrids

Motivation

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:

rcPackage.product.subscriptionOptions?.withTag(offerCode)?.getOrNull(0)

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:

fun subscriptionOption(rcPackage: Package): SubscriptionOption?

This provider can be provided to the library via the paywall options builder.

If provided, the PaywallViewModel will call the function, and if the subscriptionOption function returns non-null then it will use awaitPurchase function that takes a SubscriptionOption rather than a Package.

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! 😄

at the point of a purchase being made:

- Adds SubscriptionOptionProvider interface
- Adds property to PaywallOptions and PaywallOptions.Builder for the provider
- Uses the provider in PaywallViewModel
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant