Hi All, I have this code and I would like to send the payload of the completed purchase to my server. How to do that? Regards Thomas S
`
SubscriptionStoreView(...)
.onInAppPurchaseCompletion { product, result in
if case .success(.success(let transaction)) = result {
print("Purchased successfully: \(transaction.signedDate)") // this looks good in Xcode
// Pass payload of transaction to my server
let url = URL(string: "... my server ...")!
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = ???? // how do I pass the payload of the transaction to the httpBody
request.setValue("application/json", forHTTPHeaderField: "Content-Type")
let task = URLSession.shared.dataTask(with: request) { data, response, error in
let statusCode = (response as! HTTPURLResponse).statusCode
if statusCode == 200 {
print("SUCCESS")
} else {
print("FAILURE")
}
}
task.resume()
} else {
print("Something else happened")
}
}
`