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

Support expired subscription state and subscription repurchase #2707

Merged
merged 15 commits into from
May 3, 2024
Merged
4 changes: 2 additions & 2 deletions DuckDuckGo.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12747,8 +12747,8 @@
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/duckduckgo/BrowserServicesKit";
requirement = {
kind = exactVersion;
version = 140.0.1;
branch = "michal/stripe-repurchase";
kind = branch;
};
};
9FF521422BAA8FF300B9819B /* XCRemoteSwiftPackageReference "lottie-spm" */ = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/duckduckgo/BrowserServicesKit",
"state" : {
"revision" : "b1501e60d245625d4a5d42a61b329364134f0879",
"version" : "140.0.1"
"branch" : "michal/stripe-repurchase",
"revision" : "ebd554e54e0c155b237b7dca0a25399047b34892"
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,12 @@ final class SubscriptionPagesUseSubscriptionFeature: Subfeature {
}

func getSubscription(params: Any, original: WKScriptMessage) async throws -> Encodable? {
if let authToken = accountManager.authToken, accountManager.accessToken != nil {
guard let accessToken = accountManager.accessToken,
let authToken = accountManager.authToken
else { return Subscription(token: "") }

if case .success(let subscription) = await SubscriptionService.getSubscription(accessToken: accessToken),
subscription.isActive {
return Subscription(token: authToken)
} else {
return Subscription(token: "")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,13 @@ public struct PreferencesSubscriptionView: View {
TextMenuItemCaption(UserText.preferencesSubscriptionExpiredCaption)
} buttons: {
// We need to improve re-purchase flow
/* Button(UserText.viewPlansButtonTitle) { model.purchaseAction() }
.buttonStyle(DefaultActionButtonStyle(enabled: true)) */
Button(UserText.viewPlansExpiredButtonTitle) { model.purchaseAction() }
.buttonStyle(DefaultActionButtonStyle(enabled: true))
Menu {
Button(UserText.addToAnotherDeviceButton) {
model.userEventHandler(.addToAnotherDeviceClick)
showingSheet.toggle()
}
Button(UserText.removeFromThisDeviceButton, action: {
showingRemoveConfirmationDialog.toggle()
})
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ enum UserText {

static let addToAnotherDeviceButton = NSLocalizedString("subscription.preferences.add.to.another.device.button", value: "Add to Another Device…", comment: "Button to add subscription to another device")
static let manageSubscriptionButton = NSLocalizedString("subscription.preferences.manage.subscription.button", value: "Manage Subscription", comment: "Button to manage subscription")
static let changePlanOrBillingButton = NSLocalizedString("subscription.preferences.change.plan.or.billing.button", value: "Change Plan or Billing...", comment: "Button to add subscription to another device")
static let removeFromThisDeviceButton = NSLocalizedString("subscription.preferences.remove.from.this.device.button", value: "Remove From This Device...", comment: "Button to remove subscription from this device")
static let changePlanOrBillingButton = NSLocalizedString("subscription.preferences.change.plan.or.billing.button", value: "Change Plan or Billing", comment: "Button to add subscription to another device")
static let removeFromThisDeviceButton = NSLocalizedString("subscription.preferences.remove.from.this.device.button", value: "Remove From This Device", comment: "Button to remove subscription from this device")

// MARK: Preferences when subscription is inactive
static let preferencesSubscriptionInactiveHeader = NSLocalizedString("subscription.preferences.subscription.inactive.header", value: "Subscribe to Privacy Pro", comment: "Header for the subscription preferences pane when the subscription is inactive")
Expand All @@ -81,6 +81,7 @@ enum UserText {
// MARK: Preferences when subscription is expired
static let preferencesSubscriptionExpiredCaption = NSLocalizedString("subscription.preferences.subscription.expired.caption", value: "Subscribe again to continue using Privacy Pro.", comment: "Caption for the subscription preferences pane when the subscription activation is pending")

static let viewPlansExpiredButtonTitle = NSLocalizedString("subscription.preferences.button.view.plans", value: "View Plans…", comment: "Button for viewing subscription plans on expired subscription")
static let manageDevicesButton = NSLocalizedString("subscription.preferences.manage.devices.button", value: "Manage Devices", comment: "Button to manage devices")

// MARK: - Change plan or billing dialogs
Expand Down
Loading