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

Documentation issue/question #1510

Closed viking2917 closed 3 months ago

viking2917 commented 5 months ago

Observed behavior

The Gitbook documentation Micro Example is mildly confusing to me, and perhaps misleading. The example says:

store.when()
    .productUpdated(refreshUI)
    .approved(finishPurchase);

and

function finishPurchase(p) {
  localStorage.goldCoins = (localStorage.goldCoins | 0) + 10;
  p.finish();
  refreshUI();
}

It seems to imply that the approved handler returns a product - p - instead of a transaction.

I am in the process of migrating from v11 to v13, and at least as far as I know, with version 13, it's a transaction that gets a finish(). So should this be written as:?

function finishPurchase(transaction) {
  localStorage.goldCoins = (localStorage.goldCoins | 0) + 10;
  transaction.finish();
  refreshUI();
}

I could not see a way to submit a pull request on the gitbook, but if there is a way, I am happy to submit a change.

Expected behavior

System Info

MarcelSchuermann commented 4 months ago

Good point. I also think the micro example could be improved.

edit: With the when.receiptUpdated() function I get an object of class "Receipt" This receipt consists of multiple transactions.

so I would call it when.productUpdated(product) when.receiptUpdated(receipt)

API-Definition of Receipt: https://github.com/j3k0/cordova-plugin-purchase/blob/v13/api/classes/CdvPurchase.Receipt.md

I have the problem, that in iOS for a subscription after I successfully subscribed and close the app, reopen it - the purchase is no further recognized. How can I change that?

I can only see the app transaction popping up in the .approve event, not the IAP-transaction.

Any idea on this? @j3k0?

j3k0 commented 3 months ago

@MarcelSchuermann You can check https://j3k0.github.io/cordova-subscription-example/ for a full working example. It's a different issue so I will close this one.