I'm trying to create a "Restore" button (just like in iOS) so the user can restore his previous purchases. I'm using the code below, but List<Purchase> list comes back empty. I made a real purchase with a credit card, then I delete the app and reinstall from the Google Play Store, but I can't get it the "Restore" button to work. Here is the code I'm using for my "Restore" button:
private void restorePreviousPuchases () {
billingClient.queryPurchasesAsync(BillingClient.SkuType.INAPP, new PurchasesResponseListener() {
@Override
public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) {
if (list != null) {
for (Purchase purchase : list) {
ArrayList<String> skus = purchase.getSkus();
if (skus != null) {
for (String sku : skus) {
setPurchasedItem(sku);
}
}
}
} else {
Log.d("DEBUGGING...", "onCreate: NULL purchaseList" );
}
}
});
}