google play store restore purchase

i’m on the google store
I uploaded the game as a beta version.
Non-Consumable in-app products were sold to users,
When the beta test period is over, we plan to initialize user information.
At this time, the payment history of users who purchased non-consumable in-app products
I want to restore it.

However, no matter how much I search, it is difficult to find information about recovery of payment history.
One thing I found was that the user reinstalled the app to fix it,
I don’t want to give users this inconvenience…

Another way I found is to implement it like the code below,
The problem is, I don’t know how to distinguish the product ID.
(In case of multiple non-consumable products)
Any solution?

Please note that my case is a very special situation.
Sell non-consumable in-app products only during the beta test period,
Because it will not be sold in the official version,
In a situation where a user has a non-consumable product, the same in-app product
How to restore the purchase through the purchase failed event when the purchase button is clicked
can not use.

Is there anyone…?