在应用内购买无法验证谷歌播放的收据

时间:2017-02-21 09:47:22

标签: node.js google-play in-app-purchase

我已按照本教程设置了应用内购买流程。我的代码一直工作到今天,当我开始收到此错误时:

[错误:invalid_grant]

尝试验证来自Google的收据时。我在配置中设置了以下详细信息:

iap.config({ 
    googlePublicKeyStrSandBox: googlePublicKeyStrSandBox, 
    googlePublicKeyStrLive: googlePublicKeyStrLive,
    googleAccToken: googleAccToken,
    googleRefToken: googleRefToken,
    googleClientID: googleClientID,
    googleClientSecret: googleClientSecret
});

我尝试添加一些代码来刷新Google令牌,如下所示:

iap.setup((err) => {
    if (err) {
        full = { messageText: 'Failed: Invalid In-app purchase set up', category:'ProcessSubscriptionGoogle'}
        callback(null, full);
    } else {
        // refresh token before validating the receipt
        iap.refreshGoogleToken( function (err, response) {
            if (err) {
                full = { messageText: 'Failed: Cannot Refresh Token', category:'ProcessSubscriptionGoogle'}
                callback(null, full);
            } else {
                iap.validate(validationType, googleReceipt, (err, response) => {
                    if (err) {
                        full = { messageText: 'Failed: Invalid Receipt', category:'ProcessSubscriptionGoogle'}
                        callback(null, full);
                    } else {
                        console.log(response);
                    }
                });
            }
        })            
  }
});

但我仍然有同样的invalid_grant错误。我正确地刷新了吗?我是否应该在代码中包含刷新?

0 个答案:

没有答案