Skip to content

Conversation

@jaclync
Copy link
Contributor

@jaclync jaclync commented Dec 13, 2022

First iteration for #8392

Description

Why

Please see the background in p1670855348591299/1670855146.255439-slack-C0354HSNUJH. I'm going with option 1 since I'm AFK soon, and don't want our app to be blocked from release. We can update the UX later after design confirmation.

Implementation

In StoreCreationCoordinator, it currently throws various PlanPurchaseErrors at the beginning after checking a series of IAP conditions:

let inProgressView = createIAPEligibilityInProgressView()
let storeCreationNavigationController = WooNavigationController(rootViewController: inProgressView)
presentStoreCreation(viewController: storeCreationNavigationController)
guard await purchasesManager.inAppPurchasesAreSupported() else {
throw PlanPurchaseError.iapNotSupported
}
let products = try await purchasesManager.fetchProducts()
let expectedPlanIdentifier = featureFlagService.isFeatureFlagEnabled(.storeCreationM2WithInAppPurchasesEnabled) ?
Constants.iapPlanIdentifier: Constants.webPlanIdentifier
guard let product = products.first,
product.id == expectedPlanIdentifier else {
throw PlanPurchaseError.noMatchingProduct
}
guard try await purchasesManager.userIsEntitledToProduct(with: product.id) == false else {
throw PlanPurchaseError.productNotEligible
}
startStoreCreationM2(from: storeCreationNavigationController, planToPurchase: product)

Then in the catch closure, we currently show the M1 webview if there's an error. However, when we launch IAP with the storeCreationM2WithInAppPurchasesEnabled feature flag enabled, we can't fall back to the webview implementation. Therefore, I updated the error handling to show an alert if the storeCreationM2WithInAppPurchasesEnabled feature flag is enabled.

In order to not present the alert before the in-progress view is presented in case the result comes back immediately like when using a mock MockInAppPurchases, I updated the presentStoreCreation function to async to wait for the presentation completion.

Testing instructions

It's the easiest to test with a mock implementation using MockInAppPurchases.

IAP is not supported

  • In code, change this line to return MockInAppPurchases(isIAPSupported: false). Also, in DefaultFeatureFlagService, return true for storeCreationM2WithInAppPurchasesEnabled feature flag
  • Launch the app
  • Log in if needed
  • Go to the Menu tab, and tap Switch store
  • On the store picker, tap + Add a store
  • Tap Create a new store --> the in-progress view should be shown first. after a bit, an alert should be shown that indicates store creation isn't supported for the country

User is already entitled to the plan

  • In code, change this line to return MockInAppPurchases(userIsEntitledToProduct: true). Also, in DefaultFeatureFlagService, return true for storeCreationM2WithInAppPurchasesEnabled feature flag
  • Launch the app
  • Log in if needed
  • Go to the Menu tab, and tap Switch store
  • On the store picker, tap + Add a store
  • Tap Create a new store --> the in-progress view should be shown first. after a bit, an alert should be shown that indicates store creation isn't supported because their account is already associated with another store

Other errors, like product cannot be fetched

  • In code, change this line to return MockInAppPurchases(products: []). Also, in DefaultFeatureFlagService, return true for storeCreationM2WithInAppPurchasesEnabled feature flag
  • Launch the app
  • Log in if needed
  • Go to the Menu tab, and tap Switch store
  • On the store picker, tap + Add a store
  • Tap Create a new store --> the in-progress view should be shown first. after a bit, an alert should be shown that indicates store creation isn't supported in the app

  • @jaclync tests with actual IAP following the testing guide in PdfdoF-1Ej-p2

Screenshots

Please feel free to suggest any improvements to the copy:

IAP not supported user already purchased the plan any other errors
Simulator Screen Shot - iPhone 14 Pro - 2022-12-13 at 14 46 11 Simulator Screen Shot - iPhone 14 Pro - 2022-12-13 at 14 48 16 Simulator Screen Shot - iPhone 14 Pro - 2022-12-13 at 14 49 19

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

@jaclync jaclync added type: task An internally driven task. status: feature-flagged Behind a feature flag. Milestone is not strongly held. labels Dec 13, 2022
@jaclync jaclync added this to the 11.7 milestone Dec 13, 2022
@wpmobilebot
Copy link
Collaborator

You can test the changes from this Pull Request by:
  • Clicking here or scanning the QR code below to access App Center
  • Then installing the build number pr8393-bda4164 on your iPhone

If you need access to App Center, please ask a maintainer to add you.

@selanthiraiyan selanthiraiyan self-assigned this Dec 14, 2022
Copy link
Contributor

@selanthiraiyan selanthiraiyan left a comment

Choose a reason for hiding this comment

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

Everything works as described in the testing steps. 🚢

navigationController.dismiss(animated: true) { [weak self] in
self?.navigationController.present(viewController, animated: true)
@MainActor
func presentStoreCreation(viewController: UIViewController) async {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice idea making this async. 👏

@jaclync jaclync merged commit e81d612 into trunk Dec 14, 2022
@jaclync jaclync deleted the issue/8392-iap-ineligible branch December 14, 2022 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status: feature-flagged Behind a feature flag. Milestone is not strongly held. type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants