cordova-plugin-purchase icon indicating copy to clipboard operation
cordova-plugin-purchase copied to clipboard

Questions regarding the ios restorePurchases function

Open heffthedev opened this issue 1 year ago • 5 comments

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.

heffthedev avatar Sep 14 '23 21:09 heffthedev

  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.

j3k0 avatar Oct 16 '23 14:10 j3k0

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?

heffthedev avatar Oct 25 '23 22:10 heffthedev

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).

j3k0 avatar Nov 01 '23 13:11 j3k0

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

Receipt is mailformed Error: 21002

tolutronics avatar Nov 15 '23 12:11 tolutronics

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

j3k0 avatar Dec 01 '23 08:12 j3k0