Hello,
I'm working on non-consumable IAP's and when I try to validate a receipt, I always get this status code 21002, which means my receipt-data property was malformed or missing. But I've been doing exactly how I saw on apple's documentation. What am I missing?
I'm working on non-consumable IAP's and when I try to validate a receipt, I always get this status code 21002, which means my receipt-data property was malformed or missing. But I've been doing exactly how I saw on apple's documentation. What am I missing?
Code Block guard let receiptFileURL = Bundle.main.appStoreReceiptURL, FileManager.default.fileExists(atPath: receiptFileURL.path) else { return } let receiptData = try? Data(contentsOf: receiptFileURL, options: .alwaysMapped) guard receiptData != nil else { UserDefaults.standard.set(false, forKey: "isSubscribed") return } var recieptString = receiptData?.base64EncodedString() ?? "" let jsonDict : [String : Any] = ["receipt-data" : recieptString, "password" : Constants.ConstantValues.autoRenewableReceitPassword.rawValue, "exclude-old-transactions" : false] let httpBody = try? JSONSerialization.data(withJSONObject: jsonDict, options: []) let storeURL = URL(string: Constants.ConstantValues.verifyReceiptSandboxURL.rawValue)! var storeRequest = URLRequest(url: storeURL) storeRequest.httpMethod = "POST" storeRequest.httpBody = httpBody storeRequest.setValue("Application/json", forHTTPHeaderField: "Content-Type") let task = URLSession.shared.dataTask(with: storeRequest) { [weak self] (data, response, error) in if let data = data, let jsonData = try? JSONSerialization.jsonObject(with: data, options: .allowFragments) { /* Status code is always 21002 */ } } } task.resume()