Skip to content

Conversation

@koke
Copy link
Member

@koke koke commented Nov 16, 2022

Closes: #8130

Description

This updates the InAppPurchasesForWPComPlansProtocol.purchaseProduct so it returns the actual PurchaseResult and the site creation flow is able to differentiate a successful purchase from a pending one or a user cancellation.

Testing instructions

  1. Go to Hub menu > IAP Debug
  2. Tap on a product to purchase
  3. Dismiss the IAP modal and notice a Purchase result: userCancelled message in the console
  4. Tap on a product to purchase
  5. Complete the purchase and notice a Purchase result: success(... message in the console

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

@koke koke added type: task An internally driven task. feature: in-app purchases Related to In-app purchases and subscriptions labels Nov 16, 2022
@koke koke added this to the 11.3 milestone Nov 16, 2022
@koke koke requested review from jaclync and toupper November 16, 2022 10:33
@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


func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws {
_ = try await withCheckedThrowingContinuation { continuation in
func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws -> StoreKit.Product.PurchaseResult {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to keep StoreKit references inside the boundaries of the IAP interface if possible, so their clients don't have to even import it. That way we have WPComPlanProduct that acts as a facade of the StoreKit.Product, hiding any details about StoreKit. Can we do the same with StoreKit.Product.PurchaseResult? With a protocol or a typealias?

typealias PurchaseResult = StoreKit.Product.PurchaseResult

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good call, I'll add that

Copy link
Member Author

Choose a reason for hiding this comment

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

Added in ded8c4c

@toupper
Copy link
Contributor

toupper commented Nov 16, 2022

Thanks for this addition! Now the purchase outcome is more meaningful. :shipit:

@koke koke enabled auto-merge November 16, 2022 10:50
@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 pr8133-ded8c4c on your iPhone

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

@koke koke merged commit 4b21955 into trunk Nov 16, 2022
@koke koke deleted the issue/8130-iap-expose-purchase-result branch November 16, 2022 11:11
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.

[In-app Purchases] Include PurchaseResult in the result of a purchase

4 participants