类型 库 版本 版本 2024.3703 关键词 Google,IAP,应用内购买 平台 Android
此插件已弃用。请迁移到 Google Billing v2。
Google Play Billing 插件允许您支持
有关其他平台上的应用内购买,请参阅 Apple IAP 或 Amazon IAP 的文档。
要使用 Google IAP,首先请设置您的 Google Payments 商户中心 帐户,并将其链接到 Google Play 开发者控制台。
必须在 Google Play 开发者控制台 中进行其他配置。如果您需要此过程的帮助,请参阅 Google 的 文档。
此插件可以直接替换之前的 IAP 插件。它甚至可以响应 require( "plugin.google.iap.v3" )
代码。但是有一些区别
发生错误时,storeTransaction.transaction 将不包含有关购买的数据。
storeTransaction.transaction 事件的 state
字段具有其他值。
store.finishTransaction() 函数不再是空操作。它将确认购买。如果购买在三天内未确认或消费,则将 退款 给用户。
local store = require( "plugin.google.iap.billing" )
要使用此插件,请在 build.settings
的 plugins
表中添加一个条目。添加后,构建将在构建阶段集成插件。
settings = { plugins = { ["plugin.google.iap.billing"] = { publisherId = "com.coronalabs" }, }, }
这会将强制性 com.android.vending.BILLING
权限添加到您的应用。
最后,如果要验证您的购买,可以将 license
表添加到项目 config.lua
文件中。在此表中,key
值应设置为从 Google Play 开发者控制台 获取的相应密钥。在控制台中,选择您的应用,然后点击“货币化设置”部分。从“许可”部分复制密钥。
application = { license = { google = { key = "YOUR_KEY", }, }, }