I have a macOS app with auto-renewable subscription. I'm reading the docs and cannot fully understand the concept. According to the docs I have to add and observer to the payment queue. I have to provide a restore function to restore a purchase if the app was reinstalled. My observer is listening to the queue and it gets restored transactions once I call SKPaymentQueue.default().restoreCompletedTransactions() method. However, I cannot see if the subscription expired or not just using the observer. Transaction objects which I reecive in the payment queue have only some abstract transaction ID.
The docs recommend to validate a receipt. I'm sending base64 encoded receipt to my server which in turns sends it to verifyReceipt endpoint. Even if I send an old receipt, Apple responds with JSON containing latest_receipt_info where I can see the current status of subscription and it's expiration date. I can assume that subscription is not active if expiration date is earlier than the current date.
The question is why I have to call SKPaymentQueue.default().restoreCompletedTransactions() method to restore a purchase if I can refresh the receipt (if it's missing) and send it to my server and get the recent info? It seems to me that it is redundant. So my usage is:
- Listen to the payment queue
- Perform receipt validation as soon as I get transaction with purchased state and unlock paid functionality if I see a transaction with specific productId and expiration date later than the current date
- Perform receipt validation when user clicks Restore button and unlock paid functionality if I see a transaction with specific productId and expiration date later than the current date
- Perform receipt validation on every launch of the application to check the subscription status
- Perform receipt validation every 12 or 24 hours to disable paid functionality if the app was not closed but the subscription already expired
Did I clearly understood the concept or am I missing something here because I don't see the benefit of calling SKPaymentQueue.default().restoreCompletedTransactions() method?