SKTestSession.clearTransactions() does not seem to clear finishing transactions

Number:rdar://FB9814502 Date Originated:Dec 20, 2021 at 3:41 AM
Status:Open Resolved:
Product:StoreKit Testing in Xcode Product Version:
Classification: Reproducible:
I wrote a minimal test case reproducing this issue.

This test case just purchases a product and confirm that SKPaymentTransactionObserver's callback methods are called as expected.
I call `[SKTestSession clearTransactions]` before each test case runs, and finishes purchased transactions before each test case finishes.
Although the test case passes if run only once, it often fails if repeatedly run.

The reason why it fails is `purchasing` transaction is missing and only `purchased` transaction comes.

I investigated system log of appstored with `$ log stream --predicate 'subsystem == "appstored"'` and found it says -

> Error finishing payment 915 for com.github.manicmaniac.StoreKitTestingExample - Error Domain=AMSErrorDomain Code=301 "Invalid Status Code" UserInfo={NSLocalizedFailureReason=The response has an invalid status code, AMSURL=http://localhost:49402/WebObjects/MZFinance.woa/wa/inAppTransactionDone?REDACTED, AMSStatusCode=404, AMSServerPayload={
>     error = "Transaction not found";
> }, NSLocalizedDescription=Invalid Status Code}

only at the time of test failure.

As a trial, I inserted 0.25 sec wait after each invocation of `[SKPaymentQueue finishTransaction:]`, then the problem has gone.
I think somehow transactions remains after invoking `[SKTestSession clearTransactions]` when `[SKPaymentQueue finishTransaction:]` is called.
Please list the steps you took to reproduce the issue:
1. clone my repo (
2. run test and see it passes
3. delete ` Date(timeIntervalSinceNow: 0.25))` at L24 in AutoRenewableTests.swift
4. run test again and see it fails
What did you expect to happen?
- The test case passes without waiting for anything
- `[SKTestSession clearTransactions]` clears all transactions including finishing transactions so that `purchasing` and `purchased` transactions comes in this order
- Or this behavior is documented in API reference
What actually happened?
- The test case fails when I remove 0.25 sec wait
- `purchasing` transaction was missing and only `purchased` transaction comes


Finally Apple's reply has come at Aug 12, 2022.

After reviewing your feedback, we have some additional information for you, or some additional information, or action is necessary for this issue:

Please verify this issue with iOS 16 beta 5 and update your bug report with your results by logging into or by using the Feedback Assistant app.

iOS 16 beta 5 (20A5339d) Posted Date: August 8, 2022

Note: Before testing your software on your device, make sure to enableDeveloper Mode ( in Settings > Privacy & Security.

If the issue persists, please attach a new sysdiagnose captured in the latest build and attach it to the bug report. Thank you.

iOS sysdiagnose Instructions:

For a complete list of logging instructions visit:

Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!