我想一个receipt
发送到我的Node.js server
。目前,它打印出的火力指示其从receipt-data
要求我从POST
发得到它的iOS App
。但是我不能在我的代码正确地传递const receipt = request.body;
进行验证。我怎样才能把它传递正确的方式?谢谢。
exports.receiptValidation = functions.https.onRequest((request, response) => {
const receipt = request.body;
console.log(receipt);
iap.config({
applePassword: 'MySharedAppleKey',
test: true
});
iap.setup((error) => {
if (error) {
console.log('Failed to validate receipt', error);
}
});
iap.validate(receipt).then((pResponse) => {
//Check if receipt is valid
if (iap.isValidated(pResponse)) {
console.log('The receipt is valid', pResponse);
response.send(pResponse);
}
return pResponse;
})
.catch((error) => {
console.log(`Sorry couldn't validate receipt`, error);
response.send(error);
return error
});
});
这是我在火力地堡输出。我使用的是firebase function
我解决它通过改变我的收据数据串在这两个Swift
和Server code
迅速
let receiptData = receipt!.base64EncodedString()
let requestReceiptDict = ["receipt": receiptData]
Node.js的
const receipt = request.body.receipt;
console.log(receipt);