j3k0 / cordova-plugin-purchase

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

Android Question for Consumable Products and the transaction property #882

Closed francois-dibulo closed 5 years ago

francois-dibulo commented 5 years ago

Hi there,

I am having trouble to understand a thing about consumable products.

When I buy a renewable-subscription, restart the app, and ask for the products, which I have purchased on the device, I get the Product with all the transaction data and receipt. (since product is owned=true and it has the transaction data)

After approving a Consumable product (basically our 1-Year-Pass), the product's transaction field is NOT empty.

However, as soon as I query my products (store.products), right after calling finish, the Consumable product doesn't have any of the transaction data (= null) anymore. Same if I just restart the app and do the whole refresh call etc again.

Is there any way to load all purchased items from that device? Like a purchase history and get the transaction data, so we can send it to Google and verify it?

Or maybe in other words: how should something like a year-pass be implemented?

Maybe I am just missing a simple call?

Thanks a lot for any help!

My code looks (simplified) like this:

// Bind handlers and initialize
store.when('product')
  .approved => product.verify()
  .verified => product.finish()

store.register([...])
store.validator = function(product, callback) {
  if (product && product.valid) {
      product.finish();
      callback(true, product);
  }
}
store.refresh()

NOTE: I always buy with registered sandbox-account

francois-dibulo commented 5 years ago

I basically just understood that I shouldn't call product.finish() until it expired.