Testing non-consumable IAP items in Google Play

自闭症网瘾萝莉.ら 提交于 2019-12-12 02:33:45

问题


I'm using Google Play IABv3 and want to be able to easily test what I do (not surprisingly). Since IABv3 all items are managed and it's up to the application to consume the items that it considers consumables.

I'm not sure what the expected work flow is with testing non-consumable products. To be able to test the purchase flow more than once you need to be able to remove the previous purchase. However, the purchase is intended to be non-consumable so we obviously don't want to add any code that consumes it (since it could accidentally slip through and remove real users purchases).

I would like some way of clearing a test users account from purchases, which I doubt is possible since there is no "real" test users.

What is the suggested way to do this?


回答1:


You can use test product IDs instead of real items. Remember to use it only in debug builds.

https://developer.android.com/google/play/billing/billing_testing.html

android.test.purchased

When you make an In-app Billing request with this product ID, Google Play responds as though you successfully purchased an item. The response includes a JSON string, which contains fake purchase information (for example, a fake order ID). In some cases, the JSON string is signed and the response includes the signature so you can test your signature verification implementation using these responses.

android.test.canceled

When you make an In-app Billing request with this product ID Google Play responds as though the purchase was canceled. This can occur when an error is encountered in the order process, such as an invalid credit card, or when you cancel a user's order before it is charged.

android.test.refunded

When you make an In-app Billing request with this product ID, Google Play responds as though the purchase was refunded. Refunds cannot be initiated through Google Play's in-app billing service. Refunds must be initiated by you (the merchant). After you process a refund request through your Google Wallet merchant account, a refund message is sent to your application by Google Play. This occurs only when Google Play gets notification from Google Wallet that a refund has been made. For more information about refunds, see Handling IN_APP_NOTIFY messages and In-app Billing Pricing.

android.test.item_unavailable

When you make an In-app Billing request with this product ID, Google Play responds as though the item being purchased was not listed in your application's product list.



来源:https://stackoverflow.com/questions/30030736/testing-non-consumable-iap-items-in-google-play

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!