测试 Android In App Billing 实际购买 [英] Testing Android In App Billing real purchases
问题描述
当我已经使用 android.test.purchased
之类的测试产品测试了我的应用程序时,正确测试实际购买的条件是什么?
您需要通过几个步骤,请记住,其中一些步骤需要一些时间才能在 Google Play 服务器上进行更新.
在这个例子中,让我们使用 com.example.product
作为我们的真实产品 ID.每当它出现在本示例中时,请将其更改为您自己的.
上传 APK 文件
<块引用>您不能在调试模式下测试真实购买.您需要从 Beta 版下载应用,以便 Google 知道可以在该应用中进行购买.
检查您是否在
AndroidManifest.xml
中具有 BILLING 权限:将
android.test.purchased
改为com.example.product
,导出 *.apk 文件.必须签名!
发布 APK 测试版
您现在可以进行下一步,但您需要一些时间来准备好 Beta 版下载.
添加新产品
<块引用>在发布测试版之前,您不能添加新产品.
您不能测试订阅,只能测试产品.现在您可以也测试订阅(它们每 24 小时更新一次)
- 转到 Google Play Developer Console 中的产品部分,
- 点击
Add new product
按钮并使用com.example.product
Id定义新产品, - 等待几个小时,直到它发布.
测试人员
<块引用>您不能测试使用开发者帐户在您的设备上登录的购买.您不能自己购买.
- 在 Google 网上论坛或 Google Plus 上创建测试小组
- 将您的测试人员的 Gmail 帐户添加到该群组中,
- 在
Google Play Developer Console 中将您的组设置为测试员 >应用程序>测试版
- 在
Google Play Developer Console 中复制测试人员的电子邮件 >设置 >许可证测试
- 这将使他们的帐户启用测试购买.
测试
<块引用>作为测试人员,您不会被收取费用
从下载的应用测试版进行测试时,您会在第一个 IAP 对话框中看到测试信息.
您将在开发控制台中看到您的产品名称和价格设置.
您将使用真实的付款方式进行测试.不要害怕看到你的信用卡.正如我之前提到的 - 您不会被收取费用.
当您成功进行测试购买后,您会收到一封确认电子邮件,看起来像是真正的购买确认.
清洁测试购买
<块引用>要重复相同的购买,您需要消费产品、取消购买或等待 2 周直到测试购买到期.
取消购买:
- 作为开发者,请转到 Google 电子钱包,选择购买,然后取消购买(请记住在您的应用中管理已完成的购买),
- 作为测试人员,请转到设备上的应用管理器,然后清除 Google Play 缓存.尽管在开发者方面取消,您的设备仍会在本地存储购买信息.
What are the conditions to properly test real purchases, when i already have tested my app using test product like android.test.purchased
?
There are few steps that you need to pass, remembering, that some of them need some time to update on Google Play servers.
For this example, let's use com.example.product
as our real product Id. Any time it shows up in this example change it to your own.
UPLOAD APK FILE
You CAN'T test REAL PURCHASES in DEBUG mode. You need to download an app from Beta, so Google know it's ok to make purchases in the app.
Check if you have BILLING permission in
AndroidManifest.xml
:<uses-permission android:name="com.android.vending.BILLING" />
Change
android.test.purchased
tocom.example.product
,Export *.apk file. It MUST BE SIGNED!
Publish APK in Beta,
You can now go to the next steps, but you'd need some time for your Beta to be ready for download.
ADD NEW PRODUCT
You CAN'T add new product until you have published a beta.
You CAN'T test subscriptions, only products.Now you CAN also test subscriptions (they are renewed every 24h)
- Go to products section in Google Play Developer Console,
- Click
Add new product
button and define new product withcom.example.product
Id, - Wait FEW HOURS until it's published.
TESTERS
You CAN'T test purchases being signed-in on your device with a developer account. You CAN'T make purchases from yourself.
- Create testing group on Google Groups, or Google Plus,
- Add gmail accounts of your testers to that group,
- Set your group as testers in
Google Play Developer Console > APP > BETA
- Copy testers emails in
Google Play Developer Console > SETTINGS > LICENSE TESTING
- this will make testing purchases enabled for their accounts.
TESTING
As a tester, you WON'T be charged
When testing from downloaded app Beta, you'll see a testing information on first IAP dialog.
You'll see both your product's name and price set in dev console.
You'll be testing with your real payment options. Don't be scared of seeing your credit card. As i mentioned before - you won't be charged.
When you successfully make a test purchase, you'll get a confirmation e-mail, which looks like a real purchase confirmation.
CLEANING TEST PURCHASES
To repeat the same purchases, you'll need to consume products, cancel purchases, or simply wait 2 weeks until testing purchases will expire.
To cancel purchases:
- As a Developer, go to Google Wallet, choose purchases, and cancel them (remember to manage calceled purchases in your app),
- As a Tester, go to app manager on your device, and clear Google Play cache. Despite of canceling on developer side, your device stores the purchase information locally.
这篇关于测试 Android In App Billing 实际购买的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!