Detect if a user refunded a 'consumable' in app purchase item (Apple app store in app purchase system)
A year ago I had the same question as you and I have found this thread where author said that Apple has not added a way to detect canceled purchases. I'm still living with that as it is.
The best way to know it is contacting Apple technical support, each account has 2 request/year, so I recommend you to write there.
Hope you will find the answer and tell us about the result.
https://developer.apple.com/documentation/storekit/in-app_purchase/handling_refund_notifications Apple has provided a solution finally in 2020!!