Skip to content
Samuel Spencer edited this page Jan 22, 2021 · 1 revision

Use this method to (optionally) refresh the receipt and perform validation in one step.

let appleValidator = AppleReceiptValidator(service: .production, sharedSecret: "your-shared-secret")
SwiftyStoreKit.verifyReceipt(using: appleValidator, forceRefresh: false) { result in
    switch result {
    case .success(let receipt):
        print("Verify receipt success: \(receipt)")
    case .error(let error):
        print("Verify receipt failed: \(error)")
    }
}

Notes

  • This method is based on fetchReceipt, and the same refresh logic discussed above applies.
  • AppleReceiptValidator is a reference implementation that validates the receipt with Apple and results in a network call. This is prone to man-in-the-middle attacks.
  • You should implement your secure logic by validating your receipt locally, or sending the encrypted receipt data and validating it in your server.
  • Local receipt validation is not implemented (see issue #101 for details).
  • You can implement your own receipt validator by conforming to the ReceiptValidator protocol and passing it to verifyReceipt.