Skip to content

Commit 54fdec4

Browse files
committed
Include purchase result in purchaseProduct API
1 parent c43372b commit 54fdec4

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesDebugView.swift

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ struct InAppPurchasesDebugView: View {
3737
Task {
3838
isPurchasing = true
3939
do {
40-
try await inAppPurchasesForWPComPlansManager.purchaseProduct(with: product.id, for: siteID)
40+
let result = try await inAppPurchasesForWPComPlansManager.purchaseProduct(with: product.id, for: siteID)
41+
print("[IAP Debug] Purchase result: \(result)")
4142
} catch {
4243
purchaseError = PurchaseError(error: error)
4344
}

WooCommerce/Classes/ViewRelated/InAppPurchases/InAppPurchasesForWPComPlansManager.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protocol InAppPurchasesForWPComPlansProtocol {
3333
/// id: the id of the product to be purchased
3434
/// remoteSiteId: the id of the site linked to the purchasing plan
3535
///
36-
func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws
36+
func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws -> StoreKit.Product.PurchaseResult
3737

3838
/// Retries forwarding the product purchase to our backend, so the plan can be unlocked.
3939
/// This can happen when the purchase was previously successful but unlocking the WPCom plan request
@@ -73,8 +73,8 @@ final class InAppPurchasesForWPComPlansManager: InAppPurchasesForWPComPlansProto
7373
}
7474
}
7575

76-
func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws {
77-
_ = try await withCheckedThrowingContinuation { continuation in
76+
func purchaseProduct(with id: String, for remoteSiteId: Int64) async throws -> StoreKit.Product.PurchaseResult {
77+
try await withCheckedThrowingContinuation { continuation in
7878
stores.dispatch(InAppPurchaseAction.purchaseProduct(siteID: remoteSiteId, productID: id, completion: { result in
7979
continuation.resume(with: result)
8080
}))

0 commit comments

Comments
 (0)