Search code examples
iosswiftparsingin-app-purchase

SwiftyStoreKit parse receipt


In the documentation for SwiftStoreKit it is written that the Receipt can be obtained using

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)")
     }
}

however, I tried to parse and insert into the model but nothing worked. Can anyone help? need to parse latest_receipt_info or in_app


Solution

  • If you want to use this library you need to implement your own logic to do the local verification of receipt.

    according to README from this library

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

    This may help you https://developer.apple.com/library/archive/releasenotes/General/ValidateAppStoreReceipt/Chapters/ValidateLocally.html#//apple_ref/doc/uid/TP40010573-CH1-SW2