Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I have to verify the receipt for every SKPaymentTransaction for subscriptions?

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.

like image 890
Tom Hamming Avatar asked Nov 06 '22 04:11

Tom Hamming


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

like image 148
Hitch22 Avatar answered Nov 15 '22 12:11

Hitch22