如何从在后的Node.js请求接收数据

问题描述 投票:0回答:1

我想一个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

enter image description here

javascript node.js server in-app-purchase
1个回答
1
投票

我解决它通过改变我的收据数据串在这两个SwiftServer code

迅速

let receiptData = receipt!.base64EncodedString()
let requestReceiptDict = ["receipt": receiptData]

Node.js的

const receipt = request.body.receipt;
console.log(receipt);
© www.soinside.com 2019 - 2024. All rights reserved.