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

Implement subscription purchase #1906

Merged
merged 98 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
28a16e0
Rename shortLivedToken -> authToken
miasma13 Oct 18, 2023
2d34f75
Rename longLivedToken -> accessToken
miasma13 Oct 18, 2023
11d1b07
Tweak naming
miasma13 Oct 18, 2023
38e07b7
Move away from storing externalID
miasma13 Oct 18, 2023
6b00835
API for checking entitlements
miasma13 Oct 19, 2023
e50d906
API for checking available purchases on the App Store
miasma13 Oct 19, 2023
233e77a
Restrict subscription userscript to DDG and test domain
miasma13 Oct 31, 2023
ced340e
Remove leftover
miasma13 Oct 31, 2023
3fd6283
Error alerts test
miasma13 Nov 2, 2023
c756731
Check entitlements in settigns
miasma13 Nov 6, 2023
5befeaf
Shared APIService code and SubscriptionService
miasma13 Nov 7, 2023
81be159
Core of the purchase flow
miasma13 Nov 14, 2023
fd231db
Refresh available products on entering settings
miasma13 Nov 16, 2023
8b8c530
Complete purchase flow
miasma13 Nov 16, 2023
b8313e9
Rework AccountManager API to async
miasma13 Nov 16, 2023
7ce8193
Decouple Account and Purchase packages
miasma13 Nov 16, 2023
796dd94
Extract AppStore purchase flow
miasma13 Nov 16, 2023
38de072
Update sync Apple ID method return result
miasma13 Nov 16, 2023
cc4a3f4
Further tweaking result types
miasma13 Nov 16, 2023
4616b69
Further tweaking result types again
miasma13 Nov 16, 2023
0717198
Purchase flow errors
miasma13 Nov 16, 2023
5805873
Clean up
miasma13 Nov 16, 2023
5730c23
Present subscription access view from the offer and onboarding pages
miasma13 Nov 17, 2023
a7c009b
Gather subscription URLs in single place
miasma13 Nov 20, 2023
b853d93
Initialize and fetch subscription products add app launch
miasma13 Nov 20, 2023
b26b976
Rename isSignedIn to isUserAuthenticated
miasma13 Nov 20, 2023
046c232
Rename exchangeTokensAndRefreshEntitlements to exchangeAndStoreTokens
miasma13 Nov 20, 2023
b5201b7
Remove unnecessary call
miasma13 Nov 20, 2023
adac3fb
Extract restore flow to AppStoreRestoreFlow
miasma13 Nov 20, 2023
69b7939
Pass email PAT if present when creating an account
miasma13 Nov 21, 2023
7360026
Refresh account details after changing email
miasma13 Nov 21, 2023
f61b53a
Clean up account details after failed/cancelled purchase
miasma13 Nov 21, 2023
85625c3
Refine how error description is built
miasma13 Nov 22, 2023
769a22b
Flow for validating and refreshing short lived auth token for email m…
miasma13 Nov 22, 2023
9e2252f
Move auth token refresh to when email management flows are launched
miasma13 Nov 22, 2023
651eb88
Foundation for alerts
miasma13 Nov 23, 2023
ebf1b44
Support Stripe purchase flow
miasma13 Nov 24, 2023
cabb412
Adapt App Store purchase flow
miasma13 Nov 24, 2023
efa3bc0
Add todo
miasma13 Nov 27, 2023
cb9981f
Handle error during purchase
miasma13 Nov 27, 2023
31756a4
Edge cases for restore flow
miasma13 Nov 27, 2023
966e561
Check for active subscription when restoring
miasma13 Nov 27, 2023
0774113
Clean the logic
miasma13 Nov 27, 2023
1574e1a
Final tweaks to the restore during purchase
miasma13 Nov 27, 2023
b4d34c1
Fetch and show date in the settings
miasma13 Nov 27, 2023
49dc0ed
Merge in Purchase package with Account
miasma13 Nov 27, 2023
6f5bba1
Remove last trace of Purchase framework from the main target
miasma13 Nov 28, 2023
26d12c4
Remove Accounts from the main target
miasma13 Nov 28, 2023
fc8b971
Rename Subscription to SubscriptionUI
miasma13 Nov 28, 2023
cbb8ea1
Rename Account to Subscrtiption package
miasma13 Nov 28, 2023
aaad27d
Enable Stripe flow
miasma13 Nov 28, 2023
57d7a94
Change the subscription build config to Review
miasma13 Dec 7, 2023
05e82d2
Move files around
miasma13 Dec 7, 2023
423c898
Clean up
miasma13 Dec 7, 2023
3b9f696
Improve separation of concerns in the API
miasma13 Dec 8, 2023
5b9af1f
Show progress view on restoring subscription
miasma13 Dec 8, 2023
a2022d3
Purchase dependant environment setup
miasma13 Dec 8, 2023
ba50dd6
Navigate to Stripe customer portal to manage the subscription
miasma13 Dec 8, 2023
7ddfaf1
Update progress usage during purchase
miasma13 Dec 11, 2023
f63b050
Pass email token during Stripe account creation
miasma13 Dec 11, 2023
9730905
Cache subscription end date
miasma13 Dec 11, 2023
d78fc8e
Check for expiration
miasma13 Dec 11, 2023
6d9c30a
Refactor alerts
miasma13 Dec 11, 2023
5658059
Restore inactive buttons state and disable automatic sign out on expi…
miasma13 Dec 12, 2023
defe062
When setting purchase environment fetch available products to determi…
miasma13 Dec 12, 2023
5150caa
Hide Subscription related entrypoints if not authentcated and no able…
miasma13 Dec 12, 2023
1887c63
Sign out on expired subscription
miasma13 Dec 12, 2023
d87f0de
Merge branch 'main' into michal/subscription-purchase
miasma13 Dec 12, 2023
d0e952e
Switch BSK to a branch
miasma13 Dec 13, 2023
a170b5c
Update subscription logs
miasma13 Dec 13, 2023
4994937
Update logging
miasma13 Dec 13, 2023
1f638eb
Add conditionals for iOS 15 plus iOS product identifiers and linting …
afterxleep Dec 13, 2023
b330c99
Update logs
miasma13 Dec 13, 2023
9b1e950
Fix missed handling of an error case
miasma13 Dec 13, 2023
7bb6312
Tweak logs
miasma13 Dec 13, 2023
67e385b
Further update to logs
miasma13 Dec 13, 2023
a0c09d9
Additional logs
miasma13 Dec 14, 2023
f994e0b
Fix whitespace
miasma13 Dec 15, 2023
b9a539e
Fix further linting errors
miasma13 Dec 15, 2023
82cbbee
Further logging enhancements
miasma13 Dec 15, 2023
8fc9ce1
Disable forced sign in on purchase
miasma13 Dec 15, 2023
b69fc8f
Bump retries on entitlements polling
miasma13 Dec 15, 2023
5ad4d1a
Only pass authToken when accessToken is also present
miasma13 Dec 15, 2023
b7ba2c6
In unauthenticated state make the sections not greyed out
miasma13 Dec 18, 2023
4546733
Extract logic to separate functions
miasma13 Dec 18, 2023
40b262f
Clean AppStoreAccountManagementFlow.refreshAuthTokenIfNeeded
miasma13 Dec 18, 2023
b9289a1
Clean up errors
miasma13 Dec 18, 2023
5361ff7
Move checkForEntitlements
miasma13 Dec 18, 2023
c7bc825
Extract alert titles and descriptions
miasma13 Dec 18, 2023
035b923
Extract progress view titles
miasma13 Dec 18, 2023
439c275
Clean up todos
miasma13 Dec 18, 2023
4b6f0ff
Handle request for navigating to subscription feature via notification
miasma13 Dec 18, 2023
ebde2a4
Update comment
miasma13 Dec 18, 2023
ab18525
Remove dead code
miasma13 Dec 22, 2023
b6aa098
Add Stripe version of something went wrong alert
miasma13 Dec 22, 2023
127d19a
Merge branch 'main' into michal/subscription-purchase
miasma13 Dec 22, 2023
c2fbced
Fix linting errors
miasma13 Dec 22, 2023
71595d9
Add check for the Subscription import
miasma13 Dec 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Configuration/App/DuckDuckGoPrivacyPro.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,6 @@

#include "DuckDuckGo.xcconfig"

FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION SPARKLE SUBSCRIPTION DBP
FEATURE_FLAGS = FEEDBACK NETWORK_PROTECTION SPARKLE SUBSCRIPTION DBP STRIPE
PRODUCT_NAME = $(PRODUCT_NAME_PREFIX) Privacy Pro
PRODUCT_MODULE_NAME = DuckDuckGo_Privacy_Browser
56 changes: 16 additions & 40 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
1DFAB51E2A8982A600A0F7F6 /* SetExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DFAB51C2A8982A600A0F7F6 /* SetExtension.swift */; };
1DFAB5222A8983DE00A0F7F6 /* SetExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DFAB51F2A89830D00A0F7F6 /* SetExtensionTests.swift */; };
1DFAB5232A8983E100A0F7F6 /* SetExtensionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1DFAB51F2A89830D00A0F7F6 /* SetExtensionTests.swift */; };
1E0068AD2B1673BB00BBF43B /* SubscriptionUI in Frameworks */ = {isa = PBXBuildFile; productRef = 1E0068AC2B1673BB00BBF43B /* SubscriptionUI */; };
1E0C72062ABC63BD00802009 /* SubscriptionPagesUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0C72052ABC63BD00802009 /* SubscriptionPagesUserScript.swift */; };
1E0C72072ABC63BD00802009 /* SubscriptionPagesUserScript.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E0C72052ABC63BD00802009 /* SubscriptionPagesUserScript.swift */; };
1E2AE4C72ACB215900684E0A /* NetworkProtectionRemoteMessaging.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BCF15D62ABB8A110083F6DF /* NetworkProtectionRemoteMessaging.swift */; };
Expand All @@ -83,14 +84,13 @@
1E2AE4CA2ACB21A000684E0A /* NetworkProtectionRemoteMessage.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BCF15D82ABB8A7F0083F6DF /* NetworkProtectionRemoteMessage.swift */; };
1E2AE4CB2ACB21C800684E0A /* HardwareModel.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4B9579202AC687170062CA31 /* HardwareModel.swift */; };
1E2AE4CC2ACB224A00684E0A /* NetworkProtectionRemoteMessagingRequest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 4BCF15DC2ABB8CFC0083F6DF /* NetworkProtectionRemoteMessagingRequest.swift */; };
1E3ED4FD2AC1E0290075F60F /* Purchase in Frameworks */ = {isa = PBXBuildFile; productRef = 1E3ED4FC2AC1E0290075F60F /* Purchase */; };
1E7E2E9029029A2A00C01B54 /* ContentBlockingRulesUpdateObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7E2E8F29029A2A00C01B54 /* ContentBlockingRulesUpdateObserver.swift */; };
1E7E2E9229029F9B00C01B54 /* WebsiteBreakageReporter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7E2E9129029F9B00C01B54 /* WebsiteBreakageReporter.swift */; };
1E7E2E942902AC0E00C01B54 /* PrivacyDashboardPermissionHandler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1E7E2E932902AC0E00C01B54 /* PrivacyDashboardPermissionHandler.swift */; };
1E934E2B2B167CA80084722B /* Subscription in Frameworks */ = {isa = PBXBuildFile; productRef = 1E934E2A2B167CA80084722B /* Subscription */; };
1E950E3F2912A10D0051A99B /* ContentBlocking in Frameworks */ = {isa = PBXBuildFile; productRef = 1E950E3E2912A10D0051A99B /* ContentBlocking */; };
1E950E412912A10D0051A99B /* PrivacyDashboard in Frameworks */ = {isa = PBXBuildFile; productRef = 1E950E402912A10D0051A99B /* PrivacyDashboard */; };
1E950E432912A10D0051A99B /* UserScript in Frameworks */ = {isa = PBXBuildFile; productRef = 1E950E422912A10D0051A99B /* UserScript */; };
1EC88CA12AC1DD63003A4471 /* Account in Frameworks */ = {isa = PBXBuildFile; productRef = 1EC88CA02AC1DD63003A4471 /* Account */; };
310E79BF294A19A8007C49E8 /* FireproofingReferenceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 310E79BE294A19A8007C49E8 /* FireproofingReferenceTests.swift */; };
311B262728E73E0A00FD181A /* TabShadowConfig.swift in Sources */ = {isa = PBXBuildFile; fileRef = 311B262628E73E0A00FD181A /* TabShadowConfig.swift */; };
3143C8792B0D1F3D00382627 /* DataBrokerProtection in Frameworks */ = {isa = PBXBuildFile; productRef = 3143C8782B0D1F3D00382627 /* DataBrokerProtection */; };
Expand Down Expand Up @@ -1885,15 +1885,12 @@
4B957BD62AC7AE700062CA31 /* LoginItems in Frameworks */ = {isa = PBXBuildFile; productRef = 4B95793F2AC7AE700062CA31 /* LoginItems */; };
4B957BD72AC7AE700062CA31 /* NetworkProtection in Frameworks */ = {isa = PBXBuildFile; productRef = 4B95793E2AC7AE700062CA31 /* NetworkProtection */; };
4B957BD82AC7AE700062CA31 /* BrowserServicesKit in Frameworks */ = {isa = PBXBuildFile; productRef = 4B95792B2AC7AE700062CA31 /* BrowserServicesKit */; };
4B957BD92AC7AE700062CA31 /* Account in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579412AC7AE700062CA31 /* Account */; };
4B957BDA2AC7AE700062CA31 /* Bookmarks in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579342AC7AE700062CA31 /* Bookmarks */; };
4B957BDB2AC7AE700062CA31 /* ContentBlocking in Frameworks */ = {isa = PBXBuildFile; productRef = 4B95792E2AC7AE700062CA31 /* ContentBlocking */; };
4B957BDC2AC7AE700062CA31 /* SwiftUIExtensions in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579372AC7AE700062CA31 /* SwiftUIExtensions */; };
4B957BDD2AC7AE700062CA31 /* UserScript in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579302AC7AE700062CA31 /* UserScript */; };
4B957BDE2AC7AE700062CA31 /* Configuration in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579322AC7AE700062CA31 /* Configuration */; };
4B957BDF2AC7AE700062CA31 /* Purchase in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579422AC7AE700062CA31 /* Purchase */; };
4B957BE02AC7AE700062CA31 /* Lottie in Frameworks */ = {isa = PBXBuildFile; productRef = 4B95793A2AC7AE700062CA31 /* Lottie */; };
4B957BE12AC7AE700062CA31 /* Subscription in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579402AC7AE700062CA31 /* Subscription */; };
4B957BE22AC7AE700062CA31 /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579292AC7AE700062CA31 /* Sparkle */; };
4B957BE32AC7AE700062CA31 /* Navigation in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579332AC7AE700062CA31 /* Navigation */; };
4B957BE42AC7AE700062CA31 /* DDGSync in Frameworks */ = {isa = PBXBuildFile; productRef = 4B9579352AC7AE700062CA31 /* DDGSync */; };
Expand Down Expand Up @@ -3210,9 +3207,8 @@
1E7E2E8F29029A2A00C01B54 /* ContentBlockingRulesUpdateObserver.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ContentBlockingRulesUpdateObserver.swift; sourceTree = "<group>"; };
1E7E2E9129029F9B00C01B54 /* WebsiteBreakageReporter.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebsiteBreakageReporter.swift; sourceTree = "<group>"; };
1E7E2E932902AC0E00C01B54 /* PrivacyDashboardPermissionHandler.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PrivacyDashboardPermissionHandler.swift; sourceTree = "<group>"; };
1E862A852A9FBD7000F84D4B /* Account */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Account; sourceTree = "<group>"; };
1E862A882A9FC01200F84D4B /* Subscription */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Subscription; sourceTree = "<group>"; };
1EC88CA22AC1DE82003A4471 /* Purchase */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Purchase; sourceTree = "<group>"; };
1E862A882A9FC01200F84D4B /* SubscriptionUI */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = SubscriptionUI; sourceTree = "<group>"; };
1E8F997E2B221B3600AC5D34 /* Subscription */ = {isa = PBXFileReference; lastKnownFileType = wrapper; path = Subscription; sourceTree = "<group>"; };
310E79BE294A19A8007C49E8 /* FireproofingReferenceTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FireproofingReferenceTests.swift; sourceTree = "<group>"; };
311B262628E73E0A00FD181A /* TabShadowConfig.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TabShadowConfig.swift; sourceTree = "<group>"; };
3139A1512AA4B3C000969C7D /* DataBrokerProtectionManager.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DataBrokerProtectionManager.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -4431,22 +4427,20 @@
buildActionMask = 2147483647;
files = (
4B957BD52AC7AE700062CA31 /* QuickLookUI.framework in Frameworks */,
1E934E2B2B167CA80084722B /* Subscription in Frameworks */,
3143C8792B0D1F3D00382627 /* DataBrokerProtection in Frameworks */,
372217842B33380E00B8E9C2 /* TestUtils in Frameworks */,
4B957BD62AC7AE700062CA31 /* LoginItems in Frameworks */,
4B957BD72AC7AE700062CA31 /* NetworkProtection in Frameworks */,
4B957BD82AC7AE700062CA31 /* BrowserServicesKit in Frameworks */,
4B957BD92AC7AE700062CA31 /* Account in Frameworks */,
4B957BDA2AC7AE700062CA31 /* Bookmarks in Frameworks */,
4B957BDB2AC7AE700062CA31 /* ContentBlocking in Frameworks */,
4B957BDC2AC7AE700062CA31 /* SwiftUIExtensions in Frameworks */,
4B957BDD2AC7AE700062CA31 /* UserScript in Frameworks */,
7BBD44282AD730A400D0A064 /* PixelKit in Frameworks */,
7B31FD902AD1257B0086AA24 /* NetworkProtectionIPC in Frameworks */,
4B957BDE2AC7AE700062CA31 /* Configuration in Frameworks */,
4B957BDF2AC7AE700062CA31 /* Purchase in Frameworks */,
4B957BE02AC7AE700062CA31 /* Lottie in Frameworks */,
4B957BE12AC7AE700062CA31 /* Subscription in Frameworks */,
4B957BE22AC7AE700062CA31 /* Sparkle in Frameworks */,
4B957BE32AC7AE700062CA31 /* Navigation in Frameworks */,
4B957BE42AC7AE700062CA31 /* DDGSync in Frameworks */,
Expand All @@ -4457,6 +4451,7 @@
37269F032B332FD8005E8E46 /* Common in Frameworks */,
4B957BE82AC7AE700062CA31 /* SyncUI in Frameworks */,
4B957BE92AC7AE700062CA31 /* NetworkProtectionUI in Frameworks */,
1E0068AD2B1673BB00BBF43B /* SubscriptionUI in Frameworks */,
4B957BEB2AC7AE700062CA31 /* Persistence in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -4504,7 +4499,6 @@
9DB6E7242AA0DC5800A17F3C /* LoginItems in Frameworks */,
EE7295E32A545B9A008C0991 /* NetworkProtection in Frameworks */,
9807F645278CA16F00E1547B /* BrowserServicesKit in Frameworks */,
1EC88CA12AC1DD63003A4471 /* Account in Frameworks */,
987799ED299998B1005D8EB6 /* Bookmarks in Frameworks */,
7B5DD69A2AE51FFA001DE99C /* PixelKit in Frameworks */,
1E950E3F2912A10D0051A99B /* ContentBlocking in Frameworks */,
Expand All @@ -4514,7 +4508,6 @@
CBC83E3629B63D380008E19C /* Configuration in Frameworks */,
7B31FD8C2AD125620086AA24 /* NetworkProtectionIPC in Frameworks */,
37269EFB2B332F9E005E8E46 /* Common in Frameworks */,
1E3ED4FD2AC1E0290075F60F /* Purchase in Frameworks */,
4B2AAAF529E70DEA0026AFC0 /* Lottie in Frameworks */,
AA06B6B72672AF8100F541C5 /* Sparkle in Frameworks */,
B6B77BE8297973D4001E68A1 /* Navigation in Frameworks */,
Expand Down Expand Up @@ -4901,16 +4894,15 @@
378E279C2970217400FCADA2 /* LocalPackages */ = {
isa = PBXGroup;
children = (
1E862A852A9FBD7000F84D4B /* Account */,
378E279D2970217400FCADA2 /* BuildToolPlugins */,
3192A2702A4C4E330084EA89 /* DataBrokerProtection */,
9DB6E7222AA0DA7A00A17F3C /* LoginItems */,
7B25FE322AD12C990012AFAB /* NetworkProtectionMac */,
4BE15DB12A0B0DD500898243 /* PixelKit */,
1EC88CA22AC1DE82003A4471 /* Purchase */,
378F44E229B4B7B600899924 /* SwiftUIExtensions */,
37BA812B29B3CB8A0053F1A3 /* SyncUI */,
1E862A882A9FC01200F84D4B /* Subscription */,
1E8F997E2B221B3600AC5D34 /* Subscription */,
1E862A882A9FC01200F84D4B /* SubscriptionUI */,
7BEC182D2AD5D89C00D30536 /* SystemExtensionManager */,
7B76E6852AD5D77600186A84 /* XPCHelper */,
);
Expand Down Expand Up @@ -8336,12 +8328,10 @@
4B95793D2AC7AE700062CA31 /* NetworkProtectionUI */,
4B95793E2AC7AE700062CA31 /* NetworkProtection */,
4B95793F2AC7AE700062CA31 /* LoginItems */,
4B9579402AC7AE700062CA31 /* Subscription */,
4B9579412AC7AE700062CA31 /* Account */,
4B9579422AC7AE700062CA31 /* Purchase */,
7B8C083B2AE1268E00F4C67F /* PixelKit */,
7B31FD8F2AD1257B0086AA24 /* NetworkProtectionIPC */,
3143C8782B0D1F3D00382627 /* DataBrokerProtection */,
1E0068AC2B1673BB00BBF43B /* SubscriptionUI */,
1E934E2A2B167CA80084722B /* Subscription */,
37269F022B332FD8005E8E46 /* Common */,
372217832B33380E00B8E9C2 /* TestUtils */,
);
Expand Down Expand Up @@ -8474,8 +8464,6 @@
4B4D60B02A0C83B900BCD287 /* NetworkProtectionUI */,
EE7295E22A545B9A008C0991 /* NetworkProtection */,
9DB6E7232AA0DC5800A17F3C /* LoginItems */,
1EC88CA02AC1DD63003A4471 /* Account */,
1E3ED4FC2AC1E0290075F60F /* Purchase */,
7B31FD8B2AD125620086AA24 /* NetworkProtectionIPC */,
7BA59C9A2AE18B49009A97B1 /* SystemExtensionManager */,
7B5DD6992AE51FFA001DE99C /* PixelKit */,
Expand Down Expand Up @@ -13094,9 +13082,13 @@
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
1E3ED4FC2AC1E0290075F60F /* Purchase */ = {
1E0068AC2B1673BB00BBF43B /* SubscriptionUI */ = {
isa = XCSwiftPackageProductDependency;
productName = Purchase;
productName = SubscriptionUI;
};
1E934E2A2B167CA80084722B /* Subscription */ = {
isa = XCSwiftPackageProductDependency;
productName = Subscription;
};
1E950E3E2912A10D0051A99B /* ContentBlocking */ = {
isa = XCSwiftPackageProductDependency;
Expand All @@ -13113,10 +13105,6 @@
package = 9807F643278CA16F00E1547B /* XCRemoteSwiftPackageReference "BrowserServicesKit" */;
productName = UserScript;
};
1EC88CA02AC1DD63003A4471 /* Account */ = {
isa = XCSwiftPackageProductDependency;
productName = Account;
};
3143C8782B0D1F3D00382627 /* DataBrokerProtection */ = {
isa = XCSwiftPackageProductDependency;
productName = DataBrokerProtection;
Expand Down Expand Up @@ -13406,18 +13394,6 @@
isa = XCSwiftPackageProductDependency;
productName = LoginItems;
};
4B9579402AC7AE700062CA31 /* Subscription */ = {
isa = XCSwiftPackageProductDependency;
productName = Subscription;
};
4B9579412AC7AE700062CA31 /* Account */ = {
isa = XCSwiftPackageProductDependency;
productName = Account;
};
4B9579422AC7AE700062CA31 /* Purchase */ = {
isa = XCSwiftPackageProductDependency;
productName = Purchase;
};
7B31FD8B2AD125620086AA24 /* NetworkProtectionIPC */ = {
isa = XCSwiftPackageProductDependency;
productName = NetworkProtectionIPC;
Expand Down
16 changes: 16 additions & 0 deletions DuckDuckGo/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ import UserNotifications
import NetworkProtection
#endif

#if SUBSCRIPTION
import Subscription
#endif

@MainActor
final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDelegate {

Expand Down Expand Up @@ -184,6 +188,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
appIconChanger = AppIconChanger(internalUserDecider: internalUserDecider)
}

// swiftlint:disable:next function_body_length
func applicationDidFinishLaunching(_ notification: Notification) {
guard NSApp.runType.requiresEnvironment else { return }
defer {
Expand Down Expand Up @@ -254,6 +259,17 @@ final class AppDelegate: NSObject, NSApplicationDelegate, FileDownloadManagerDel
#if DBP
DataBrokerProtectionAppEvents().applicationDidFinishLaunching()
#endif

#if SUBSCRIPTION
Task {
#if STRIPE
SubscriptionPurchaseEnvironment.current = .stripe
#else
SubscriptionPurchaseEnvironment.current = .appStore
#endif
Comment on lines +265 to +269
Copy link
Collaborator

Choose a reason for hiding this comment

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

In the future I assume we can replace STRIPE with !APPSTORE.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

await AccountManager().checkSubscriptionState()
}
#endif
}

func applicationDidBecomeActive(_ notification: Notification) {
Expand Down
4 changes: 4 additions & 0 deletions DuckDuckGo/Common/Localizables/UserText.swift
Original file line number Diff line number Diff line change
Expand Up @@ -982,5 +982,9 @@ struct UserText {
#if SUBSCRIPTION
static let subscriptionOptionsMenuItem = NSLocalizedString("subscription.menu.item", value: "Privacy Pro", comment: "Title for Subscription item in the options menu")
static let subscription = NSLocalizedString("preferences.subscription", value: "Privacy Pro", comment: "Show subscription preferences")

static let purchasingSubscriptionTitle = NSLocalizedString("subscription.progress.view.purchasing.subscription", value: "Purchase in progress...", comment: "Progress view title when starting the purchase")
static let restoringSubscriptionTitle = NSLocalizedString("subscription.progress.view.restoring.subscription", value: "Restoring subscription...", comment: "Progress view title when restoring past subscription purchase")
static let completingPurchaseTitle = NSLocalizedString("subscription.progress.view.completing.purchase", value: "Completing purchase...", comment: "Progress view title when completing the purchase")
#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
#if DBP && SUBSCRIPTION

import Foundation
import Account
import Subscription
import DataBrokerProtection

final class DataBrokerProtectionSubscriptionEventHandler {

private let accountManager: Account.AccountManaging
private let accountManager: Subscription.AccountManaging
private let authRepository: AuthenticationRepository

init(accountManager: Account.AccountManaging = Account.AccountManager(),
init(accountManager: Subscription.AccountManaging = Subscription.AccountManager(),
authRepository: AuthenticationRepository = KeychainAuthenticationData()) {
self.accountManager = accountManager
self.authRepository = authRepository
Expand All @@ -38,7 +38,7 @@ final class DataBrokerProtectionSubscriptionEventHandler {
}

@objc private func handleAccountDidSignIn() {
guard let token = accountManager.token else {
guard let token = accountManager.accessToken else {
Pixel.fire(.dataBrokerProtectionErrorWhenFetchingSubscriptionAuthTokenAfterSignIn)
assertionFailure("[DBP Subscription] AccountManager signed in but token could not be retrieved")
return
Expand Down
36 changes: 36 additions & 0 deletions DuckDuckGo/Localizable.xcstrings
Original file line number Diff line number Diff line change
Expand Up @@ -8186,6 +8186,42 @@
}
}
},
"subscription.progress.view.completing.purchase" : {
"comment" : "Progress view title when completing the purchase",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Completing purchase..."
}
}
}
},
"subscription.progress.view.purchasing.subscription" : {
"comment" : "Progress view title when starting the purchase",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Purchase in progress..."
}
}
}
},
"subscription.progress.view.restoring.subscription" : {
"comment" : "Progress view title when restoring past subscription purchase",
"extractionState" : "extracted_with_value",
"localizations" : {
"en" : {
"stringUnit" : {
"state" : "new",
"value" : "Restoring subscription..."
}
}
}
},
"Substitutions" : {
"comment" : "Main Menu Edit item"
},
Expand Down
2 changes: 1 addition & 1 deletion DuckDuckGo/Menus/MainMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import NetworkProtection
#endif

#if SUBSCRIPTION
import Subscription
import SubscriptionUI
#endif

// swiftlint:disable:next type_body_length
Expand Down
Loading
Loading