Unable to verify restored purchases

I am using IAP in my app for non-consumable products. I am facing the issue to verify the restored purchases of the user. I understand the concept that when a user purchases something a unique appStoreReceiptURL is saved in the app bundle but it is there as long as the user does not un-install the app and I am also setting the status and the transaction id on the server. Now when the user has purchased something on one device and he has logged into some other device I can get the status from the server and show him the premium content, but what if the user has cancelled the subscription from his Apple ID not from the app? In this case the status key is still set true. I am restoring the purchases whenever the user log in the app but I cannot find a way to validate those purchases. If anyone knows how to validate those? Thanks in advance.

For non-consumables you can become aware of it being refunded/revoked in multiple ways:

  • On-demand use VerifyReceipt or the App Store Server API (Refund Lookup & History) to see transactions and their status.
  • Receive near-real-time notifications of an applicable status change with Server Notifications (v1 and v2).
  • StoreKit2 always provides local methods to retrieve current status (currentEntitlements)

I am restoring the purchases whenever the user log in the app

Don't do that, App Review will reject it (if they find it). Restore Purchases should always be initiated by the user pressing a button.

Unable to verify restored purchases
 
 
Q