Given a reciept from an IOS device how do I decode this and verify the transaction on my NodeJS server?
async function verify (receiptFromIosDevice, testMode){
const key = `-----BEGIN PRIVATE KEY-----
XXXXXXXXXXXXXXXXXXkey stuff hereXXXXXXXXXXX
-----END PRIVATE KEY-----`; //probably import from secrets or something.
const issuerId = "e6a51f63-b30b-41fc-a62d-f5e01cdb847f"
const keyId = "00AA000AAA"
const bundleId = "com.name.name"
const environment = testMode ? Environment.SANDBOX : Environment.PRODUCTION
const client =
new AppStoreServerAPIClient(key, keyId, issuerId, bundleId, environment)
const receiptUtil = new ReceiptUtility()
const transactionId = receiptUtil.extractTransactionIdFromAppReceipt(encodedReceipt)
console.log(transactionId)
if (transactionId != null) {
const transactionHistoryRequest = {
sort: Order.DESCENDING,
revoked: false,
// productTypes: [ProductType.AUTO_RENEWABLE]
}
let response = await client.getTransactionHistory(transactionId, null, transactionHistoryRequest)
console.log(response)
return JSON.parse(Buffer.from(response.signedTransactions[0].split(".")[1], 'base64').toString())
}
}