Hello!
I'm glad that Xcode 27.2 could fix many StoreKit testing issues (27.2 release notes).
While refreshing my unit tests for Xcode 27.2, I noticed a new behavior of "Ask to Buy" transactions. Since Xcode/iOS 27.2 at least, it seems that declining an Ask to Buy request in an SKTestSession makes StoreKit 2 record a purchase. Is this the intended new behavior?
To reproduce:
let session = try SKTestSession(configurationFileNamed: "ConfigFile")
session.askToBuyEnabled = true
session.resetToDefaultState()
session.disableDialogs = true
session.clearTransactions()
let result = try await product.purchase() // .pending
let pending = session.allTransactions().first! // state .deferred
try session.declineAskToBuyTransaction(identifier: pending.identifier)
// a few seconds later
for await t in Transaction.all { print(t.unsafePayloadValue) }
In my case the purchased product is an auto-renewable subscription with a free-trial intro offer, from a local .storekit file, in a unit test run inside a host app.
After the decline, I could observe the following
- iOS 26.2 simulator
SKTestTransaction.state=.deferredTransaction.updates: nothingTransaction.all: empty
- iOS 27.2 simulator
SKTestTransaction.state=.failedTransaction.updates: emits a transactionTransaction.all: 1 transaction:ownershipType = .purchased,reason = .purchase, no revocation, expires at the end of the trial.
The test session marks the request as failed, yet StoreKit 2 reports an active subscription...
My understanding was that a declined "Ask to Buy" request never produces a transaction. With the new behavior, apps relying on Transaction.all or currentEntitlements would grant access that the Apple user refused...
Is the new behavior expected? Or is it a regression (and is it limited to SKTestSession) ?
Thanks for your help!