Skip to content

Add checkTrialOrIntroDiscountEligibility(package: Package)#7159

Open
fire-at-will wants to merge 10 commits into
mainfrom
intro-eligibility-for-package
Open

Add checkTrialOrIntroDiscountEligibility(package: Package)#7159
fire-at-will wants to merge 10 commits into
mainfrom
intro-eligibility-for-package

Conversation

@fire-at-will

@fire-at-will fire-at-will commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Motivation

I was creating a mini-paywall in the Settings screen of one of my apps, when I realized that we don't have a function to check the trial/intro eligibility on a single package like we do for a single product. This means that if you only want to check the eligibility of one package, you need to wrap it in an array and then parse it out of a response dictionary, or check the eligibility of the package's product.

This isn't a super ergonomic way to check the eligibility of just one package, and we already have functions to check the eligibility of one StoreProduct, so I created this PR to add a new function to check the trial/intro eligibility of just one package.

Description

Adds the following new APIs to PurchasesType:

@objc(checkTrialOrIntroDiscountEligibilityForPackage:completion:)
func checkTrialOrIntroDiscountEligibility(
   package: Package, 
   completion: @escaping (RevenueCat.IntroEligibilityStatus) -> Void)

func checkTrialOrIntroDiscountEligibility(
   package: Package
) async -> RevenueCat.IntroEligibilityStatus

It also adds unit/API/integration tests for the new functions


Note

Low Risk
Additive public API with no change to eligibility logic; behavior matches the existing product-based checks via package.storeProduct.

Overview
Adds checkTrialOrIntroDiscountEligibility(package:) in completion and async forms on Purchases / PurchasesType, mirroring the existing single-StoreProduct APIs so callers can check intro/trial eligibility for one offering package without wrapping it in an array or using package.storeProduct directly.

Implementation delegates to the same trialOrIntroPriceEligibilityChecker path as the product overloads (package.storeProduct). ObjC entry point is checkTrialOrIntroDiscountEligibilityForPackage:completion:; public swiftinterface files are updated accordingly.

Coverage includes unit tests (completion + async), a StoreKit integration test, API testers (Swift + ObjC), and MockPurchases stubs.

Reviewed by Cursor Bugbot for commit 68c75d7. Bugbot is set up for automated code reviews on this repo. Configure here.

@fire-at-will fire-at-will added the pr:feat A new feature label Jul 7, 2026
@emerge-tools

emerge-tools Bot commented Jul 8, 2026

Copy link
Copy Markdown

📸 Snapshot Test

1 modified, 858 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
PaywallsTester V1 swift-snapshot-testing
com.revenuecat.PaywallsTester.v1-snapshots
0 0 1 0 64 0 ⏳ Needs approval
RevenueCat
com.revenuecat.PaywallsTester
0 0 0 0 274 0 N/A
Paywall Rendering Validation (mac-catalyst-optimized-for-mac)
com.revenuecat.paywall-rendering-validation.mac-catalyst-optimized-for-mac
0 0 0 0 130 0 N/A
Paywall Rendering Validation (mac-native)
com.revenuecat.paywall-rendering-validation.mac-native
0 0 0 0 130 0 N/A
Paywall Rendering Validation (mac-catalyst-scaled-to-match-ipad)
com.revenuecat.paywall-rendering-validation.mac-catalyst-scaled-to-match-ipad
0 0 0 0 130 0 N/A
Paywall Rendering Validation (ios)
com.revenuecat.paywall-rendering-validation.ios
0 0 0 0 130 0 N/A

🛸 Powered by Emerge Tools

@fire-at-will
fire-at-will marked this pull request as ready for review July 8, 2026 15:26
@fire-at-will
fire-at-will requested a review from a team as a code owner July 8, 2026 15:26

@ajpallares ajpallares left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice addition indeed! Some minor comments, no blockers! Thanks for adding this! 🙌

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably not for this PR, but now that we're adding the singular package: overload to PurchasesType, I realized that the plural checkTrialOrIntroDiscountEligibility(packages:) still lives only on the concrete Purchases class and not in the protocol. I don't think there's a reason for that? Might be worth a follow-up to add it here for consistency (I'd be fine with sneaking it in with this PR though).

Comment on lines +744 to +747
* ### Related symbols
* - ``Purchases/checkTrialOrIntroDiscountEligibility(productIdentifiers:completion:)``
* - ``Purchases/checkTrialOrIntroDiscountEligibility(product:completion:)``
*/

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Related to my previous point, in "Related symbols" we could add the checkTrialOrIntroDiscountEligibility(packages:) method. Conversely, it'd be nice to add a back-reference to package: from the existing product:/productIdentifiers: doc comments

* Computes whether or not a user is eligible for the introductory pricing period of a given package.
* You should use this method to determine whether or not you show the user the normal product price or
* the introductory price. This also applies to trials (trials are considered a type of introductory pricing).
* [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers).
* [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers).

* Computes whether or not a user is eligible for the introductory pricing period of a given package.
* You should use this method to determine whether or not you show the user the normal product price or
* the introductory price. This also applies to trials (trials are considered a type of introductory pricing).
* [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers).
* [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants