【发布时间】:2019-04-25 06:45:03
【问题描述】:
我想验证我的应用内购买。
我正在使用this receipt validator,通过查看源代码调用https://www.googleapis.com/androidpublisher/v3/applications/<appId>/purchases/products/<productId>/tokens/<token>,这是我的代码基本上是从自述文件中复制的
$googleClient = new Google_Client();
$googleClient->setScopes([Google_Service_AndroidPublisher::ANDROIDPUBLISHER]);
$googleClient->setApplicationName('my project name');
$googleClient->setAuthConfig('files/googleauthconfig.json');
$validator = new Validator(new Google_Service_AndroidPublisher($googleClient));
try {
$response = $validator->setPackageName('my.app.id')
->setProductId('my.product.id')
->setPurchaseToken('token i got from my app when purchasing')
->validatePurchase();
} catch (Exception $e) {
var_dump($e->getMessage());
exit;
}
var_dump($response);
exit;
我已经硬编码了很多东西,因为我现在只是想让它工作。 googleauthconfig.json 是开发控制台为我的服务帐户提供的 JSON 文件,其中包含该帐户的一堆 ID 以及一个私钥。我进入我的游戏控制台并将我的服务帐户设为管理员,然后按照其他问题中针对相同问题的建议等待了大约 24 小时。我已经配置了我的产品,这些产品是可消耗的和活跃的,并且我使用测试信用卡通过我签名的发布应用成功地购买了它们。
我不断收到的错误是
当前用户没有足够的权限来执行请求的操作。
【问题讨论】:
-
验证器是什么?你能把代码写下来吗?您应该通过 android Google_Service_AndroidPublisher 服务运行所有内容。
-
@DaImTo 我链接到了 repo,它是某种我并不真正需要但仍然使用它的包装器 github.com/aporat/store-receipt-validator/blob/master/src/…
-
这是我的 V2 示例代码我还没有生成 v3 的代码github.com/LindaLawton/Google-APIs-PHP-Samples/tree/master/…
-
@DaImTo 我将代码复制了两次,变量是正确的,对不起,这是我的问题,代码没有错误,我已成功收到谷歌的回复。
-
我没有想法,那么您可能想等待看看其他人是否有任何想法。或者继续尝试记住服务帐户权限启动的延迟。除此之外,我会尝试在没有您的验证器的情况下使用它,以确保它不会导致您的问题。
标签: php google-api google-api-php-client service-accounts google-play-developer-api