I am implementing auto-renewable subscriptions in my iOS app. My transaction handling looks something like this pseudocode:
func paymentQueue(_queue: SKPaymentQueue, updatedTransactions transactions:[SKPaymentTransaction]) {
for (t in transactions) {
let data = Data(contentsOf: getReceiptUrl())
//this is actually async, but for simplicity here it's just a straight return
if verifyReceiptWithServer(data) == .success {
print("Verified receipt successfully!")
}
queue.finishTransaction(t)
}
}
If a subscription renews more than once while my app isn't active, I could get more than one transaction per product here. Sometimes the app also gets a lot of old transactions at once on reinstall. Do I need to verify every transaction? Or is it better to do just one per productIdentifier
? Or maybe even just once per call to paymentQueue:updatedTransactions:
? If the receipt data on disk is the same the whole time, then I'm sending the same binary data to my server every time, and it can be a lot sometimes.
Documentation links are appreciated in answers.
For subscriptions, you could just make 1 call for all transactions. What's important is that you are validating entitlements off the receipt. So as long as your server is looking at the whole receipt, you should be good.
For other IAP types, it's after to verify for each updated transaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With