google.iap.billing.*

类型
版本 版本 2024.3703
关键词 Google,IAP,应用内购买
平台 Android
重要

此插件已弃用。请迁移到 Google Billing v2

概述

Google Play Billing 插件允许您支持应用内在 Android 上购买,包括游戏内货币、升级等。

有关其他平台上的应用内购买,请参阅 Apple IAPAmazon IAP 的文档。

备注
与 IAPv3 的兼容性

此插件可以直接替换之前的 IAP 插件。它甚至可以响应 require( "plugin.google.iap.v3" ) 代码。但是有一些区别

语法

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

属性

store.target

store.isActive

store.canLoadProducts

函数

store.init()

store.loadProducts()

store.purchase()

store.purchaseSubscription()

store.restore()

store.consumePurchase()

store.finishTransaction()

事件

init

storeTransaction

productList

项目设置

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

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",
        },
    },
}