How to detect refund for paid app?

I noticed a very weird behavior for refunds. When a user refunds an up-front paid app, they still have access to the app. How can I detect such a case and block access to the app?

In general, I think it should be handled by Apple, but for some reason, they don't do it.

There may be a way now. The iOS 27 SDK added AppTransaction.revocationDate ("The revocation date of the app purchase"), and it is back-deployed to iOS 16.

It is not confirmed yet that a normal App Store refund sets it. It may only cover app licenses that an organization takes back. Related thread: https://developer.apple.com/forums/thread/852203