从Google Play验证应用内购买
我正在制作一个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 ,
recepiptid
,puphaseToken
和developerpayload
。
bundleId
和puphaseToken
很清楚,因此我认为我遇到的错误是由于recepiptid
devage> devagent> devagenterpaypayload 。
我尝试使用id
和productid
值的值 - 请参见上图 - 但我一直遇到相同的错误:
不良请求 - 无效的值
任何想法这里有什么问题?我使用错误的值吗?我很感谢这里的一些指示。
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:
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论