Post

Replies

Boosts

Views

Activity

Reply to Cannot handle unfinished consumable in Transaction.currentEntitlements when testing Ask to Buy in Xcode
Thank you for the reply. I still don't understand. In the code above, I try to deliver consumable product before I call transaction.finish(). I'm testing for Ask to Buy and I'm not calling transaction.finish() before the transaction approval. (When the purchase result is .pending I don't call transaction.finish() as shown in the code below)     func purchase(_ info: ConsumableProductInfo) async throws {         let result: Product.PurchaseResult         switch info {         case .coffee:             guard let coffeeProduct else { return }             result = try await coffeeProduct.purchase()         }         switch result {         case let .success(verificationResult):             switch verificationResult {             case let .verified(transaction):                 await refreshPurchasedProducts()               // Deliver consumable products because it couldn't be handled in `refreshPurchasedProducts()`                 if case .consumable = transaction.productType {                     updateConsumablePurchaseCount(productID: transaction.productID)                 }                 await transaction.finish()             case let .unverified(_, verificationError):                 throw verificationError             }         case .pending, .userCancelled:             break         @unknown default:             break         }     } I found a blog post that is similar to this problem: https://iosexample.com/implementing-and-testing-in-app-purchases-with-storekit2-in-xcode-13-swift-5-5-and-ios-15/ It says that "In tests I've done transactions for consumables do not remain in the receipt, even if you omit to call finish()." So I wonder if this is a bug or problem in Xcode testing.
Nov ’22