Add checkTrialOrIntroDiscountEligibility(package: Package)#7159
Add checkTrialOrIntroDiscountEligibility(package: Package)#7159fire-at-will wants to merge 10 commits into
Conversation
…venueCat/purchases-ios into intro-eligibility-for-package
📸 Snapshot Test1 modified, 858 unchanged
🛸 Powered by Emerge Tools |
ajpallares
left a comment
There was a problem hiding this comment.
Nice addition indeed! Some minor comments, no blockers! Thanks for adding this! 🙌
There was a problem hiding this comment.
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).
| * ### Related symbols | ||
| * - ``Purchases/checkTrialOrIntroDiscountEligibility(productIdentifiers:completion:)`` | ||
| * - ``Purchases/checkTrialOrIntroDiscountEligibility(product:completion:)`` | ||
| */ |
There was a problem hiding this comment.
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). |
There was a problem hiding this comment.
| * [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). |
There was a problem hiding this comment.
| * [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers). | |
| * [iOS Introductory Offers](https://docs.revenuecat.com/docs/ios-subscription-offers). |
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: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 onPurchases/PurchasesType, mirroring the existing single-StoreProductAPIs so callers can check intro/trial eligibility for one offering package without wrapping it in an array or usingpackage.storeProductdirectly.Implementation delegates to the same
trialOrIntroPriceEligibilityCheckerpath as the product overloads (package.storeProduct). ObjC entry point ischeckTrialOrIntroDiscountEligibilityForPackage:completion:; public swiftinterface files are updated accordingly.Coverage includes unit tests (completion + async), a StoreKit integration test, API testers (Swift + ObjC), and
MockPurchasesstubs.Reviewed by Cursor Bugbot for commit 68c75d7. Bugbot is set up for automated code reviews on this repo. Configure here.