从Google Play验证应用内购买

发布于 2025-01-20 16:11:44 字数 1526 浏览 1 评论 0原文

我正在制作一个Azure功能应用程序,该应用程序将拨打Google验证用户在我的移动应用程序中的应用内购买的应用程序。

我使用的是google.apis.androidpublisher.v3 nuget软件包,并带有以下代码来验证应用内购买。

public async Task<bool> IsValidPurchase(string bundleId, string receiptId, string purchaseToken, string developerPayload)
{
     try
     {
        var isValidPurchase = true;

        var request = _googleService.Purchases.Products.Get(bundleId, receiptId, purchaseToken);
        var purchaseState = await request.ExecuteAsync();

        if (purchaseState.DeveloperPayload != developerPayload)
            isValidPurchase = false;

        if (purchaseState.PurchaseState != 0)
            isValidPurchase = false;

        return isValidPurchase;
     }
     catch (Exception e)
     {
        throw new Exception(e.Message);
     }
}

我一直遇到“不良请求 - 无效的值”错误。

我的移动用户将购买自动续订订阅,并在Android手机上成功购买后,我会得到以下响应 - 请参见下图:

“在此处输入映像说明”

验证方法要求bundled ,recepiptidpuphaseTokendeveloperpayload

bundleIdpuphaseToken很清楚,因此我认为我遇到的错误是由于recepiptid devage> devagent> devagenterpaypayload 。

我尝试使用idproductid值的值 - 请参见上图 - 但我一直遇到相同的错误:

不良请求 - 无效的值

任何想法这里有什么问题?我使用错误的值吗?我很感谢这里的一些指示。

I'm working on an Azure Functions app that will make calls to Google to verify in-app purchases users make in my mobile app.

I'm using the Google.Apis.AndroidPublisher.v3 NuGet package with the following code to verify an in-app purchase.

public async Task<bool> IsValidPurchase(string bundleId, string receiptId, string purchaseToken, string developerPayload)
{
     try
     {
        var isValidPurchase = true;

        var request = _googleService.Purchases.Products.Get(bundleId, receiptId, purchaseToken);
        var purchaseState = await request.ExecuteAsync();

        if (purchaseState.DeveloperPayload != developerPayload)
            isValidPurchase = false;

        if (purchaseState.PurchaseState != 0)
            isValidPurchase = false;

        return isValidPurchase;
     }
     catch (Exception e)
     {
        throw new Exception(e.Message);
     }
}

I keep getting "Bad Request - Invalid Value" error.

My mobile users will be purchasing auto-renewing subscriptions and after a successful purchase on an Android phone, I get the following response -- see image below:

enter image description here

The verification method asks for bundleId, receiptId, purchaseToken and developerPayload.

The bundleId and purchaseToken are pretty clear so I'm thinking the error I get is either due to receiptId or developerPayload.

I tried using both Id and ProductId values from the response -- see image above -- but I keep getting the same error:

Bad request - Invalid Value

Any idea what's wrong here? Am I using the wrong values? I'd appreciate some pointers here.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文