本指南介绍如何建立 Unity 游戏与应用内购 (IAP) 商店进行交互所需的数字记录和关系。本指南针对的是 Unity IAP 购买 API。
应用内购 (IAP) 是通过资金交易购买数字商品的过程。一个平台的应用商店会允许购买代表数字商品的产品。这些商品有一个标识符(通常是字符串数据类型)。商品的类型 (Types) 可表示其耐用性:_订阅、消耗品_(可以多次购买)以及_非消耗品_(可以购买一次)是最常见的类型。
2.准备好游戏的商品标识符以便稍后在 Google Play Developer Console(开发者控制台)中使用。
![gold50](../uploads/Main/IAPGoogleImage0.png)
Build a signed non-Development Build Android APK from your game.
提示:务必妥善保存您的密钥库文件。始终需要原始密钥库来更新已发布的 Google Play 应用程序。
提示:在本地测试期间,请复用您上次上传的 APK 的 Bundle Version Code 以便允许侧载 (side-loading),无需先将已更改的 APK 上传到 Developer Console。请参阅 Android 平台 Player 设置。
通过用于发布游戏的 Google 帐户,将 Android 应用程序注册到 Google Play Developer Console。
NOTE: This guide uses the Google Play License Testing approach for testing in-app purchase integration.
Choose Create app.
Give the application an App name and select the appropriate options for your game.
Navigate to Testing/Closed testing in the left nav and choose Create track. Select your APK and upload it. Also complete the basic Dashboard requirements, upload screenshots and add a Short and Full description. You can also create an Internal test track.
Now that you have uploaded our first binary, you can add the IAP products.
Navigate to In-app Products and choose Create product.
Define the Product ID , product details and price. Remember to activate the product after saving.
您可以在 Managed product 中指定消耗品或非消耗品商品类型。Unity IAP 也支持 __Subscription__(订阅)商品类型。
NOTE: The “Product ID” here is the same identifier used in the game source code, added to the [Unity IAP ConfigurationBuilder] instance via AddProduct()
or AddProducts()
, like “gold50”.
Add your testers to License Testing.
Navigate to All Apps on your Google Developer dashboard.
Select Settings/License Testing. Add each Google Account email address. Save changes.
NOTE: There may be a delay of several hours from the time you publish the APK.
Note: To test updates retaining permission to purchase IAPS’s for free, you may side-load applications, updating the existing store-downladed APK install.
To test the IAP, make a purchase on a device logged in with a Tester Google Account. A modified purchase dialog box appears to confirm the fact this product is under test and is free.
WARNING: If this dialog box does not appear, then the Tester Google Account will be charged real money for the product.