j3k0 / cordova-plugin-purchase

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

Questions regarding the ios restorePurchases function #1467

Open heffthedev opened 1 year ago

heffthedev commented 1 year ago

The restorePurchases ios function completes quickly and only later on the actual process is being run in the background / server side. I'd love some pointers regarding two things:

  1. How to track when the restorePurchases function has run and is finished?
  2. How to track errors on the appleStore side that I can see when using CDVPurchase debug output so I can tell the user that his restorePurchases try didn't work out?

Also I have to run this function on ios to complete purchses made after each other (shopping cart functionality) at the end of the process or the verification of anything but the first purchase is not being run correctly. This could be related to #1466 but I haven't been able to confirm this yet. When using the update() function instead it does not work.

j3k0 commented 1 year ago
  1. If you have a receipt validation service, a good solution is to wait for a call to store.when().verified() or unverified.
  2. It looks like restorePurchases() doesn't report errors at the moment, I'll work on that.
heffthedev commented 1 year ago

Thanks for the reply! From the way I understand it, the restorePurchases function goes through all existing transactions and verifies them once more, right? So when I listen to when().verified() in case of many previous product-transactions, it should also be triggered many times - but how to determine when the last one has been triggered?

j3k0 commented 1 year ago

All transactions will be "approved", since all those transactions are in the same receipt (that's the way it is with AppStore), there will be a since receipt validation, you'll get a single call to "verified" (which takes the verified receipt as a parameter).

tolutronics commented 1 year ago

Listening to when().verified() gave the receipt, However, upon validation form apple server, I got an error.

Receipt is mailformed Error: 21002

j3k0 commented 11 months ago

Maybe you're testing with local products (defined in XML)? in that case the receipt is not verifiable server-side?