Thank you @endecotp for your reply, Currently I am using SwiftyStoreKit to handle In-App Purchases.
To make the In-App Purchase, I am calling SwiftyStoreKit's purchaseProduct(_ product: SKProduct)
method,
And once I get the success response from this method, I am validating the receipt to validate the purchase by this SwiftyStoreKit's verifyReceipt(using validator: ReceiptValidator)
method,
Which first fetches the appStoreReceiptData from the Bundle as below,
var appStoreReceiptData: Data? {
guard let receiptDataURL = Bundle.main.appStoreReceiptURL,
let data = try? Data(contentsOf: receiptDataURL) else {
return nil
}
return data
}
Then to validate the receipt data, calls the verifyReceipt endpoint https://buy.itunes.apple.com/verifyReceipt
as below,
let storeURL = URL(string: "https://buy.itunes.apple.com/verifyReceipt")!
let storeRequest = NSMutableURLRequest(url: storeURL)
storeRequest.httpMethod = "POST"
let receipt = appStoreReceiptData.base64EncodedString(options: [])
let requestContents: NSMutableDictionary = [ "receipt-data": receipt ]
// password if defined
if let password = sharedSecret {
requestContents.setValue(password, forKey: "password")
}
// Encore request body
do {
storeRequest.httpBody = try JSONSerialization.data(withJSONObject: requestContents, options: [])
} catch let e {
completion(.error(error: .requestBodyEncodeError(error: e)))
return
}
// Remote task
let task = URLSession.shared.dataTask(with: storeRequest as URLRequest) { data, _, error -> Void in
}
task.resume()
And once I got the successful validation response from the above method, I unlock the pro content for the user in the application.
Can you please let me know how can I know that how I am validating the certificate?
Also, can you please check the above things, and let me know if I still needs any changes on receipt validation?
Thanks again.