PurchaseHistoryListener
interface PurchaseHistoryListener
Listener interface for purchase history events. Implement this to track and persist purchase history in your app.
Since Google Play Billing Library 8+ deprecated queryPurchaseHistoryAsync, consumed purchase tracking must be done by your app. Use these callbacks to persist purchase events and build your own purchase history.
Example usage:
AppPurchase.getInstance().setPurchaseHistoryListener(new PurchaseHistoryListener() {
@Override
public void onNewPurchase(String productId, PurchaseResult purchase) {
// Save to your database/preferences
savePurchase(productId, purchase.getQuantity(), purchase.getPurchaseTime(), false);
}
@Override
public void onPurchaseConsumed(String productId, PurchaseResult purchase) {
// Mark as consumed in your database
markConsumed(productId, purchase.getOrderId());
}
});
Content copied to clipboard