Kaloyan Roussev
Kaloyan Roussev

Reputation: 14711

In-App Billing: How to query the inventory after purchase, in order to get the price and currency code?

I am trying to obtain the price and the currency code after I've made a purchase using Google In-App Billing in my Android app.

Right after a successful purchase, I query the inventory for the same SKU but I get null

new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
        if (result.isFailure()) {
            return;
        } else if (purchase.getSku().equals(MY_SKU)) {
            if (purchase.getPurchaseState() == 0) {
                try {
                    Inventory inventory = appBillingHelper.queryInventory();
                    price = inventory.getSkuDetails(MY_SKU).getPrice(); // CRASHES WITH A NULL POINTER EXCEPTION for SkuDetails.
                    currencyCode = inventory.getSkuDetails(MY_SKU).getPriceCurrencyCode();

Upvotes: 0

Views: 876

Answers (1)

Related Questions