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());
    }
});

Functions

Link copied to clipboard
abstract fun onNewPurchase(productId: String, purchase: PurchaseResult)
Called when a new purchase is completed and acknowledged.
Link copied to clipboard
abstract fun onPurchaseConsumed(productId: String, purchase: PurchaseResult)
Called when a purchase is consumed (for consumable products).