New Purchases.checkTrialOrIntroDiscountEligibility(packages:)#2858
Closed
NachoSoto wants to merge 27 commits into
Closed
New Purchases.checkTrialOrIntroDiscountEligibility(packages:)#2858NachoSoto wants to merge 27 commits into
Purchases.checkTrialOrIntroDiscountEligibility(packages:)#2858NachoSoto wants to merge 27 commits into
Conversation
This was referenced Jul 20, 2023
Codecov Report
@@ Coverage Diff @@
## main #2858 +/- ##
==========================================
+ Coverage 86.58% 86.67% +0.08%
==========================================
Files 217 217
Lines 15513 15550 +37
==========================================
+ Hits 13432 13478 +46
+ Misses 2081 2072 -9
|
### Changes: - Added `RevenueCatUI` to `Package.json` - Set up tests for `RevenueCatUI` using `snapshot-testing` (not in CI during initial development) - Added Schemes to allow easily building packages while working on the `Package.swift` - Updated `SimpleApp` to use new package
- Added `Offering.paywall` - Decoding `PaywallData` in `OfferingsResponse`, using `IgnoreDecodeErrors` (this will be better after #2778) - New `PaywallData` `struct` - Added new APIs to testers - Testing paywall deserialization from `Offerings` - Testing paywall deserialization separately to check edge cases
…#2781) This adds a new `TemplateViewType` that different templates can conform to. `PaywallView` now takes `PaywallData` and renders the paywall depending on its template.
### Other changes: - Added `subtitle` and `offerDetails` to `LocalizedConfiguration` - Improved sample paywall to include these with test variables - Updated snapshot test to display the current progress - Added initial implementation of `VariableHandler` with tests
- Added `PaywallData.assetBaseURL` and `PaywallData.Configuration.headerImageName` - Changed template to fetch image from network - Updated snapshot testing to support asynchronous checking, necessary for `AsyncImageView` - Added support for overriding images for snapshot tests - Extracted `DebugErrorView`
Follow up to #2796. This also makes `PaywallData.Configuration`'s intro strings optional. ### Other changes: - Injected `TrialOrIntroEligibilityChecker` - Created mock `TrialOrIntroEligibilityChecker` for previews - Handling state and transitions for loading eligibility - Snapshot tests for the different new cases - Improved `SnapshotTesting` delay management - Expanded `DebugErrorView` to customize release behavior
Some missing tests for the logic added in #2798. I've also moved this function to be fined in `PaywallData` instead of the `TemplateViewType` protocol, which makes more sense.
This adds a new `PurchaseHandler` type, which can be instantiated with `Purchases` or with a mock implementation for previews. That gets injected, and templates can now purchase and dismiss themselves. I've improved the `SimpleApp` setup to better work with the lifetime of purchases. Now it only displays the paywall if the user doesn't have an entitlement. I've also added some basic error handling to the new `AsyncButton`: 
These now match how the frontend is configuring them.
This improves the layout of the template, and adds a scroll view that optionally scrolls if the content is too large. This can serve as a the basis for future templates. 
…ewConfiguration` (#2830) ### Changes: - Created `TemplateViewConfiguration` to encapsulate all processed configuration for a paywall - Created `TemplateViewConfiguration.PackageSetting` and `TemplateViewConfiguration.PackageConfiguration` to represent paywalls that support 1 or N packages - Taken all common logic out of `Example1Template` - Added new `PaywallViewMode` for upcoming "ramps" views
This adds 2 new modes: `.square` and `.banner`:   ------- I've updated `Example1Template` to support both as an example, and added that as snapshot tests. This also adds a new constructor to `PaywallView` that doesn't require passing an `Offering` or `PaywallData`, it automatically loads that from `Purchases.shared`. With that, embedding these mini-paywalls is trivial: ```swift struct MyApp: View { var body: some View { MyOtherViews() if !customerInfo.hasPro { PaywallView(mode: .card) } } } ``` I've added these as examples to the testing app: 
Small refactor, starting to take views out of `Example1Template` so they're usable by other templates. This also removes some of the duplicate code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This new overload helps the implementation of
RevenueCatUI(#2846), so we can get a complete dictionary of all requestedPackages, regardless of whether they might refer to the same products, or if the implementation does not contain that in the result.I also implemented
IntroEligibility'sHashable's overrides as well asdebugDescription, which were needed to debug this.Turns out there was no test coverage for the other check trial eligibility methods, so this tests those indirectly as well.