I am trying to validate the app-store purchase receipt using https://www.npmjs.com/package/in-app-purchase npm package. It is working fine in local, i am getting validation and purchase data both.
But when i transfer that function to google cloud functions then i get the following error:
"{\"error\":{\"errno\":\"EAI_AGAIN\",\"code\":\"EAI_AGAIN\",\"syscall\":\"getaddrinfo\",\"hostname\":\"sandbox.itunes.apple.com\",\"host\":\"sandbox.itunes.apple.com\",\"port\":443,\"validatedData\":{\"sandbox\":true,\"status\":1,\"message\":\"Unknown\"}},\"status\":1,\"message\":\"Unknown\"}"
My cloud functions code is:
exports.validateReceipt = functions.https.onRequest( async (req, res) => {
let result = null;
receipt = #########base64encodedstring########
let validator = new receiptValidatorService(receipt);
result = await validator.verifyAppleStoreReceipt('subscription');
res.json(result);
}
The required functions are imported accordingly.
I also tried in heroku, it is working, but not working in google cloud functions, any idea ?
Any kinds of helps are appreciated. Thanks
The issue is not with the code, Its just that google cloud doesn't allow the request to be made outside the google services for unpaid version. For this to happen, the payment should be added.
Thanks.