Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate the Google Play Billing Library into engine #17836

Open
wants to merge 3 commits into
base: v3.8.5
Choose a base branch
from

Conversation

qiuguohua
Copy link
Contributor

@qiuguohua qiuguohua commented Nov 11, 2024

Re: #
https://developer.android.com/google/play/billing/integrate
https://developer.android.com/reference/com/android/billingclient/api/BillingClient?_gl=1*11tcdon*_up*MQ..*_ga*MjcyNzYxMzIuMTczMTM3NTA0MQ..*_ga_6HH9YJMN9M*MTczMTM3NTA0MS4xLjAuMTczMTM3NTA0MS4wLjAuNzA1NTQwMDMy

Changelog


Continuous Integration

This pull request:

  • needs automatic test cases check.

    Manual trigger with @cocos-robot run test cases afterward.

  • does not change any runtime related code or build configuration

    If any reviewer thinks the CI checks are needed, please uncheck this option, then close and reopen the issue.


Compatibility Check

This pull request:

  • changes public API, and have ensured backward compatibility with deprecated features.
  • affects platform compatibility, e.g. system version, browser version, platform sdk version, platform toolchain, language version, hardware compatibility etc.
  • affects file structure of the build package or build configuration which requires user project upgrade.
  • introduces breaking changes, please list all changes, affected features and the scope of violation.

Copy link

github-actions bot commented Nov 11, 2024

⚠️ Package size ⤴ 4624 bytes, old: 5378018, new: 5382642

Interface Check Report

! WARNING this pull request has changed these public interfaces:

@@ -21866,8 +21866,489 @@
          */
         off(type: __private._pal_screen_adapter_enum_type_screen_event__PalScreenEvent, callback?: (...args: any) => void, target?: any): void;
     }
     /**
+     * @en
+     * Interface for google play blling module.
+     *
+     * @zh
+     * google play blling模块的接口。
+     *
+     * @example
+     */
+    export const googlePlayBilling: __private._cocos_core_platform_billing_billing__GooglePlayBilling;
+    /**
+     * @en Google play billing event type
+     * @zh google play billing事件类型
+     */
+    export enum BillingEventType {
+        /**
+         * @en
+         * Called to notify that setup is complete.
+         *
+         * @zh
+         * 当安装已经完成时触发。
+         */
+        BILLING_SETUP_FINISHED = "billing_setup_finished",
+        /**
+         * @en
+         * Called to notify that the connection to the billing service was lost.
+         *
+         * @zh
+         * 当Billing服务连接断开时触发。
+         */
+        BILLING_SERVICE_DISCONNECTED = "billing_service_disconnected",
+        /**
+         * @en
+         * Listen to this event to get notifications of purchase updates.
+         *
+         * @zh
+         * 监听这个事件可以获取购买更新。
+         */
+        PURCHASES_UPDATED = "purchases_updated",
+        /**
+         * @en
+         * Called to notify that query product details operation has finished.
+         *
+         * @zh
+         * 查询产品详细信息操作完成时触发。
+         */
+        PRODUCT_DETAILS_RESPONSE = "product_details_response",
+        /**
+         * @en
+         * Called to notify that the query purchases operation has finished.
+         *
+         * @zh
+         * 查询购买操作完成时触发。
+         */
+        QUERY_PURCHASES_RESPONSE = "query_purchases_response",
+        /**
+         * @en
+         * Called to notify that a consume operation has finished.
+         *
+         * @zh
+         * 消费操作完成时触发。
+         */
+        CONSUME_RESPONSE = "consume_response",
+        /**
+         * @en
+         * Called to notify that an acknowledge purchase operation has finished.
+         *
+         * @zh
+         * 确认购买操作完成时触发。
+         */
+        ACKNOWLEDGE_PURCHASES_RESPONSE = "acknowledge_purchases_response",
+        /**
+         * @en
+         * Called to notify when the get billing config flow has finished.
+         *
+         * @zh
+         * 获取Billing配置流程完成时触发。
+         */
+        BILLING_CONFIG_RESPONSE = "billing_config_response",
+        /**
+         * @en
+         * Called to receive the results from createAlternativeBillingOnlyReportingDetailsAsync when it is finished.
+         *
+         * @zh
+         * 当调用createAlternativeBillingOnlyReportingDetailsAsync接口完成时触发,可以接收调用结果。
+         */
+        ALTERNATIVE_BILLING_ONLY_TOKEN_RESPONSE = "alternative_billing_only_token_response",
+        /**
+         * @en
+         * Called to receive the results from createExternalOfferReportingDetailsAsync when it is finished.
+         *
+         * @zh
+         * 当调用createExternalOfferReportingDetailsAsync接口完成时触发,可以接收调用结果。
+         */
+        EXTERNAL_OFFER_REPORTING_DETAILS_RESPONSE = "external_offer_reporting_details_response",
+        /**
+         * @en
+         * Called to receive the results from BillingClient#isAlternativeBillingOnlyAvailableAsync when it is finished.
+         *
+         * @zh
+         * 当调用BillingClient#isAlternativeBillingOnlyAvailableAsync接口完成时触发,可以接收调用结果。
+         */
+        ALTERNATIVE_BILLING_ONLY_AVAILABILITY_RESPONSE = "alternative_billing_only_availability_response",
+        /**
+         * @en
+         * Called to receive the results from BillingClient#isExternalOfferAvailableAsync when it is finished.
+         *
+         * @zh
+         * 当调用BillingClient#isExternalOfferAvailableAsync接口完成时触发,可以接收调用结果。
+         */
+        EXTERNAL_OFFER_AVAILABILITY_RESPONSE = "external_offer_availability_response",
+        /**
+         * @en
+         * Called to notify that the alternative billing only dialog flow is finished.
+         *
+         * @zh
+         * 当仅替代Billing对话流程已完成时触发。
+         */
+        ALTERNATIVE_BILLING_ONLY_INFORMATION_DIALOG_RESPONSE = "alternative_billing_only_information_dialog_response",
+        /**
+         * @en
+         * Called to notify that the external offer information dialog flow is finished.
+         *
+         * @zh
+         * 当外部报价信息对话流程已完成时触发。
+         */
+        EXTERNAL_OFFER_INFORMATION_DIALOG_RESPONSE = "external_offer_information_dialog_response",
+        /**
+         * @en
+         * Called to notify when the in-app messaging flow has finished.
+         *
+         * @zh
+         * 当应用内消息流程完成时触发。
+         */
+        IN_APP_MESSAGE_RESPONSE = "in_app_message_response"
+    }
+    /**
+     * @en
+     * Supported Product types.
+     *
+     * @zh
+     * 支持的产品类型。
+     */
+    export enum ProductType {
+        /**
+         * @en
+         * A Product type for Android apps in-app products.
+         *
+         * @zh
+         * Android 应用内产品的产品类型。
+         */
+        INAPP = "inapp",
+        /**
+         * @en
+         * A Product type for Android apps subscriptions.
+         *
+         * @zh
+         * Android 应用程序订阅的产品类型。
+         */
+        SUBS = "subs"
+    }
+    /**
+     * @en
+     * Possible response codes.
+     *
+     * @zh
+     * 可能的响应代码。
+     */
+    export enum BillingResponseCode {
+        /**
+         * @en
+         * This field is deprecated.
+         * See SERVICE_UNAVAILABLE which will be used instead of this code.
+         *
+         * @zh
+         * 这个字段已经废弃。
+         * 看看SERVICE_UNAVAILABLE将使用哪一个来代替此代码。
+         */
+        SERVICE_TIMEOUT = "Bad expression <-3>",
+        /**
+         * @en
+         * The requested feature is not supported by the Play Store on the current device.
+         *
+         * @zh
+         * 当前设备上的 Play Store 不支持所请求的功能。
+         */
+        FEATURE_NOT_SUPPORTED = "Bad expression <-2>",
+        /**
+         * @en
+         * The app is not connected to the Play Store service via the Google Play Billing Library.
+         *
+         * @zh
+         * 该应用未通过 Google Play Billing库连接到 Play Store 服务。
+         */
+        SERVICE_DISCONNECTED = "Bad expression <-1>",
+        /**
+         * @en
+         * Success.
+         *
+         * @zh
+         * 成功。
+         */
+        OK = 0,
+        /**
+         * @en
+         * Transaction was canceled by the user.
+         *
+         * @zh
+         * 交易已被用户取消。
+         */
+        USER_CANCELED = 1,
+        /**
+         * @en
+         * The service is currently unavailable.
+         *
+         * @zh
+         * 当前设备上的 Play Store 不支持所请求的功能。
+         */
+        SERVICE_UNAVAILABLE = 2,
+        /**
+         * @en
+         * A user billing error occurred during processing.
+         *
+         * @zh
+         * 处理过程中出现用户billing错误。
+         */
+        BILLING_UNAVAILABLE = 3,
+        /**
+         * @en
+         * The requested product is not available for purchase.
+         *
+         * @zh
+         * 所请求的产品无法购买。
+         */
+        ITEM_UNAVAILABLE = 4,
+        /**
+         * @en
+         * Error resulting from incorrect usage of the API.
+         *
+         * @zh
+         * 由于错误使用 API 而导致的错误。
+         */
+        DEVELOPER_ERROR = 5,
+        /**
+         * @en
+         * Fatal error during the API action.
+         *
+         * @zh
+         * API 操作期间发生致命错误。
+         */
+        ERROR = 6,
+        /**
+         * @en
+         * The purchase failed because the item is already owned.
+         *
+         * @zh
+         * 购买失败,因为该物品已被拥有。
+         */
+        ITEM_ALREADY_OWNED = 7,
+        /**
+         * @en
+         * Requested action on the item failed since it is not owned by the user.
+         *
+         * @zh
+         * 由于该项目不属于用户,因此对该项目请求的操作失败。
+         */
+        ITEM_NOT_OWNED = 8,
+        /**
+         * @en
+         * A network error occurred during the operation.
+         *
+         * @zh
+         * 操作期间发生网络错误。
+         */
+        NETWORK_ERROR = 12
+    }
+    /**
+     * @en
+     * Recurrence mode of the pricing phase.
+     *
+     * @zh
+     * 定价阶段的复现模式。
+     */
+    export enum RecurrenceMode {
+        /**
+         * @en
+         * The billing plan payment recurs for infinite billing periods unless cancelled.
+         *
+         * @zh
+         * 除非取消,否则billing计划付款将无限期地重复。
+         */
+        INFINITE_RECURRING = 1,
+        /**
+         * @en
+         * The billing plan payment recurs for a fixed number of billing period set in billingCycleCount.
+         *
+         * @zh
+         * Billing计划付款将在 billingCycleCount 中设置的固定计费周期内重复发生。
+         */
+        FINITE_RECURRING = 2,
+        /**
+         * @en
+         * The billing plan payment is a one time charge that does not repeat.
+         *
+         * @zh
+         * Billing计划付款是一次性费用,不会重复。
+         */
+        NON_RECURRING = 3
+    }
+    /**
+     * @en
+     * Connection state of billing client.
+     *
+     * @zh
+     * Billing client的连接状态
+     */
+    export enum ConnectionState {
+        /**
+         * @en
+         * This client was not yet connected to billing service or was already closed.
+         *
+         * @zh
+         * 此客户端尚未连接到Billing服务或已关闭。
+         */
+        DISCONNECTED = 0,
+        /**
+         * @en
+         * This client is currently in process of connecting to billing service.
+         *
+         * @zh
+         * 此客户端目前正在连接到Billing服务。
+         */
+        CONNECTING = 1,
+        /**
+         * @en
+         * This client is currently connected to billing service.
+         *
+         * @zh
+         * 此客户端当前已连接到Billing服务。
+         */
+        CONNECTED = 2,
+        /**
+         * @en
+         * This client was already closed and shouldn't be used again.
+         *
+         * @zh
+         * 该客户端已关闭,不应再次使用。
+         */
+        CLOSED = 3
+    }
+    /**
+     * @en
+     * Features/capabilities supported by isFeatureSupported.
+     *
+     * @zh
+     * 支持的特性/能力isFeatureSupported。
+     */
+    export enum FeatureType {
+        /**
+         * @en
+         * Alternative billing only.
+         *
+         * @zh
+         * 仅限替代Billing。
+         */
+        ALTERNATIVE_BILLING_ONLY = "jjj",
+        /**
+         * @en
+         * Get billing config.
+         *
+         * @zh
+         * 获取计费配置。
+         */
+        BILLING_CONFIG = "ggg",
+        /**
+         * @en
+         * Play billing library support for external offer.
+         *
+         * @zh
+         * Play billing库支持外部报价。
+         */
+        EXTERNAL_OFFER = "kkk",
+        /**
+         * @en
+         * Show in-app messages.
+         *
+         * @zh
+         * 显示应用内消息。
+         */
+        IN_APP_MESSAGING = "bbb",
+        /**
+         * @en
+         * Launch a price change confirmation flow.
+         *
+         * @zh
+         * 启动价格变动确认流程。
+         */
+        PRICE_CHANGE_CONFIRMATION = "priceChangeConfirmation",
+        /**
+         * @en
+         * Play billing library support for querying and purchasing.
+         *
+         * @zh
+         * Play Billing库支持查询、购买。
+         */
+        PRODUCT_DETAILS = "fff",
+        /**
+         * @en
+         * Purchase/query for subscriptions.
+         *
+         * @zh
+         * 购买/查询订阅。
+         */
+        SUBSCRIPTIONS = "subscriptions",
+        /**
+         * @en
+         * Subscriptions update/replace.
+         *
+         * @zh
+         * 订阅更新/替换。
+         */
+        UBSCRIPTIONS_UPDATE = "subscriptionsUpdate"
+    }
+    /**
+     * @en
+     * Possible purchase states.
+     *
+     * @zh
+     * 可能的购买状态。
+     */
+    export enum PurchaseState {
+        /**
+         * @en
+         * Purchase is pending and not yet completed to be processed by your app.
+         *
+         * @zh
+         * 购买处于待处理状态且尚未完成,无法由您的应用程序处理。
+         */
+        PENDING = 2,
+        /**
+         * @en
+         * Purchase is completed..
+         *
+         * @zh
+         * 购买完成。
+         */
+        PURCHASED = 1,
+        /**
+         * @en
+         * Purchase with unknown state.
+         *
+         * @zh
+         * 未知状态
+         */
+        UNSPECIFIED_STATE = 0
+    }
+    /**
+     * @en
+     * Possible response codes.
+     *
+     * @zh
+     * InAppMessage可能的影响代码。
+     */
+    export enum InAppMessageResponseCode {
+        /**
+         * @en
+         * The flow has finished and there is no action needed from developers.
+         *
+         * @zh
+         * 流程已完成,开发人员无需采取任何行动。
+         */
+        NO_ACTION_NEEDED = 0,
+        /**
+         * @en
+         * The subscription status changed.
+         *
+         * @zh
+         * 订阅状态已改变。
+         */
+        SUBSCRIPTION_STATUS_UPDATED = 1
+    }
+    /**
      * @en A set of system related variables.
      * @zh 一系列系统相关环境变量。
      */
     export const sys: {
@@ -35379,8 +35860,337 @@
              * @returns
              */
             onThermalStatusChanged?: (previousStatus: number, newStatus: number, statusMin: number, statusMax: number) => void;
         } | undefined;
+        /**
+         * @en Params containing the response code and the debug message from In-app Billing API response.
+         * @zh 包含应用内结算 API 响应代码和调试信息的参数
+         */
+        export interface BillingResult {
+            /**
+             * @en Debug message returned in In-app Billing API calls.
+             * @zh 应用内结算 API 调用中返回的调试消息。
+             */
+            readonly debugMessage: string;
+            /**
+             * @en Code returned in In-app Billing API calls.
+             * @zh 应用内结算 API 调用中返回的响应代码。
+             */
+            readonly responseCode: string;
+            readonly toStr: string;
+        }
+        /**
+         * @en Represents the offer details to buy an one-time purchase product.
+         * @zh 代表一次性购买产品的报价详情。
+         */
+        export interface OneTimePurchaseOfferDetails {
+            /**
+             * @en The price for the payment in micro-units, where 1,000,000 micro-units equal one unit of the currency.
+             * @zh 以微单位返回支付价格,其中 1,000,000 个微单位等于 1 个货币单位。
+             */
+            readonly priceAmountMicros: number;
+            /**
+             * @en Formatted price for the payment, including its currency sign.
+             * @zh 支付的格式化价格,包括其货币单位。
+             */
+            readonly formattedPrice: string;
+            /**
+             * @en ISO 4217 currency code for price.
+             * @zh 价格的 ISO 4217 货币代码。
+             */
+            readonly priceCurrencyCode: string;
+        }
+        /**
+         * @en Represents additional details of an installment subscription plan.
+         * @zh 表示分期付款订阅计划的附加详细信息。
+         */
+        export interface InstallmentPlanDetails {
+            /**
+             * @en Committed payments count after a user signs up for this subscription plan.
+             * @zh 用户注册此订阅计划后承诺的付款数量。
+             */
+            readonly installmentPlanCommitmentPaymentsCount: number;
+            /**
+             * @en Subsequent committed payments count after this subscription plan renews.
+             * @zh 此订阅计划续订后的后续承诺付款数量。
+             */
+            readonly subsequentInstallmentPlanCommitmentPaymentsCount: number;
+        }
+        /**
+         * @en Represents a pricing phase, describing how a user pays at a point in time.
+         * @zh 表示定价阶段,描述用户在某个时间点如何付款。
+         */
+        export interface PricingPhase {
+            /**
+             * @en Number of cycles for which the billing period is applied.
+             * @zh 计费周期适用的周期数。
+             */
+            readonly billingCycleCount: number;
+            /**
+             * @en The price for the payment cycle in micro-units, where 1,000,000 micro-units equal one unit of the currency.
+             * @zh 微单位付款周期的价格,其中 1,000,000 个微单位等于 1 个货币单位。
+             */
+            readonly priceAmountMicros: number;
+            /**
+             * @en RecurrenceMode for the pricing phase.
+             * @zh 定价阶段的RecurrenceMode。
+             */
+            readonly recurrenceMode: number;
+            /**
+             * @en Billing period for which the given price applies, specified in ISO 8601 format.
+             * @zh 给定价格适用的计费期,以 ISO 8601 格式指定。
+             */
+            readonly billingPeriod: string;
+            /**
+             * @en Formatted price for the payment cycle, including its currency sign.
+             * @zh 付款周期的格式化价格,包括其货币符号。
+             */
+            readonly formattedPrice: string;
+            /**
+             * @en Returns ISO 4217 currency code for price.
+             * @zh 返回价格的 ISO 4217 货币代码。
+             */
+            readonly priceCurrencyCode: string;
+        }
+        /**
+         * @en Represents the available purchase plans to buy a subscription product.
+         * @zh 代表一次性购买产品的报价详情。
+         */
+        export interface SubscriptionOfferDetails {
+            /**
+             * @en The base plan id associated with the subscription product.
+             * @zh 与订阅产品相关的基本计划 ID。
+             */
+            readonly basePlanId: string;
+            /**
+             * @en The offer id associated with the subscription product.
+             * @zh 与订阅产品相关的优惠 ID。
+             */
+            readonly offerId: string;
+            /**
+             * @en The offer tags associated with this Subscription Offer.
+             * @zh 与此订阅优惠相关的优惠标签。
+             */
+            readonly offerTags: string[];
+            /**
+             * @en The offer token required to pass in launchBillingFlow to purchase the subscription product with these pricing phases.
+             * @zh 在 launchBillingFlow 中传递以使用这些定价阶段购买订阅产品所需的优惠令牌。
+             */
+            readonly offerToken: string;
+            /**
+             * @en The pricing phases for the subscription product.
+             * @zh 订阅产品的定价区间。
+             */
+            readonly pricingPhaseList: PricingPhase[];
+            /**
+             * @en The additional details of an installment plan.
+             * @zh 分期付款计划的附加详细信息。
+             */
+            readonly installmentPlanDetails: InstallmentPlanDetails;
+        }
+        /**
+         * @en Represents the details of a one time or subscription product.
+         * @zh 代表一次性或订阅产品的详细信息。
+         */
+        export interface ProductDetails {
+            /**
+             * @en Represents the available purchase plans to buy a subscription product.
+             * @zh 代表一次性购买产品的报价详情。
+             */
+            readonly hashCode: number;
+            /**
+             * @en The description of the product.
+             * @zh 产品的描述。
+             */
+            readonly description: string;
+            /**
+             * @en The name of the product being sold.
+             * @zh 所售产品的名称。
+             */
+            readonly name: string;
+            /**
+             * @en The product's Id.
+             * @zh 产品的 ID。
+             */
+            readonly productId: string;
+            /**
+             * @en The ProductType of the product.
+             * @zh ProductType产品的。
+             */
+            readonly productType: string;
+            /**
+             * @en The title of the product being sold.
+             * @zh 所售产品的标题。
+             */
+            readonly title: string;
+            readonly toStr: string;
+            /**
+             * @en The offer details of an one-time purchase product.
+             * @zh 代表一次性购买产品的报价详情。
+             */
+            readonly oneTimePurchaseOfferDetails: OneTimePurchaseOfferDetails;
+            /**
+             * @en A list containing all available offers to purchase a subscription product.
+             * @zh 返回包含购买订阅产品的所有可用优惠的列表。
+             */
+            readonly subscriptionOfferDetails: SubscriptionOfferDetails[];
+        }
+        /**
+         * @en Account identifiers that were specified when the purchase was made.
+         * @zh 购买时指定的帐户标识符。
+         */
+        export interface AccountIdentifiers {
+            /**
+             * @en The obfuscated account id specified in setObfuscatedAccountId.
+             * @zh 在setObfuscatedAccountId中设置的混淆账户id
+             */
+            readonly obfuscatedAccountId: string;
+            /**
+             * @en The obfuscated profile id specified in setObfuscatedProfileId.
+             * @zh 在setObfuscatedProfileId中设置的混淆profile id
+             */
+            readonly obfuscatedProfileId: string;
+        }
+        /**
+         * @en Represents a pending change/update to the existing purchase.
+         * @zh 表示对现有购买的待定更改/更新。
+         */
+        export interface PendingPurchaseUpdate {
+            /**
+             * @en A token that uniquely identifies this pending transaction.
+             * @zh 唯一标识此待处理交易的令牌。
+             */
+            readonly purchaseToken: string;
+            /**
+             * @en The product ids.
+             * @zh 产品 ID。
+             */
+            readonly products: string[];
+        }
+        /**
+         * @en Represents an in-app billing purchase.
+         * @zh 代表应用内billing购买。
+         */
+        export interface Purchase {
+            /**
+             * @en One of PurchaseState indicating the state of the purchase.
+             * @zh PurchaseState表示购买状态的其中一个值。
+             */
+            readonly purchaseState: number;
+            /**
+             * @en The time the product was purchased, in milliseconds since the epoch (Jan 1, 1970).
+             * @zh 产品购买的时间,以纪元(1970 年 1 月 1 日)以来的毫秒数表示。
+             */
+            readonly purchaseTime: number;
+            /**
+             * @en Indicates whether the purchase has been acknowledged.
+             * @zh 表示是否已确认购买。
+             */
+            readonly isAcknowledged: number;
+            /**
+             * @en Indicates whether the subscription renews automatically.
+             * @zh 指示订阅是否自动续订。
+             */
+            readonly isAutoRenewing: number;
+            readonly hashCode: number;
+            /**
+             * @en The quantity of the purchased product.
+             * @zh 购买产品的数量。
+             */
+            readonly quantity: number;
+            /**
+             * @en The payload specified when the purchase was acknowledged or consumed.
+             * @zh 确认或消费购买时指定的有效负载。
+             */
+            readonly developerPayload: string;
+            /**
+             * @en Returns a unique order identifier for the transaction.
+             * @zh 交易的唯一订单标识符。
+             */
+            readonly orderId: string;
+            /**
+             * @en Returns a String in JSON format that contains details about the purchase order.
+             * @zh 包含有关采购订单详细信息的 JSON 格式的字符串。
+             */
+            readonly originalJson: string;
+            /**
+             * @en The application package from which the purchase originated.
+             * @zh 购买来源的应用程序包。
+             */
+            readonly packageName: string;
+            /**
+             * @en A token that uniquely identifies a purchase for a given item and user pair.
+             * @zh 唯一标识给定商品和用户对的购买的令牌。
+             */
+            readonly purchaseToken: string;
+            /**
+             * @en String containing the signature of the purchase data that was signed with the private key of the developer.
+             * @zh 包含使用开发者私钥签名的购买数据签名的字符串。
+             */
+            readonly signature: string;
+            readonly toStr: string;
+            /**
+             * @en Returns account identifiers that were provided when the purchase was made.
+             * @zh 返回购买时提供的帐户标识符。
+             */
+            readonly accountIdentifiers: AccountIdentifiers;
+            /**
+             * @en The PendingPurchaseUpdate for an uncommitted transaction.
+             * @zh 返回PendingPurchaseUpdate未提交的事务。
+             */
+            readonly pendingPurchaseUpdate: PendingPurchaseUpdate;
+            /**
+             * @en the product Ids.
+             * @zh 产品 ID。
+             */
+            readonly products: string[];
+        }
+        export interface BillingConfig {
+            /**
+             * @en The customer's country code.
+             * @zh 客户的国家代码。
+             */
+            readonly countryCode: string;
+        }
+        /**
+         * @en The details used to report transactions made via alternative billing without user choice to use Google Play billing.
+         * @zh 用于报告用户未选择使用 Google Play 结算方式而通过替代结算方式进行的交易的详细信息。
+         */
+        export interface AlternativeBillingOnlyReportingDetails {
+            /**
+             * @en An external transaction token that can be used to report a transaction made via alternative billing
+             *     without user choice to use Google Play billing.
+             * @zh 返回一个外部交易令牌,该令牌可用于报告通过替代付款方式进行的交易,而无需用户选择使用 Google Play 付款方式。
+             */
+            readonly externalTransactionToken: string;
+        }
+        /**
+         * @en The details used to report transactions made via external offer.
+         * @zh 用于报告通过外部报价进行的交易的详细信息。
+         */
+        export interface ExternalOfferReportingDetails {
+            /**
+             * @en An external transaction token that can be used to report a transaction made via external offer.
+             * @zh 可用于报告通过外部报价进行的交易的外部交易令牌。
+             */
+            readonly externalTransactionToken: string;
+        }
+        /**
+         * @en Results related to in-app messaging.
+         * @zh 与应用程序内消息相关的结果。
+         */
+        export interface InAppMessageResult {
+            /**
+             * @en Response code for the in-app messaging API call.
+             * @zh 应用内消息传递 API 调用的响应代码。
+             */
+            readonly responseCode: number;
+            /**
+             * @en Token that identifies the purchase to be acknowledged, if any.
+             * @zh 返回标识需要确认的购买的令牌。
+             */
+            readonly purchaseToken: string;
+        }
     }
     export namespace postProcess {
         export class PostProcessSetting extends Component {
             onEnable(): void;
@@ -63240,8 +64050,132 @@
         export class _cocos_core_event_event_target__Empty {
         }
         export type _cocos_core_event_eventify__Constructor<T> = new (...args: any[]) => T;
         export type _pal_screen_adapter_enum_type_screen_event__PalScreenEvent = "window-resize" | "orientation-change" | "fullscreen-change";
+        export interface _cocos_core_platform_billing_billing__BillingEventMap {
+            [BillingEventType.BILLING_SETUP_FINISHED]: (result: native.BillingResult) => void;
+            [BillingEventType.BILLING_SERVICE_DISCONNECTED]: () => void;
+            [BillingEventType.PRODUCT_DETAILS_RESPONSE]: (result: native.BillingResult, productDetailsList: native.ProductDetails[]) => void;
+            [BillingEventType.PURCHASES_UPDATED]: (result: native.BillingResult, purchases: native.Purchase[]) => void;
+            [BillingEventType.CONSUME_RESPONSE]: (result: native.BillingResult, purchaseToken: string) => void;
+            [BillingEventType.QUERY_PURCHASES_RESPONSE]: (result: native.BillingResult, purchases: native.Purchase[]) => void;
+            [BillingEventType.BILLING_CONFIG_RESPONSE]: (result: native.BillingResult, config: native.BillingConfig) => void;
+            [BillingEventType.ALTERNATIVE_BILLING_ONLY_TOKEN_RESPONSE]: (result: native.BillingResult, alternativeBillingOnlyReportingDetails: native.AlternativeBillingOnlyReportingDetails) => void;
+            [BillingEventType.EXTERNAL_OFFER_REPORTING_DETAILS_RESPONSE]: (result: native.BillingResult, externalOfferReportingDetails: native.ExternalOfferReportingDetails) => void;
+            [BillingEventType.ALTERNATIVE_BILLING_ONLY_AVAILABILITY_RESPONSE]: (result: native.BillingResult) => void;
+            [BillingEventType.EXTERNAL_OFFER_AVAILABILITY_RESPONSE]: (result: native.BillingResult) => void;
+            [BillingEventType.ALTERNATIVE_BILLING_ONLY_INFORMATION_DIALOG_RESPONSE]: (result: native.BillingResult) => void;
+            [BillingEventType.EXTERNAL_OFFER_INFORMATION_DIALOG_RESPONSE]: (result: native.BillingResult) => void;
+            [BillingEventType.IN_APP_MESSAGE_RESPONSE]: (result: native.InAppMessageResult) => void;
+        }
+        export class _cocos_core_platform_billing_billing__GooglePlayBilling {
+            constructor();
+            /**
+             * @en Starts up BillingClient setup process asynchronously.
+             * @zh 异步启动 BillingClient 设置过程。
+             */
+            startConnection(): void;
+            /**
+             * @en Closes the connection and releases all held resources such as service connections.
+             * @zh 关闭连接并释放所有持有的资源,例如服务连接。
+             */
+            endConnection(): void;
+            /**
+             * @en Get the current billing client connection state.
+             * @zh 获取当前billing客户端连接状态。
+             */
+            getConnectionState(): number;
+            /**
+             * @en Checks if the client is currently connected to the service, so that requests to other methods will succeed.
+                       Returns true if the client is currently connected to the service, false otherwise.
+             * @zh 检查客户端当前是否连接到服务,以便对其他方法的请求能够成功。
+                       如果客户端当前已连接到服务,则返回 true,否则返回 false。
+             */
+            isReady(): boolean;
+            /**
+             * @en Performs a network query the details of products available for sale in your app.
+             * @zh 执行网络查询您的应用中可供销售的产品的详细信息。
+             * @param productId @zh 产品ID。 @en product id.
+             * @param productType @zh 产品类型。 @en product type.
+             *
+             */
+            queryProductDetailsParams(productId: string[] | string, productType: ProductType): void;
+            /**
+             * @en Initiates the billing flow for an in-app purchase or subscription.
+             * @zh 启动应用内购买或订阅的计费流程。
+             * @param productDetails @zh 产品详情。 @en product details.
+             * @param selectedOfferToken @zh 选择提供的token。 @en selected offer token.
+             */
+            launchBillingFlow(productDetails: native.ProductDetails[] | native.ProductDetails, selectedOfferToken: string | null): void;
+            /**
+             * @en Consumes a given in-app product.
+             * @zh 消费指定的应用内产品。
+             * @param purchase @zh 已经购买的产品。 @en Purchased Products.
+             */
+            consumePurchases(purchase: native.Purchase[] | native.Purchase): void;
+            /**
+             * @en Acknowledges in-app purchases.
+             * @zh 确认应用内购买。
+             * @param purchase @zh 已经购买的产品。 @en Purchased Products.
+             */
+            acknowledgePurchase(purchase: native.Purchase[] | native.Purchase): void;
+            /**
+             * @en Returns purchases details for currently owned items bought within your app.
+             * @zh 返回您应用内当前拥有的购买商品的购买详情。
+             * @param productType @zh 产品类型 @en Product type.
+             */
+            queryPurchasesAsync(productType: ProductType): void;
+            /**
+             * @en Gets the billing config, which stores configuration used to perform billing operations.
+             * @zh 获取计费配置,其中存储用于执行计费操作的配置。
+             */
+            getBillingConfigAsync(): void;
+            /**
+             * @en Creates alternative billing only purchase details that can be used to report a transaction made
+             *     via alternative billing without user choice to use Google Play billing.
+             * @zh 创建仅限替代结算的购买详情,可用于报告通过替代结算进行的交易,而无需用户选择使用 Google Play 结算。
+             */
+            createAlternativeBillingOnlyReportingDetailsAsync(): void;
+            /**
+             * @en Checks the availability of offering alternative billing without user choice to use Google Play billing.
+             * @zh 检查是否可以提供替代结算方式,而无需用户选择使用 Google Play 结算方式。
+             */
+            isAlternativeBillingOnlyAvailableAsync(): void;
+            /**
+             * @en Creates purchase details that can be used to report a transaction made via external offer.
+             * @zh 创建可用于报告通过外部报价进行的交易的购买详情。
+             */
+            createExternalOfferReportingDetailsAsync(): void;
+            /**
+             * @en Checks the availability of providing external offer.
+             * @zh 检查提供外部报价的可用性。
+             */
+            isExternalOfferAvailableAsync(): void;
+            /**
+             * @en Checks if the specified feature or capability is supported by the Play Store.
+             * @zh 检查 Play Store 是否支持指定的功能。
+             * @param feature @zh 功能特性 @en feature.
+             */
+            isFeatureSupported(feature: string): native.BillingResult | null;
+            /**
+             * @en Shows the alternative billing only information dialog on top of the calling app.
+             * @zh 在调用应用程序顶部显示仅显示备用计费信息对话框。
+             */
+            showAlternativeBillingOnlyInformationDialog(): native.BillingResult | null;
+            /**
+             * @en Shows the external offer information dialog on top of the calling app.
+             * @zh 在调用应用程序顶部显示外部优惠信息对话框。
+             */
+            showExternalOfferInformationDialog(): native.BillingResult | null;
+            /**
+             * @en Overlays billing related messages on top of the calling app.
+             * @zh 在调用应用程序上叠加与计费相关的消息。
+             */
+            showInAppMessages(): native.BillingResult | null;
+            on<K extends keyof _cocos_core_platform_billing_billing__BillingEventMap>(type: K, callback: _cocos_core_platform_billing_billing__BillingEventMap[K], target?: unknown): _cocos_core_platform_billing_billing__BillingEventMap[K];
+            once<K extends keyof _cocos_core_platform_billing_billing__BillingEventMap>(type: K, callback: _cocos_core_platform_billing_billing__BillingEventMap[K], target?: unknown): _cocos_core_platform_billing_billing__BillingEventMap[K];
+            off<K extends keyof _cocos_core_platform_billing_billing__BillingEventMap>(eventType: K, callback?: _cocos_core_platform_billing_billing__BillingEventMap[K], target?: any): void;
+        }
         export enum _pal_system_info_enum_type_feature__Feature {
             /**
              * @en Feature to support Webp.
              * @zh 是否支持 Webp 特性。

* 这个字段已经废弃。
* 看看SERVICE_UNAVAILABLE将使用哪一个来代替此代码。
*/
SERVICE_TIMEOUT = -3,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This field is marked as deprecated in the google docs, does it need to be removed?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, i think should remove it. But it is better to listen to the google guys' opinions too.

export class GooglePlayBilling {
private _eventTarget: EventTarget = new EventTarget();
constructor () {
if (!JSB || !jsb.billing) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Return if non-JSB or jsb.billing is null, only in android platform jsb.billing is not null

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should only work on google play build target.

2. Adjust the file name
@qiuguohua
Copy link
Contributor Author

@cocos-robot run test cases

*/
readonly signature: string;

readonly toStr: string;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name should be toString, but ts has an internal toString, so it's changed to toStr.

jintArray result = env->NewIntArray(size);
jint* buf = new jint[size];
for (int i = 0; i < size; ++i) {
buf[i] = productDetailsList[i]->hashCode;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Finding objects in Java using hashCode

* @en Represents the available purchase plans to buy a subscription product.
* @zh 代表一次性购买产品的报价详情。
*/
readonly hashCode: number;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the comment for hashCode wrong?

*/
readonly title: string;

readonly toStr: string;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing API comment for toStr


bool jsb_register_all_billing(se::Object* obj) { // NOLINT
se::Value nsVal;
if (!obj->getProperty("jsb", &nsVal, true)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should use another namespace, like gp or googleplay

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants