I'm having this same issue on a simulator. I'm using Xcode 12.2 and simulator 14.2.
I did the setup as in https://developer.apple.com/documentation/xcode/setting_up_storekit_testing_in_xcode
and I'm testing a subscription purchase and the error happens right after payment confirmation screen.
When I printed out the transaction error I got the following
(lldb) po transaction.error
Error Domain=NSCocoaErrorDomain Code=4097 "connection to service on pid 25563 named com.apple.storekitservice" UserInfo={NSDebugDescription=connection to service on pid 25563 named com.apple.storekitservice}
Is there a way to fix it? Did I missed some config step>