j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.29k stars 529 forks source link

[Android] store.localTransactions doesn't return consumed consumable transactions #1558

Closed AEiosApp closed 3 weeks ago

AEiosApp commented 3 weeks ago

Observed behavior

I have both NON-CONSUMABE & CONSUMABLE in app purchases in my app.

This code returns me a list of transactions for purchased NON-CONSUMABE products, however - it doesn't return transactions for CONSUMABLE products that were already consumed by user.

CdvPurchase.store
        .when()
        .productUpdated((product) => {}))
        .receiptsReady(() => {
          console.log(
            `#iaptest receiptsReady localTransactions:\n${JSON.stringify(
              CdvPurchase.store.localTransactions
            )}`
          );
         })

Expected behavior

Is there any option to get all purchases made by user? (to get a list of transactions of consumed purchases)

If not, please suggest(!!!):

P.S. Apple doesn't allow to force user to register in your app to be able to make any in app purchase.

🤷‍♂️

System Info

Plugin version 13.10.1.

AEiosApp commented 3 weeks ago

Sorry, just found that Apple doesn't allow to restore consumable purchases. Just in case anybody will face same issue:

What happens if the user uses a subset of the lives, say, 5, and then deletes the app, reinstalls, and restores purchases?Apple will tell the user that they purchased a set of 10 lives, and my program will happily oblige and give them 5 extra lives.

No! the consumable products cannot be restored. Even if you provide a Restore IAP, consumable products cannot be restored back. So your concern that the user will get 5 extra lives is baseless, but yes you need to keep track of the lives that are used by the user if your app is syncing data with server.

Here is what Apple docs say,

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Products.html#//apple_ref/doc/uid/TP40008267-CH2-SW2

Consumable products, by their nature, aren’t synced or restored. Users understand that, for example, buying ten more bubbles on their iPhone doesn’t also give them ten more bubbles on their iPad. All other types of products are made available across all of the user’s devices. They’re also restored so users can continue to access their purchased content even after buying a new device. Store Kit handles the syncing and restoring process for auto-renewable and free subscriptions and for non-consumable products.

Products that expire or get used up—consumable products, auto-renewable subscriptions, and non-renewing subscriptions—can be purchased multiple times to get the consumable item again or extend the subscription.

image

source: https://stackoverflow.com/a/42600091/6534130