diff --git a/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesDebugView.swift b/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesDebugView.swift index 8156961b7e4..7b70ca0b11e 100644 --- a/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesDebugView.swift +++ b/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesDebugView.swift @@ -1,5 +1,4 @@ import SwiftUI -import StoreKit import Yosemite @MainActor @@ -37,7 +36,8 @@ struct InAppPurchasesDebugView: View { Task { isPurchasing = true do { - try await inAppPurchasesForWPComPlansManager.purchaseProduct(with: product.id, for: siteID) + let result = try await inAppPurchasesForWPComPlansManager.purchaseProduct(with: product.id, for: siteID) + print("[IAP Debug] Purchase result: \(result)") } catch { purchaseError = PurchaseError(error: error) } diff --git a/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesForWPComPlansManager.swift b/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesForWPComPlansManager.swift index bef52e34911..011f3bfd235 100644 --- a/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesForWPComPlansManager.swift +++ b/WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesForWPComPlansManager.swift @@ -15,6 +15,8 @@ protocol WPComPlanProduct { extension StoreKit.Product: WPComPlanProduct {} +typealias InAppPurchaseResult = StoreKit.Product.PurchaseResult + protocol InAppPurchasesForWPComPlansProtocol { /// Retrieves asynchronously all WPCom plans In-App Purchases products. /// @@ -33,7 +35,7 @@ protocol InAppPurchasesForWPComPlansProtocol { /// id: the id of the product to be purchased /// remoteSiteId: the id of the site linked to the purchasing plan /// - func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws + func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws -> InAppPurchaseResult /// Retries forwarding the product purchase to our backend, so the plan can be unlocked. /// This can happen when the purchase was previously successful but unlocking the WPCom plan request @@ -73,8 +75,8 @@ final class InAppPurchasesForWPComPlansManager: InAppPurchasesForWPComPlansProto } } - 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 -> InAppPurchaseResult { + try await withCheckedThrowingContinuation { continuation in stores.dispatch(InAppPurchaseAction.purchaseProduct(siteID: remoteSiteId, productID: id, completion: { result in continuation.resume(with: result) }))