google.iap.v3.*

类型
修订版 发布版本 2024.3703
关键字 谷歌,IAP,应用内购买
平台 安卓
重要提示

此插件已弃用。请迁移到 Google Billing。有关更多信息和主要差异,请参阅其 文档

概览

借助 Google IAP 插件,你可以支持应用内购买,包括游戏内货币、升级以及更多内容。

如需在其他平台进行应用内购买,请参阅 Apple IAPAmazon IAPStore API 的文档。

注意

语法

local store = require( "plugin.google.iap.v3" )

属性

store.target

store.isActive

store.canLoadProducts

函数

store.init()

store.loadProducts()

store.purchase()

store.restore()

store.consumePurchase()

事件

init

storeTransaction

productList

项目设置

如需使用此插件,请在 build.settingsplugins 表中添加一个条目。添加后,构建服务器将在构建阶段集成该插件。

settings =
{
    plugins =
    {
        ["plugin.google.iap.v3"] =
        {
            publisherId = "com.coronalabs"
        },
    },
}

此外,你必须在 build.settings 中启用 BILLING 权限

settings =
{
    android =
    {
        usesPermissions =
        {
            "com.android.vending.BILLING",
        },
    },
}

最后,必须将 license 表添加到项目的 config.lua 文件中。在此表内,key 值应设置为从 Google Play Developer Console 获得的相应密钥。

application = 
{
    license =
    {
        google =
        {
            key = "YOUR_KEY",
        },
    },
}