Skip to content

Conversation

@toupper
Copy link
Contributor

@toupper toupper commented Nov 14, 2022

Closes: #8110

Description

Previously, we used the default app site id when debugging In-App purchases and plans, which didn't make much sense because that site was either a wp.com with an e-commerce plan active or a self-hosted site, and thus not eligible for new plans.
When testing IAP plans, we want a wp.com site without a plan, so, to test that, we have added a Xcode environment variable in this PR. This way we can easily set the site id we want to use to that environment variable and test the whole process.

Testing instructions

No test id set

Run the app without setting a site id in the environment variable, or entering it with the wrong format e.g string. Go to the IAP Debug menu. After the products are loaded, you should see the warning explaining that the site couldn't be retrieved, and you shouldn't be able to purchase any product:

Test id set

If you set a valid site id, the IAP Debug screen should show the products and you should be able to trigger a product purchase with the site id set in the environment variable. To verify that that, you can set a breakpoint in InAppPurchasesForWPComPlansManager.swift, func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws, and inspect the remoteSiteId variable.

Screenshots

See above

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

@toupper toupper added type: task An internally driven task. feature: in-app purchases Related to In-app purchases and subscriptions labels Nov 14, 2022
@toupper toupper added this to the 11.3 milestone Nov 14, 2022
@toupper toupper requested a review from koke November 14, 2022 11:49
@wpmobilebot
Copy link
Collaborator

wpmobilebot commented Nov 14, 2022

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 pr8111-352a970 on your iPhone

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

Copy link
Member

@koke koke left a comment

Choose a reason for hiding this comment

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

Works fine. The new variable didn't initially appear in my Xcode scheme for some reason and I had to add it manually but it works after that.

}

private enum Constants {
static let siteIdEnvironmentVariableName = "iap-debug-site-id-purchase-param"
Copy link
Member

Choose a reason for hiding this comment

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

Nitpicky, but maybe iap-debug-site-id is descriptive enough

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Indeed! That name is simpler and descriptive enough

@peril-woocommerce
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 2 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@toupper toupper enabled auto-merge November 15, 2022 10:32
@toupper toupper merged commit 64979b3 into trunk Nov 15, 2022
@toupper toupper deleted the issue/8110-site-id-xcode-env-variable-iap branch November 15, 2022 11:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature: in-app purchases Related to In-app purchases and subscriptions type: task An internally driven task.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add a Xcode environment variable for site id in debug screen

4 participants