简体   繁体   English

退款后如何撤销 Android 应用内非消耗性购买权利?

[英]How do I revoke an Android in-app non-consumable purchase entitlement after refunding?

I'm currently testing my Android app (license testing in-app payments), requiring many iterations of buying and refunding an item to test it.我目前正在测试我的 Android 应用程序(许可测试应用程序内支付),需要多次购买和退款来测试它。 This last time, while issuing a refund, I accidentally forgot to check the "revoke entitlement" box in the Play Developer Console (which is unchecked by default for some reason).上次,在发放退款时,我不小心忘记选中 Play 开发者控制台中的“撤销权利”框(由于某种原因默认未选中)。 Now, my version of the app always has the entitlement and I can't test buying it anymore.现在,我的应用程序版本始终具有权利,我无法再测试购买它。

I know that there is no way to revoke the entitlement via the website.我知道没有办法通过网站撤销权利。 There seems to be a way to do it through an API call, but I don't have a back-end setup for the app, and haven't been able to figure out how to call the function successfully through my browser/curl (always authentication errors).似乎有一种方法可以通过 API 调用来实现,但我没有应用程序的后端设置,并且无法弄清楚如何通过我的浏览器/curl 成功调用 function(总是验证错误)。 My app doesn't seem to be able to tell the difference between a purchased entitlement or one that was refunded but not revoked (my Purchase object's getPurchaseState() call always returns Purchase.PurchaseState.PURCHASED ), so I don't know if I can revoke it via the app's code-base.我的应用程序似乎无法区分购买的权利或已退款但未撤销的权利(我的Purchase对象的getPurchaseState()调用总是返回Purchase.PurchaseState.PURCHASED ),所以我不知道我是否可以通过应用程序的代码库撤销它。

Is there any way that I can revoke the entitlement?有什么办法可以撤销权利吗? The procedure to authorize myself to make API calls is completely opaque to me, but that seems like a viable route if I could understand it.授权自己进行 API 调用的程序对我来说完全不透明,但如果我能理解的话,这似乎是一条可行的路线。

It turns out I had to go the route of consuming the purchase via the app.事实证明,我必须通过应用程序消费购买的路线 go。 I did this by adding a developer-only Preference in the Settings pane (by programmatically adding a new Preference depending on the value of BuildConfig.Debug ) specifically for revoking the given product.我通过在“设置”窗格中添加仅限开发人员的Preference (通过根据BuildConfig.Debug的值以编程方式添加新的首选项)专门用于撤销给定产品来做到这一点。 Once clicked, the app will:单击后,该应用程序将:

  1. Get a list of all Purchase s (through the BillingClient object's queryPurchases method)获取所有Purchase的列表(通过BillingClient对象的queryPurchases方法)
  2. Find the Purchase with the SKU of the product I want to consume (if it exists).使用我要消费的产品的 SKU 查找Purchase (如果存在)。
  3. Call the consumeAsync method of my BillingClient object, which accepts the purchase token (held by the Purchase object from step 2).调用我的BillingClient object 的consumeAsync方法,该方法接受购买令牌(由步骤 2 中的Purchase object 持有)。

Once this is done and has been verified, the product is consumed immediately and the entitlement that was granted is revoked (significantly faster than refunding through the Google Play Developer Console).完成此操作并经过验证后,产品会立即使用,并且已授予的权利将被撤销(比通过 Google Play 开发者控制台退款要快得多)。

Be careful to not let this option sneak into your release build, because I think it will revoke entitlements without refunding (not a problem for license testers who aren't using real money, but will lead to angry customers).注意不要让这个选项潜入你的release版本,因为我认为它会在不退款的情况下撤销权利(对于不使用真钱的许可证测试人员来说不是问题,但会导致愤怒的客户)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM