SwiftyStoreKit
SwiftyStoreKit copied to clipboard
Should I serialize calls to retrieveProductsInfo, verifyReceipt?
TL;DR: Should I call verifyReceipt in the completion handler of retrieveProductsInfo? Should I delay a call to purchaseProduct until verifyReceipt has returned? The log files seem to say these are all happening in order, but there could be log buffering issues.
Problem: About 2/3 of attempted purchase, in production, are failing with .paymentCancelled. We don't think they are all cancelling -- some logs show two or three attempts in succession. I'm not calling it a bug, but don't know quite what to call it. It is hard to duplicate in TestFlight/Sandbox.
Details: I am calling completeTransaction, retrieveProductsInfo, verifyReceipt, and purchaseProduct in that order. The first one's completion handler is never called; that's OK. RetrieveProductsInfo always returns (i.e. its completion handler is called) first, and correctly reports my product IDs. VerifyReceipt returns after that, with "not purchased" for all product IDs. The completion handler for purchaseProduct is returning .error about 2/3 of the time, almost always with .paymentCancelled.
I'm not saying that my setup is correct but I do:
User launches app -> completeTransaction()
User has previously subscribed -> verifyReceipt() on app launch every 3 days
User opens purchase view controller -> retrieveProductsInfo() and unhide purchase button
User clicks purchase button -> purchaseProduct() purchaseProduct() success handler -> verifyReceipt()