为什么 getLocalPricing() 和 getLocalName() 返回 null?

huangapple go评论75阅读模式
英文:

Why getLocalPricing() and getLocalName() return null

问题

我想通过gdx-pay库实现Google Play订阅。为了显示所需的信息,我使用以下代码:

info = purchaseManager.getInformation(SKU);
info.getLocalName(); //返回null
info.getLocalPricing(); //返回null

但是这些方法都返回了null

以下是我的代码:

PurchaseManagerConfig pmc = new PurchaseManagerConfig();
pmc.addOffer(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier(SKU));
//pmc.addStoreParam(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE, param);
purchaseManager.install(new MyObserver(this), pmc, true);
...
info = purchaseManager.getInformation(SKU);

我查阅了文档和这个库的示例,但没有找到任何问题。唯一一件事是我没有编写pmc.addStoreParam(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE, param);,因为我不明白那里需要什么参数。另外,在示例中没有使用这行代码,所以我跳过了它。我还没有时间来编写订阅购买的实现。我创建了一个订阅,注册了一个价格,添加了一个ID并进行了激活。在开发者控制台中,我没有看到关于创建订阅后可能出现延迟的任何说明。我做错了什么?

英文:

I want to implement google play subscriptions via gdx-pay library. To display the information I need, I ask

info = purchaseManager.getInformation(SKU);
info.getLocalName(); //returns null
info.getLocalPricing(); //returns null

But these methods return null
Here is my code

PurchaseManagerConfig pmc = new PurchaseManagerConfig();
pmc.addOffer(new Offer().setType(OfferType.SUBSCRIPTION).setIdentifier(SKU));
//pmc.addStoreParam(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE, param);
purchaseManager.install(new MyObserver(this), pmc, true);
...
info = purchaseManager.getInformation(SKU);

I looked at the documentation and an example for this library, but did not find any problems, the only thing I did not write pmc.addStoreParam(PurchaseManagerConfig.STORE_NAME_ANDROID_GOOGLE, param); Because I don't understand what parameters are needed there. In addition, this line is not used in the example, so I skipped it. I have not yet had time to write a subscription purchase implementation. I created a subscription, registered a price for it, added an ID and activated. In the developer console, I have not seen any notes about a possible delay after creating a subscription. What am I doing wrong?

答案1

得分: 1

抱歉,您的要求我无法完全满足。由于您希望只返回翻译的部分,我会为您提供翻译后的文本,但我仍然会保留原始文本以供参考:

原始文本:
I can't say what exactly helped, but the problem went away (at least during the testing phase). A few days later, I changed a few things: I published the game to the public, started working on a new version, created another OAuth 2.0 client ID with SHA-1 upload certificate, added it to the firebase project.

翻译后文本:
我无法确切地说是什么帮助了,但问题已经消失了(至少在测试阶段是这样)。几天后,我做了一些改变:我将游戏发布给了公众,开始着手开发新版本,创建了另一个带有SHA-1上传证书的OAuth 2.0客户端ID,并将其添加到了Firebase项目中。

英文:

I can't say what exactly helped, but the problem went away (at least during the testing phase). A few days later, I changed a few things: I published the game to the public, started working on a new version, created another OAuth 2.0 client ID with SHA-1 upload certificate, added it to the firebase project.

答案2

得分: 0

从gdx-pay的自述文件中:

> 当PurchaseManager成功安装时,您的PurchaseObserver将收到回调,并且purchaseManager.installed()将返回true。这可能需要一些时间,具体取决于付款服务。现在,您可以请求信息或购买物品。

我们不知道您是否这样做,可能您并没有这样做,而是只收到了Information.UNAVAILABLE的返回。

英文:

From the readme file on gdx-pay:

> When the PurchaseManager is sucessfully installed, your PurchaseObserver will receive a callback and purchaseManager.installed() will return true. That might take some seconds depending on the payment service. You can now request information or purchase items.

We don't know if you do this, probably you don't and you just get Information.UNAVAILABLE returned.

huangapple
  • 本文由 发表于 2020年9月2日 22:47:43
  • 转载请务必保留本文链接:https://go.coder-hub.com/63708054.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定