From c01975ad0ef5c9a321ec723424a2ef4214935ffd Mon Sep 17 00:00:00 2001 From: qiuguohua Date: Mon, 9 Dec 2024 20:18:52 +0800 Subject: [PATCH] Reorganize the directory structure --- @types/jsb.d.ts | 188 +- native/CMakeLists.txt | 33 +- .../bindings/manual/jsb_google_billing.cpp | 1539 ----------------- .../bindings/manual/jsb_module_register.cpp | 4 - .../vendor/google/billing/GoogleBilling.java | 35 +- .../google/billing/GoogleBillingHelper.java | 5 - .../vendor/google/billing/GoogleBilling.cpp | 45 +- native/vendor/google/billing/GoogleBilling.h | 925 +--------- .../google/billing/GoogleBillingHelper.cpp | 118 +- .../google/billing/GoogleBillingHelper.h | 4 +- ...ogleBillingToNative.cpp => JniBilling.cpp} | 99 +- .../{GoogleBillingToNative.h => JniBilling.h} | 27 +- .../build-params/AcknowledgePurchaseParams.h | 67 + .../billing/build-params/BillingFlowParams.h | 171 ++ .../billing/build-params/ConsumeParams.h | 67 + .../build-params/GetBillingConfigParams.h | 54 + .../billing/build-params/InAppMessageParams.h | 68 + .../build-params/PendingPurchasesParams.h | 75 + .../build-params/QueryProductDetailsParams.h | 106 ++ .../build-params/QueryPurchasesParams.h | 63 + .../result-values/AccountIdentifiers.h | 51 + .../AlternativeBillingOnlyReportingDetails.h | 45 + .../billing/result-values/BillingConfig.h | 51 + .../billing/result-values/BillingResult.h | 79 + .../ExternalOfferReportingDetails.h | 46 + .../result-values/InAppMessageResult.h | 54 + .../billing/result-values/ProductDetails.cpp | 43 + .../billing/result-values/ProductDetails.h | 226 +++ .../Purchase.cpp} | 13 + .../google/billing/result-values/Purchase.h | 141 ++ .../billing/result-values/UserChoiceDetails.h | 92 + vendor/google/billing/billing-enum.ts | 32 + vendor/google/billing/billing.ts | 23 +- 33 files changed, 1945 insertions(+), 2644 deletions(-) delete mode 100644 native/cocos/bindings/manual/jsb_google_billing.cpp rename native/vendor/google/billing/{GoogleBillingToNative.cpp => JniBilling.cpp} (81%) rename native/vendor/google/billing/{GoogleBillingToNative.h => JniBilling.h} (83%) create mode 100644 native/vendor/google/billing/build-params/AcknowledgePurchaseParams.h create mode 100644 native/vendor/google/billing/build-params/BillingFlowParams.h create mode 100644 native/vendor/google/billing/build-params/ConsumeParams.h create mode 100644 native/vendor/google/billing/build-params/GetBillingConfigParams.h create mode 100644 native/vendor/google/billing/build-params/InAppMessageParams.h create mode 100644 native/vendor/google/billing/build-params/PendingPurchasesParams.h create mode 100644 native/vendor/google/billing/build-params/QueryProductDetailsParams.h create mode 100644 native/vendor/google/billing/build-params/QueryPurchasesParams.h create mode 100644 native/vendor/google/billing/result-values/AccountIdentifiers.h create mode 100644 native/vendor/google/billing/result-values/AlternativeBillingOnlyReportingDetails.h create mode 100644 native/vendor/google/billing/result-values/BillingConfig.h create mode 100644 native/vendor/google/billing/result-values/BillingResult.h create mode 100644 native/vendor/google/billing/result-values/ExternalOfferReportingDetails.h create mode 100644 native/vendor/google/billing/result-values/InAppMessageResult.h create mode 100644 native/vendor/google/billing/result-values/ProductDetails.cpp create mode 100644 native/vendor/google/billing/result-values/ProductDetails.h rename native/vendor/google/billing/{GoogleBillingManager.cpp => result-values/Purchase.cpp} (81%) create mode 100644 native/vendor/google/billing/result-values/Purchase.h create mode 100644 native/vendor/google/billing/result-values/UserChoiceDetails.h diff --git a/@types/jsb.d.ts b/@types/jsb.d.ts index e5a895d6d83..0f45f4911c7 100644 --- a/@types/jsb.d.ts +++ b/@types/jsb.d.ts @@ -500,7 +500,8 @@ declare namespace jsb { * @en Represents the details of a one time or subscription product. * @zh 代表一次性或订阅产品的详细信息。 */ - export interface ProductDetails { + export class ProductDetails { + static RecurrenceMode: jsb.RecurrenceMode; equals(other: ProductDetails): boolean; /** * @en Hash code @@ -583,11 +584,45 @@ declare namespace jsb { getProducts(): string[]; } + /** + * @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 Represents an in-app billing purchase. * @zh 代表应用内billing购买。 */ - export interface Purchase { + export class Purchase { + static PurchaseState: typeof jsb.PurchaseState; /** * @en One of PurchaseState indicating the state of the purchase. * @zh PurchaseState表示购买状态的其中一个值。 @@ -780,6 +815,7 @@ declare namespace jsb { build: () => QueryProductDetailsParams; } export class QueryProductDetailsParams { + static Product: typeof jsb.Product; private constructor(); public static newBuilder(): QueryProductDetailsParamsBuilder; } @@ -1118,6 +1154,153 @@ declare namespace jsb { SUBS = 'subs' } + /** + * @en + * A high-level category of the in-app message. + * One category can be mapped to multiple in-app messages. + * + * @zh + * 应用程序内信息的高级类别。 + * 一个类别可映射到多个应用程序内信息。 + */ + export enum InAppMessageCategoryId { + /** + * @en + * A Product type for Android apps in-app products. + * + * @zh + * 应用程序中未知的消息类别 ID + */ + UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID = 0, + /** + * @en + * The in-app messages of this category are for transactional purpose, such as payment issues. + * + * @zh + * 这类应用内信息用于交易目的,如支付问题。 + */ + TRANSACTIONAL = 2 + } + + /** + * @en + * Supported replacement modes to replace an existing subscription with a new one. + * + * @zh + * 支持替换模式,可将现有订购替换为新订购。 + */ + export enum ReplacementMode { + /** + * @en + * Unknown replacement mode. + * + * @zh + * 未知替换模式 + */ + UNKNOWN_REPLACEMENT_MODE = 0, + /** + * @en + * The new plan takes effect immediately, and the remaining time will be prorated and credited to the user. + * + * @zh + * 新计划立即生效,剩余时间将按比例计入用户贷方。 + */ + WITH_TIME_PRORATION = 1, + /** + * @en + * The new plan takes effect immediately, and the billing cycle remains the same. + * + * @zh + * 新计划立即生效,计费周期保持不变。 + */ + CHARGE_PRORATED_PRICE = 2, + /** + * @en + * The new plan takes effect immediately, and the new price will be charged on next recurrence time. + * + * @zh + * 新计划立即生效,新价格将在下次复诊时收取。 + */ + WITHOUT_PRORATION = 3, + /** + * @en + * Replacement takes effect immediately, and the user is charged full price of new plan and + * is given a full billing cycle of subscription, plus remaining prorated time from the old plan. + * + * @zh + * 替换立即生效,用户将被收取新计划的全额费用,并获得一个完整的计费周期,加上旧计划按比例计算的剩余时间。 + */ + CHARGE_FULL_PRICE = 5, + /** + * @en + * The new purchase takes effect immediately, the new plan will take effect when the old item expires. + * + * @zh + * 新购买立即生效,新计划将在旧项目到期时生效。 + */ + DEFERRED = 6, + } + + /** + * @en + * Possible response codes. + * + * @zh + * 可能的响应代码。 + */ + 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 + * 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, + } + export interface ProductDetailsParamsBuilder { setOfferToken: (purchaseToken: string) => ProductDetailsParamsBuilder; setProductDetails: (productDetails: ProductDetails) => ProductDetailsParamsBuilder; @@ -1190,6 +1373,7 @@ declare namespace jsb { export class InAppMessageParams { private constructor(); public static newBuilder(): InAppMessageParamsBuilder; + static InAppMessageCategoryId: typeof InAppMessageCategoryId; } export interface GetBillingConfigParamsBuilder { diff --git a/native/CMakeLists.txt b/native/CMakeLists.txt index b7f80fb2ef6..8b1c9fd2c83 100644 --- a/native/CMakeLists.txt +++ b/native/CMakeLists.txt @@ -765,11 +765,31 @@ if(USE_GOOGLE_BILLING) vendor/google/billing/GoogleBilling.cpp vendor/google/billing/GoogleBilling.h vendor/google/billing/GoogleBillingManager.h - vendor/google/billing/GoogleBillingManager.cpp vendor/google/billing/GoogleBillingHelper.cpp vendor/google/billing/GoogleBillingHelper.h - vendor/google/billing/GoogleBillingToNative.cpp - vendor/google/billing/GoogleBillingToNative.h + vendor/google/billing/JniBilling.cpp + vendor/google/billing/JniBilling.h + + vendor/google/billing/build-params/AcknowledgePurchaseParams.h + vendor/google/billing/build-params/BillingFlowParams.h + vendor/google/billing/build-params/ConsumeParams.h + vendor/google/billing/build-params/GetBillingConfigParams.h + vendor/google/billing/build-params/InAppMessageParams.h + vendor/google/billing/build-params/PendingPurchasesParams.h + vendor/google/billing/build-params/QueryProductDetailsParams.h + vendor/google/billing/build-params/QueryPurchasesParams.h + + vendor/google/billing/result-values/AccountIdentifiers.h + vendor/google/billing/result-values/AlternativeBillingOnlyReportingDetails.h + vendor/google/billing/result-values/BillingConfig.h + vendor/google/billing/result-values/BillingResult.h + vendor/google/billing/result-values/ExternalOfferReportingDetails.h + vendor/google/billing/result-values/InAppMessageResult.h + vendor/google/billing/result-values/Purchase.h + vendor/google/billing/result-values/Purchase.cpp + vendor/google/billing/result-values/ProductDetails.h + vendor/google/billing/result-values/ProductDetails.cpp + vendor/google/billing/result-values/UserChoiceDetails.h ) endif() @@ -2622,13 +2642,6 @@ if(USE_ADPF) ) endif() -if(USE_GOOGLE_BILLING) - cocos_source_files( - cocos/bindings/manual/jsb_google_billing.cpp - ) - -endif() - if(ANDROID) cocos_source_files( cocos/bindings/manual/jsb_platform_android.cpp diff --git a/native/cocos/bindings/manual/jsb_google_billing.cpp b/native/cocos/bindings/manual/jsb_google_billing.cpp deleted file mode 100644 index 4f62fc942eb..00000000000 --- a/native/cocos/bindings/manual/jsb_google_billing.cpp +++ /dev/null @@ -1,1539 +0,0 @@ -// /**************************************************************************** -// Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. - -// http://www.cocos.com - -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights to -// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies -// of the Software, and to permit persons to whom the Software is furnished to do so, -// subject to the following conditions: - -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. - -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. -// *****************************************************************************/ - -// #include "application/ApplicationManager.h" -// #include "bindings/jswrapper/SeApi.h" - -// #if CC_PLATFORM == CC_PLATFORM_ANDROID -// #include "bindings/jswrapper/SeApi.h" -// #include "bindings/manual/jsb_conversions.h" -// #include "bindings/manual/jsb_global.h" -// #include "vendor/google/billing/GoogleBilling.h" -// JSB_REGISTER_OBJECT_TYPE(cc::BillingResult); -// JSB_REGISTER_OBJECT_TYPE(cc::OneTimePurchaseOfferDetails); -// JSB_REGISTER_OBJECT_TYPE(cc::InstallmentPlanDetails); -// JSB_REGISTER_OBJECT_TYPE(cc::PricingPhase); -// JSB_REGISTER_OBJECT_TYPE(cc::SubscriptionOfferDetails); -// JSB_REGISTER_OBJECT_TYPE(cc::ProductDetails); -// JSB_REGISTER_OBJECT_TYPE(cc::AccountIdentifiers); -// JSB_REGISTER_OBJECT_TYPE(cc::PendingPurchaseUpdate); -// JSB_REGISTER_OBJECT_TYPE(cc::Purchase); -// JSB_REGISTER_OBJECT_TYPE(cc::BillingConfig); -// JSB_REGISTER_OBJECT_TYPE(cc::GoogleBilling); - -// #endif - -// #if CC_PLATFORM == CC_PLATFORM_ANDROID -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_BillingResult) -// static bool js_cc_BillingResult_debugMessage_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::BillingResult* arg1 = (cc::BillingResult*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->debugMessage; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_BillingResult_debugMessage_get) - -// static bool js_cc_BillingResult_responseCode_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::BillingResult* arg1 = (cc::BillingResult*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->responseCode; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); -// return true; -// } -// SE_BIND_PROP_GET(js_cc_BillingResult_responseCode_get) - -// static bool js_cc_BillingResult_toString_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::BillingResult* arg1 = (cc::BillingResult*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->toString; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); -// return true; -// } -// SE_BIND_PROP_GET(js_cc_BillingResult_toString_get) - -// static bool js_delete_cc_BillingResult(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_BillingResult) - -// bool js_register_cc_BillingResult(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("BillingResult", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("debugMessage", _SE(js_cc_BillingResult_debugMessage_get), nullptr); -// cls->defineProperty("responseCode", _SE(js_cc_BillingResult_responseCode_get), nullptr); -// cls->defineProperty("toStr", _SE(js_cc_BillingResult_toString_get), nullptr); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_BillingResult)); - -// cls->install(); -// JSBClassType::registerClass(cls); -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_OneTimePurchaseOfferDetails) - -// static bool js_cc_OneTimePurchaseOfferDetails_formattedPrice_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::OneTimePurchaseOfferDetails* arg1 = (cc::OneTimePurchaseOfferDetails*)NULL; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// ok &= nativevalue_to_se(arg1->formattedPrice, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(arg1->formattedPrice, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_OneTimePurchaseOfferDetails_formattedPrice_get) - -// static bool js_cc_OneTimePurchaseOfferDetails_priceAmountMicros_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::OneTimePurchaseOfferDetails* arg1 = (cc::OneTimePurchaseOfferDetails*)NULL; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// ok &= nativevalue_to_se(arg1->priceAmountMicros, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_OneTimePurchaseOfferDetails_priceAmountMicros_get) - -// static bool js_cc_OneTimePurchaseOfferDetails_priceCurrencyCode_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::OneTimePurchaseOfferDetails* arg1 = (cc::OneTimePurchaseOfferDetails*)NULL; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// ok &= nativevalue_to_se(arg1->priceCurrencyCode, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(arg1->priceCurrencyCode, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_OneTimePurchaseOfferDetails_priceCurrencyCode_get) - -// static bool js_delete_cc_OneTimePurchaseOfferDetails(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_OneTimePurchaseOfferDetails) - -// bool js_register_cc_OneTimePurchaseOfferDetails(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("OneTimePurchaseOfferDetails", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("formattedPrice", _SE(js_cc_OneTimePurchaseOfferDetails_formattedPrice_get), nullptr); -// cls->defineProperty("priceAmountMicros", _SE(js_cc_OneTimePurchaseOfferDetails_priceAmountMicros_get), nullptr); -// cls->defineProperty("priceCurrencyCode", _SE(js_cc_OneTimePurchaseOfferDetails_priceCurrencyCode_get), nullptr); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_OneTimePurchaseOfferDetails)); - -// cls->install(); -// JSBClassType::registerClass(cls); -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_InstallmentPlanDetails) -// static bool js_cc_InstallmentPlanDetails_installmentPlanCommitmentPaymentsCount_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::InstallmentPlanDetails* arg1 = (cc::InstallmentPlanDetails*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->installmentPlanCommitmentPaymentsCount; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_InstallmentPlanDetails_installmentPlanCommitmentPaymentsCount_get) - -// static bool js_cc_InstallmentPlanDetails_subsequentInstallmentPlanCommitmentPaymentsCount_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::InstallmentPlanDetails* arg1 = (cc::InstallmentPlanDetails*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->subsequentInstallmentPlanCommitmentPaymentsCount; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_InstallmentPlanDetails_subsequentInstallmentPlanCommitmentPaymentsCount_get) - -// static bool js_delete_cc_InstallmentPlanDetails(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_InstallmentPlanDetails) - -// bool js_register_cc_InstallmentPlanDetails(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("InstallmentPlanDetails", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("installmentPlanCommitmentPaymentsCount", _SE(js_cc_InstallmentPlanDetails_installmentPlanCommitmentPaymentsCount_get), nullptr); -// cls->defineProperty("subsequentInstallmentPlanCommitmentPaymentsCount", _SE(js_cc_InstallmentPlanDetails_subsequentInstallmentPlanCommitmentPaymentsCount_get), nullptr); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_InstallmentPlanDetails)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_PricingPhase) - -// static bool js_cc_PricingPhase_billingCycleCount_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhase* arg1 = (cc::PricingPhase*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->billingCycleCount; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhase_billingCycleCount_get) - -// static bool js_cc_PricingPhase_priceAmountMicros_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhase* arg1 = (cc::PricingPhase*)NULL; -// long result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->priceAmountMicros; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhase_priceAmountMicros_get) - -// static bool js_cc_PricingPhase_recurrenceMode_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhase* arg1 = (cc::PricingPhase*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->recurrenceMode; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhase_recurrenceMode_get) - -// static bool js_cc_PricingPhase_billingPeriod_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhase* arg1 = (cc::PricingPhase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->billingPeriod; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhase_billingPeriod_get) - -// static bool js_cc_PricingPhase_formattedPrice_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhase* arg1 = (cc::PricingPhase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->formattedPrice; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhase_formattedPrice_get) - -// static bool js_cc_PricingPhase_priceCurrencyCode_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhase* arg1 = (cc::PricingPhase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->priceCurrencyCode; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhase_priceCurrencyCode_get) - -// static bool js_delete_cc_PricingPhase(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_PricingPhase) - -// bool js_register_cc_PricingPhase(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("PricingPhase", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("billingCycleCount", _SE(js_cc_PricingPhase_billingCycleCount_get), nullptr); -// cls->defineProperty("priceAmountMicros", _SE(js_cc_PricingPhase_priceAmountMicros_get), nullptr); -// cls->defineProperty("recurrenceMode", _SE(js_cc_PricingPhase_recurrenceMode_get), nullptr); -// cls->defineProperty("billingPeriod", _SE(js_cc_PricingPhase_billingPeriod_get), nullptr); -// cls->defineProperty("formattedPrice", _SE(js_cc_PricingPhase_formattedPrice_get), nullptr); -// cls->defineProperty("priceCurrencyCode", _SE(js_cc_PricingPhase_priceCurrencyCode_get), nullptr); -// cls->defineFinalizeFunction(_SE(js_delete_cc_PricingPhase)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_PricingPhases) -// static bool js_cc_PricingPhases_pricingPhaseList_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PricingPhases* arg1 = (cc::PricingPhases*)NULL; -// std::vector result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->pricingPhaseList; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PricingPhases_pricingPhaseList_get) -// static bool js_delete_cc_PricingPhases(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_PricingPhases) -// bool js_register_cc_PricingPhases(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("PricingPhases", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("pricingPhaseList", _SE(js_cc_PricingPhases_pricingPhaseList_get), nullptr); -// cls->defineFinalizeFunction(_SE(js_delete_cc_PricingPhases)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_SubscriptionOfferDetails) - -// static bool js_cc_SubscriptionOfferDetails_basePlanId_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::SubscriptionOfferDetails* arg1 = (cc::SubscriptionOfferDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->basePlanId; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_SubscriptionOfferDetails_basePlanId_get) - -// static bool js_cc_SubscriptionOfferDetails_installmentPlanDetails_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::SubscriptionOfferDetails* arg1 = (cc::SubscriptionOfferDetails*)NULL; -// cc::InstallmentPlanDetails* result = 0; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->installmentPlanDetails.get(); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_SubscriptionOfferDetails_installmentPlanDetails_get) - -// static bool js_cc_SubscriptionOfferDetails_offerId_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::SubscriptionOfferDetails* arg1 = (cc::SubscriptionOfferDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->offerId; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_SubscriptionOfferDetails_offerId_get) - -// static bool js_cc_SubscriptionOfferDetails_offerTags_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::SubscriptionOfferDetails* arg1 = (cc::SubscriptionOfferDetails*)NULL; -// std::vector result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->offerTags; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_SubscriptionOfferDetails_offerTags_get) - -// static bool js_cc_SubscriptionOfferDetails_offerToken_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::SubscriptionOfferDetails* arg1 = (cc::SubscriptionOfferDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->offerToken; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_SubscriptionOfferDetails_offerToken_get) - -// static bool js_cc_SubscriptionOfferDetails_pricingPhases_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::SubscriptionOfferDetails* arg1 = (cc::SubscriptionOfferDetails*)NULL; -// cc::PricingPhases* result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->pricingPhases.get(); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_SubscriptionOfferDetails_pricingPhases_get) - -// static bool js_delete_cc_SubscriptionOfferDetails(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_SubscriptionOfferDetails) - -// bool js_register_cc_SubscriptionOfferDetails(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("SubscriptionOfferDetails", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("basePlanId", _SE(js_cc_SubscriptionOfferDetails_basePlanId_get), nullptr); -// cls->defineProperty("installmentPlanDetails", _SE(js_cc_SubscriptionOfferDetails_installmentPlanDetails_get), nullptr); -// cls->defineProperty("offerId", _SE(js_cc_SubscriptionOfferDetails_offerId_get), nullptr); -// cls->defineProperty("offerTags", _SE(js_cc_SubscriptionOfferDetails_offerTags_get), nullptr); -// cls->defineProperty("offerToken", _SE(js_cc_SubscriptionOfferDetails_offerToken_get), nullptr); -// cls->defineProperty("pricingPhases", _SE(js_cc_SubscriptionOfferDetails_pricingPhases_get), nullptr); -// cls->defineFinalizeFunction(_SE(js_delete_cc_SubscriptionOfferDetails)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_ProductDetails) - -// static bool js_cc_ProductDetails_equals(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// cc::ProductDetails* arg2 = (cc::ProductDetails*)NULL; -// bool result; -// if (argc != 1) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); -// return false; -// } -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// ok &= sevalue_to_native(args[0], &arg2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// result = (bool)((cc::ProductDetails const*)arg1)->equals(*arg2); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); -// return true; -// } -// SE_BIND_FUNC(js_cc_ProductDetails_equals) - -// static bool js_cc_ProductDetails_hashCode_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->hashCode; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_hashCode_get) - -// static bool js_cc_ProductDetails_description_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->description; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_description_get) - -// static bool js_cc_ProductDetails_name_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->name; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_name_get) - -// static bool js_cc_ProductDetails_oneTimePurchaseOfferDetails_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// cc::OneTimePurchaseOfferDetails* result = 0; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->oneTimePurchaseOfferDetails.get(); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_oneTimePurchaseOfferDetails_get) - -// static bool js_cc_ProductDetails_productId_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->productId; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_productId_get) - -// static bool js_cc_ProductDetails_productType_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->productType; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_productType_get) - -// static bool js_cc_ProductDetails_title_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->title; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_title_get) - -// static bool js_cc_ProductDetails_toString_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->toString; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_toString_get) - -// static bool js_cc_ProductDetails_subscriptionOfferDetails_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::ProductDetails* arg1 = (cc::ProductDetails*)NULL; -// std::vector result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->subscriptionOfferDetails; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_ProductDetails_subscriptionOfferDetails_get) - -// static bool js_delete_cc_ProductDetails(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_ProductDetails) - -// bool js_register_cc_ProductDetails(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("ProductDetails", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("hashCode", _SE(js_cc_ProductDetails_hashCode_get), nullptr); -// cls->defineProperty("description", _SE(js_cc_ProductDetails_description_get), nullptr); -// cls->defineProperty("name", _SE(js_cc_ProductDetails_name_get), nullptr); -// cls->defineProperty("oneTimePurchaseOfferDetails", _SE(js_cc_ProductDetails_oneTimePurchaseOfferDetails_get), nullptr); -// cls->defineProperty("productId", _SE(js_cc_ProductDetails_productId_get), nullptr); -// cls->defineProperty("productType", _SE(js_cc_ProductDetails_productType_get), nullptr); -// cls->defineProperty("title", _SE(js_cc_ProductDetails_title_get), nullptr); -// cls->defineProperty("toStr", _SE(js_cc_ProductDetails_toString_get), nullptr); -// cls->defineProperty("subscriptionOfferDetails", _SE(js_cc_ProductDetails_subscriptionOfferDetails_get), nullptr); - -// cls->defineFunction("equals", _SE(js_cc_ProductDetails_equals)); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_ProductDetails)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_AccountIdentifiers) - -// static bool js_cc_AccountIdentifiers_obfuscatedAccountId_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::AccountIdentifiers* arg1 = (cc::AccountIdentifiers*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->obfuscatedAccountId; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_AccountIdentifiers_obfuscatedAccountId_get) - -// static bool js_cc_AccountIdentifiers_obfuscatedProfileId_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::AccountIdentifiers* arg1 = (cc::AccountIdentifiers*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->obfuscatedProfileId; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_AccountIdentifiers_obfuscatedProfileId_get) - -// static bool js_delete_cc_AccountIdentifiers(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_AccountIdentifiers) - -// bool js_register_cc_AccountIdentifiers(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("AccountIdentifiers", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("obfuscatedAccountId", _SE(js_cc_AccountIdentifiers_obfuscatedAccountId_get), nullptr); -// cls->defineProperty("obfuscatedProfileId", _SE(js_cc_AccountIdentifiers_obfuscatedProfileId_get), nullptr); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_AccountIdentifiers)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_PendingPurchaseUpdate) - -// static bool js_cc_PendingPurchaseUpdate_products_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PendingPurchaseUpdate* arg1 = (cc::PendingPurchaseUpdate*)NULL; -// std::vector result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->products; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PendingPurchaseUpdate_products_get) - -// static bool js_cc_PendingPurchaseUpdate_purchaseToken_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::PendingPurchaseUpdate* arg1 = (cc::PendingPurchaseUpdate*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->purchaseToken; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_PendingPurchaseUpdate_purchaseToken_get) - -// static bool js_delete_cc_PendingPurchaseUpdate(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_PendingPurchaseUpdate) - -// bool js_register_cc_PendingPurchaseUpdate(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("PendingPurchaseUpdate", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("products", _SE(js_cc_PendingPurchaseUpdate_products_get), nullptr); -// cls->defineProperty("purchaseToken", _SE(js_cc_PendingPurchaseUpdate_purchaseToken_get), nullptr); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_PendingPurchaseUpdate)); - -// cls->install(); -// JSBClassType::registerClass(cls); -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_Purchase) - -// static bool js_cc_Purchase_equals(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// cc::Purchase* arg2 = 0; -// cc::Purchase temp2; -// bool result; - -// if (argc != 1) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); -// return false; -// } -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg2 = &temp2; - -// result = (bool)((cc::Purchase const*)arg1)->equals((cc::Purchase const&)*arg2); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_FUNC(js_cc_Purchase_equals) - -// static bool js_cc_Purchase_accountIdentifiers_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// cc::AccountIdentifiers* result = 0; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->accountIdentifiers.get(); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_accountIdentifiers_get) - -// static bool js_cc_Purchase_developerPayload_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->developerPayload; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_developerPayload_get) - -// static bool js_cc_Purchase_orderId_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->orderId; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_orderId_get) - -// static bool js_cc_Purchase_originalJson_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->originalJson; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_originalJson_get) - -// static bool js_cc_Purchase_packageName_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->packageName; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_packageName_get) - -// static bool js_cc_Purchase_pendingPurchaseUpdate_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// cc::PendingPurchaseUpdate* result = 0; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->pendingPurchaseUpdate.get(); - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_pendingPurchaseUpdate_get) - -// static bool js_cc_Purchase_products_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::vector result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->products; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_products_get) - -// static bool js_cc_Purchase_purchaseState_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->purchaseState; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_purchaseState_get) - -// static bool js_cc_Purchase_purchaseTime_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// long result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = (long)arg1->purchaseTime; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_purchaseTime_get) - -// static bool js_cc_Purchase_purchaseToken_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->purchaseToken; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_purchaseToken_get) - -// static bool js_cc_Purchase_quantity_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->quantity; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_quantity_get) - -// static bool js_cc_Purchase_signature_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->signature; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_signature_get) - -// static bool js_cc_Purchase_hashCode_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// int result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->hashCode; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_hashCode_get) - -// static bool js_cc_Purchase_isAcknowledged_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// bool result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->isAcknowledged; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_isAcknowledged_get) - -// static bool js_cc_Purchase_isAutoRenewing_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// bool result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->isAutoRenewing; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_isAutoRenewing_get) - -// static bool js_cc_Purchase_toString_get(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::Purchase* arg1 = (cc::Purchase*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->toString; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_Purchase_toString_get) - -// static bool js_delete_cc_Purchase(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_Purchase) - -// bool js_register_cc_Purchase(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("Purchase", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); -// cls->defineProperty("accountIdentifiers", _SE(js_cc_Purchase_accountIdentifiers_get), nullptr); -// cls->defineProperty("developerPayload", _SE(js_cc_Purchase_developerPayload_get), nullptr); -// cls->defineProperty("orderId", _SE(js_cc_Purchase_orderId_get), nullptr); -// cls->defineProperty("originalJson", _SE(js_cc_Purchase_originalJson_get), nullptr); -// cls->defineProperty("packageName", _SE(js_cc_Purchase_packageName_get), nullptr); -// cls->defineProperty("pendingPurchaseUpdate", _SE(js_cc_Purchase_pendingPurchaseUpdate_get), nullptr); -// cls->defineProperty("products", _SE(js_cc_Purchase_products_get), nullptr); -// cls->defineProperty("purchaseState", _SE(js_cc_Purchase_purchaseState_get), nullptr); -// cls->defineProperty("purchaseTime", _SE(js_cc_Purchase_purchaseTime_get), nullptr); -// cls->defineProperty("purchaseToken", _SE(js_cc_Purchase_purchaseToken_get), nullptr); -// cls->defineProperty("quantity", _SE(js_cc_Purchase_quantity_get), nullptr); -// cls->defineProperty("signature", _SE(js_cc_Purchase_signature_get), nullptr); -// cls->defineProperty("hashCode", _SE(js_cc_Purchase_hashCode_get), nullptr); -// cls->defineProperty("isAcknowledged", _SE(js_cc_Purchase_isAcknowledged_get), nullptr); -// cls->defineProperty("isAutoRenewing", _SE(js_cc_Purchase_isAutoRenewing_get), nullptr); -// cls->defineProperty("toStr", _SE(js_cc_Purchase_toString_get), nullptr); - -// cls->defineFunction("equals", _SE(js_cc_Purchase_equals)); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_Purchase)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// static bool js_cc_BillingConfig_countryCode(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::BillingConfig* arg1 = (cc::BillingConfig*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; -// result = arg1->countryCode; - -// ok &= nativevalue_to_se(result, s.rval(), s.thisObject() /*ctx*/); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// SE_HOLD_RETURN_VALUE(result, s.thisObject(), s.rval()); - -// return true; -// } -// SE_BIND_PROP_GET(js_cc_BillingConfig_countryCode) - -// static bool js_delete_cc_BillingConfig(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_BillingConfig) - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_BillingConfig) - -// bool js_register_cc_BillingConfig(se::Object* obj) { // NOLINT -// auto* cls = se::Class::create("BillingConfig", obj, nullptr, nullptr); - -// cls->defineStaticProperty("__isJSB", se::Value(true), se::PropertyAttribute::READ_ONLY | se::PropertyAttribute::DONT_ENUM | se::PropertyAttribute::DONT_DELETE); - -// cls->defineProperty("countryCode", _SE(js_cc_BillingConfig_countryCode), nullptr); - -// cls->defineFinalizeFunction(_SE(js_delete_cc_BillingConfig)); - -// cls->install(); -// JSBClassType::registerClass(cls); - -// se::ScriptEngine::getInstance()->clearException(); -// return true; -// } - -// SE_DECLARE_FINALIZE_FUNC(js_delete_cc_Google_Billing) -// se::Class *jsbWebSocketClass = nullptr; -// static bool js_cc_Google_Billing_startConnection(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::GoogleBilling* arg1 = (cc::GoogleBilling*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// arg1->startConnection(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_startConnection) - -// static bool js_cc_Google_Billing_endConnection(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::GoogleBilling* arg1 = (cc::GoogleBilling*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// arg1->endConnection(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_endConnection) - -// static bool js_cc_Google_Billing_getConnectionState(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// cc::GoogleBilling* arg1 = (cc::GoogleBilling*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// arg1->getConnectionState(); -// s.rval().setFloat(connectionState); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_getConnectionState) - -// static bool js_cc_Google_Billing_isReady(se::State& s) { -// CC_UNUSED bool ok = true; -// cc::GoogleBilling* arg1 = (cc::GoogleBilling*)NULL; -// std::string result; - -// arg1 = SE_THIS_OBJECT(s); -// if (nullptr == arg1) return true; - -// int isReady = arg1->isReady(); -// s.rval().setFloat(isReady); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_isReady) - -// static bool js_cc_Google_Billing_queryProductDetailsAsync(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); - -// std::vector* arg2 = 0; -// std::vector* arg3 = 0; -// std::vector temp2; -// std::vector temp3; - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg2 = &temp2; - -// ok &= sevalue_to_native(args[1], &temp3, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg3 = &temp3; - -// //cc::GoogleBilling::getInstance().queryProductDetailsAsync((std::vector const&)*arg2, (std::vector const&)*arg3); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_queryProductDetailsAsync) - -// static bool js_cc_Google_Billing_launchBillingFlow(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); - -// std::vector* arg2 = 0; -// std::string* arg3 = 0; -// std::vector temp2; -// std::string temp3; - -// if (argc != 2) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 2); -// return false; -// } - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg2 = &temp2; - -// ok &= sevalue_to_native(args[1], &temp3, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg3 = &temp3; - -// //cc::GoogleBilling::getInstance().launchBillingFlow((std::vector const&)*arg2, (std::string const&)*arg3); - -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_launchBillingFlow) - -// static bool js_cc_Google_Billing_consumeAsync(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); -// std::vector* arg2 = 0; -// std::vector temp2; - -// if (argc != 1) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); -// return false; -// } - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg2 = &temp2; - -// //cc::GoogleBilling::getInstance().consumeAsync((std::vector const&)*arg2); - -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_consumeAsync) - -// static bool js_cc_Google_Billing_acknowledgePurchase(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); -// std::vector* arg1 = 0; -// std::vector temp2; - -// if (argc != 1) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); -// return false; -// } - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg1 = &temp2; - -// //cc::GoogleBilling::getInstance().acknowledgePurchase((std::vector const&)*arg1); - -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_acknowledgePurchase) - -// static bool js_cc_Google_Billing_queryPurchasesAsync(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); -// std::string* arg2 = 0; -// std::string temp2; - -// if (argc != 1) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); -// return false; -// } - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// arg2 = &temp2; - -// //cc::GoogleBilling::getInstance().queryPurchasesAsync((std::string const&)*arg2); - -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_queryPurchasesAsync) - -// static bool js_cc_Google_Billing_getBillingConfigAsync(se::State& s) { // NOLINT -// //cc::GoogleBilling::getInstance().getBillingConfigAsync(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_getBillingConfigAsync) - -// static bool js_cc_Google_Billing_createAlternativeBillingOnlyReportingDetailsAsync(se::State& s) { // NOLINT -// //cc::GoogleBilling::getInstance().createAlternativeBillingOnlyReportingDetailsAsync(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_createAlternativeBillingOnlyReportingDetailsAsync) - -// static bool js_cc_Google_Billing_isAlternativeBillingOnlyAvailableAsync(se::State& s) { // NOLINT -// //cc::GoogleBilling::getInstance().isAlternativeBillingOnlyAvailableAsync(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_isAlternativeBillingOnlyAvailableAsync) - -// static bool js_cc_Google_Billing_createExternalOfferReportingDetailsAsync(se::State& s) { // NOLINT -// //cc::GoogleBilling::getInstance().createExternalOfferReportingDetailsAsync(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_createExternalOfferReportingDetailsAsync) - -// static bool js_cc_Google_Billing_isExternalOfferAvailableAsync(se::State& s) { // NOLINT -// //cc::GoogleBilling::getInstance().isExternalOfferAvailableAsync(); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_isExternalOfferAvailableAsync) - -// static bool js_cc_Google_Billing_isFeatureSupported(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// const auto& args = s.args(); -// size_t argc = args.size(); -// std::string temp2; - -// if (argc != 1) { -// SE_REPORT_ERROR("wrong number of arguments: %d, was expecting %d", (int)argc, 1); -// return false; -// } - -// ok &= sevalue_to_native(args[0], &temp2, s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); - -// //cc::BillingResult* result = cc::GoogleBilling::getInstance().isFeatureSupported(temp2); - -// ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_isFeatureSupported) - -// static bool js_cc_Google_Billing_showAlternativeBillingOnlyInformationDialog(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// //cc::BillingResult* result = cc::GoogleBilling::getInstance().showAlternativeBillingOnlyInformationDialog(); -// ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_showAlternativeBillingOnlyInformationDialog) - -// static bool js_cc_Google_Billing_showExternalOfferInformationDialog(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// //cc::BillingResult* result = cc::GoogleBilling::getInstance().showExternalOfferInformationDialog(); -// ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_showExternalOfferInformationDialog) - -// static bool js_cc_Google_Billing_showInAppMessages(se::State& s) { // NOLINT -// CC_UNUSED bool ok = true; -// //cc::BillingResult* result = cc::GoogleBilling::getInstance().showInAppMessages(); -// ok &= nativevalue_to_se(*result, s.rval(), s.thisObject()); -// SE_PRECONDITION2(ok, false, "Error processing arguments"); -// return true; -// } -// SE_BIND_FUNC(js_cc_Google_Billing_showInAppMessages) - -// static bool js_delete_cc_Google_Billing(se::State& s) { // NOLINT -// return true; -// } -// SE_BIND_FINALIZE_FUNC(js_delete_cc_Google_Billing) - -// se::Class *jsb_GoogleBilling_class = nullptr; // NOLINT - -// SE_DECLARE_FINALIZE_FUNC(jsb_BufferPool_finalize) -// static bool jsb_GoogleBilling_constructor(se::State &s) { - -// } - -// static bool jsb_googleBilling_finalize(se::State &s) { -// return true; -// } -// SE_BIND_FINALIZE_FUNC(jsb_googleBilling_finalize) -// SE_BIND_CTOR(jsb_GoogleBilling_constructor, jsb_GoogleBilling_class, jsb_googleBilling_finalize) - -// bool js_register_cc_Google_Billing(se::Object* obj) { // NOLINT - -// se::Class *cls = se::Class::create("googleBilling", obj, nullptr, _SE(jsb_GoogleBilling_constructor)); -// // se::Value googleBillingVal{se::Object::createPlainObject()}; -// // auto* cls = googleBillingVal.toObject(); - -// cls->defineFunction("startConnection", _SE(js_cc_Google_Billing_startConnection)); -// cls->defineFunction("endConnection", _SE(js_cc_Google_Billing_endConnection)); -// cls->defineFunction("getConnectionState", _SE(js_cc_Google_Billing_getConnectionState)); -// cls->defineFunction("isReady", _SE(js_cc_Google_Billing_isReady)); -// cls->defineFunction("queryProductDetailsAsync", _SE(js_cc_Google_Billing_queryProductDetailsAsync)); - -// cls->defineFunction("launchBillingFlow", _SE(js_cc_Google_Billing_launchBillingFlow)); -// cls->defineFunction("consumeAsync", _SE(js_cc_Google_Billing_consumeAsync)); -// cls->defineFunction("acknowledgePurchase", _SE(js_cc_Google_Billing_acknowledgePurchase)); -// cls->defineFunction("queryPurchasesAsync", _SE(js_cc_Google_Billing_queryPurchasesAsync)); -// cls->defineFunction("getBillingConfigAsync", _SE(js_cc_Google_Billing_getBillingConfigAsync)); - -// cls->defineFunction("createAlternativeBillingOnlyReportingDetailsAsync", _SE(js_cc_Google_Billing_createAlternativeBillingOnlyReportingDetailsAsync)); -// cls->defineFunction("isAlternativeBillingOnlyAvailableAsync", _SE(js_cc_Google_Billing_isAlternativeBillingOnlyAvailableAsync)); -// cls->defineFunction("createExternalOfferReportingDetailsAsync", _SE(js_cc_Google_Billing_createExternalOfferReportingDetailsAsync)); -// cls->defineFunction("isExternalOfferAvailableAsync", _SE(js_cc_Google_Billing_isExternalOfferAvailableAsync)); - -// cls->defineFunction("isFeatureSupported", _SE(js_cc_Google_Billing_isFeatureSupported)); - -// cls->defineFunction("showAlternativeBillingOnlyInformationDialog", _SE(js_cc_Google_Billing_showAlternativeBillingOnlyInformationDialog)); -// cls->defineFunction("showExternalOfferInformationDialog", _SE(js_cc_Google_Billing_showExternalOfferInformationDialog)); -// cls->defineFunction("showInAppMessages", _SE(js_cc_Google_Billing_showInAppMessages)); -// jsb_GoogleBilling_class = cls; - -// return true; -// } - -// bool jsb_register_all_billing(se::Object* obj) { // NOLINT -// se::Value nsVal; -// if (!obj->getProperty("jsb", &nsVal, true)) { -// se::HandleObject jsobj(se::Object::createPlainObject()); -// nsVal.setObject(jsobj); -// obj->setProperty("jsb", nsVal); -// } -// se::Object* ns = nsVal.toObject(); -// /* Register classes */ -// js_register_cc_BillingResult(ns); -// js_register_cc_OneTimePurchaseOfferDetails(ns); -// js_register_cc_InstallmentPlanDetails(ns); -// js_register_cc_PricingPhases(ns); -// js_register_cc_PricingPhase(ns); - -// js_register_cc_SubscriptionOfferDetails(ns); -// js_register_cc_ProductDetails(ns); -// js_register_cc_AccountIdentifiers(ns); -// js_register_cc_PendingPurchaseUpdate(ns); -// js_register_cc_Purchase(ns); -// js_register_cc_BillingConfig(ns); -// js_register_cc_Google_Billing(ns); -// return true; -// } - -// #else -// void jsb_register_all_billing(se::Object *ns) {} // NOLINT - -// #endif // CC_PLATFORM_ANDROID diff --git a/native/cocos/bindings/manual/jsb_module_register.cpp b/native/cocos/bindings/manual/jsb_module_register.cpp index 407170422b6..d8cabe4c041 100644 --- a/native/cocos/bindings/manual/jsb_module_register.cpp +++ b/native/cocos/bindings/manual/jsb_module_register.cpp @@ -128,7 +128,6 @@ #if CC_USE_GOOGLE_BILLING #include "cocos/bindings/auto/jsb_google_billing_auto.h" #endif -//extern bool jsb_register_all_billing(se::Object *); // NOLINT bool jsb_register_all_modules() { se::ScriptEngine *se = se::ScriptEngine::getInstance(); @@ -166,8 +165,6 @@ bool jsb_register_all_modules() { se->addRegisterCallback(register_all_render); se->addRegisterCallback(register_all_native2d); - - #if (CC_PLATFORM == CC_PLATFORM_IOS || CC_PLATFORM == CC_PLATFORM_MACOS) se->addRegisterCallback(register_javascript_objc_bridge); se->addRegisterCallback(register_script_native_bridge); @@ -198,7 +195,6 @@ bool jsb_register_all_modules() { #endif #if CC_USE_GOOGLE_BILLING - //se->addRegisterCallback(jsb_register_all_billing); se->addRegisterCallback(register_all_billing); #endif diff --git a/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java b/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java index b6bc205222a..b88d52d5f3f 100644 --- a/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java +++ b/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java @@ -28,10 +28,8 @@ of this software and associated documentation files (the "Software"), to deal import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.android.billingclient.api.BillingConfig; + import com.android.billingclient.api.BillingResult; -import com.android.billingclient.api.InAppMessageResult; -import com.android.billingclient.api.PendingPurchasesParams; import com.android.billingclient.api.ProductDetails; import com.android.billingclient.api.Purchase; import com.android.billingclient.api.AcknowledgePurchaseParams; @@ -44,33 +42,26 @@ of this software and associated documentation files (the "Software"), to deal import com.android.billingclient.api.AlternativeBillingOnlyReportingDetailsListener; import com.android.billingclient.api.ProductDetailsResponseListener; import com.android.billingclient.api.PurchasesResponseListener; -import com.android.billingclient.api.PurchasesUpdatedListener; -import com.android.billingclient.api.UserChoiceBillingListener; import com.android.billingclient.api.QueryProductDetailsParams; import com.android.billingclient.api.QueryPurchasesParams; import com.android.billingclient.api.GetBillingConfigParams; import com.android.billingclient.api.BillingConfigResponseListener; -import com.android.billingclient.api.AlternativeBillingOnlyReportingDetails; import com.android.billingclient.api.AlternativeBillingOnlyAvailabilityListener; import com.android.billingclient.api.AlternativeBillingOnlyInformationDialogListener; import com.android.billingclient.api.ExternalOfferReportingDetailsListener; -import com.android.billingclient.api.ExternalOfferReportingDetails; import com.android.billingclient.api.ExternalOfferAvailabilityListener; import com.android.billingclient.api.ExternalOfferInformationDialogListener; import com.android.billingclient.api.InAppMessageParams; import com.android.billingclient.api.InAppMessageResponseListener; import com.android.billingclient.api.BillingClientStateListener; -import com.android.billingclient.api.UserChoiceDetails; import com.cocos.lib.GlobalObject; -import com.cocos.lib.CocosHelper; -import com.google.android.gms.common.internal.Asserts; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; -public class GoogleBilling implements PurchasesUpdatedListener, UserChoiceBillingListener { +public class GoogleBilling { private static final String TAG = GoogleBilling.class.getSimpleName(); private Map _productDetails = new HashMap<>(); @@ -266,26 +257,4 @@ public BillingResult showExternalOfferInformationDialog(@NonNull ExternalOfferIn public BillingResult showInAppMessages(InAppMessageParams params, @NonNull InAppMessageResponseListener listener) { return _billingClient.showInAppMessages(GlobalObject.getActivity(), params, listener); } - - @Override - public void onPurchasesUpdated(@NonNull BillingResult billingResult, - @Nullable List purchaseList) { - int startID = pushPurchases(purchaseList); - CocosHelper.runOnGameThread(new Runnable() { - @Override - public void run() { - GoogleBillingHelper.onPurchasesUpdated(_tag, billingResult, purchaseList, startID); - } - }); - } - - @Override - public void userSelectedAlternativeBilling(@NonNull UserChoiceDetails userChoiceDetails) { - CocosHelper.runOnGameThread(new Runnable() { - @Override - public void run() { - GoogleBillingHelper.userSelectedAlternativeBilling(_tag, userChoiceDetails); - } - }); - } } diff --git a/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java b/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java index 82dd251d090..a9265687c61 100644 --- a/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java +++ b/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java @@ -24,8 +24,6 @@ of this software and associated documentation files (the "Software"), to deal package google.billing; -import android.annotation.SuppressLint; - import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -39,7 +37,6 @@ of this software and associated documentation files (the "Software"), to deal import com.android.billingclient.api.BillingConfigResponseListener; import com.android.billingclient.api.BillingFlowParams; import com.android.billingclient.api.BillingResult; -import com.android.billingclient.api.ConsumeParams; import com.android.billingclient.api.ConsumeResponseListener; import com.android.billingclient.api.ExternalOfferAvailabilityListener; import com.android.billingclient.api.ExternalOfferInformationDialogListener; @@ -58,9 +55,7 @@ of this software and associated documentation files (the "Software"), to deal import com.android.billingclient.api.UserChoiceBillingListener; import com.android.billingclient.api.UserChoiceDetails; import com.cocos.lib.CocosHelper; -import com.cocos.lib.CocosVideoView; import com.cocos.lib.GlobalObject; -import google.billing.GoogleBilling; import android.util.SparseArray; import com.android.billingclient.api.BillingClientStateListener; diff --git a/native/vendor/google/billing/GoogleBilling.cpp b/native/vendor/google/billing/GoogleBilling.cpp index 4017342b134..9813487408b 100644 --- a/native/vendor/google/billing/GoogleBilling.cpp +++ b/native/vendor/google/billing/GoogleBilling.cpp @@ -25,16 +25,41 @@ #include "vendor/google/billing/GoogleBilling.h" #include "platform/java/jni/JniHelper.h" #include "platform/java/jni/JniImp.h" +#include "cocos/bindings/jswrapper/SeApi.h" #include "vendor/google/billing/GoogleBillingHelper.h" #include "vendor/google/billing/GoogleBillingManager.h" +#include "vendor/google/billing/build-params/AcknowledgePurchaseParams.h" +#include "vendor/google/billing/build-params/BillingFlowParams.h" +#include "vendor/google/billing/build-params/ConsumeParams.h" +#include "vendor/google/billing/build-params/GetBillingConfigParams.h" +#include "vendor/google/billing/build-params/InAppMessageParams.h" +#include "vendor/google/billing/build-params/PendingPurchasesParams.h" +#include "vendor/google/billing/build-params/QueryProductDetailsParams.h" +#include "vendor/google/billing/build-params/QueryPurchasesParams.h" + namespace cc { +BillingClient::Builder& BillingClient::Builder::enableUserChoiceBilling(se::Object* listener) { + listener->root(); + listener->incRef(); + _userChoiceBillingListener = listener; + return *this; +} + +BillingClient::Builder& BillingClient::Builder::setListener(se::Object* listener) { + listener->root(); + listener->incRef(); + _purchasesUpdatedListener = listener; + return *this; +} + + BillingClient::BillingClient(Builder* builder) { this->_enableAlternativeBillingOnly = builder->_enableAlternativeBillingOnly; this->_enableExternalOffer = builder->_enableExternalOffer; this->_pendingPurchasesParams = builder->_pendingPurchasesParams; - this->purchasesUpdatedListener = builder->purchasesUpdatedListener; - this->userChoiceBillingListener = builder->userChoiceBillingListener; + this->_purchasesUpdatedListener = builder->_purchasesUpdatedListener; + this->_userChoiceBillingListener = builder->_userChoiceBillingListener; _tag = GoogleBillingHelper::createBillingClient(builder); @@ -49,22 +74,6 @@ BillingClient::~BillingClient() { GoogleBillingManager::getInstance()->removeBillingClient(_tag); } -ProductDetails::~ProductDetails() { - if (_oneTimePurchaseOfferDetails) { - delete _oneTimePurchaseOfferDetails; - _oneTimePurchaseOfferDetails = nullptr; - } - for (auto* ptr : _subscriptionOfferDetails) { - delete ptr; - } - _subscriptionOfferDetails.clear(); - GoogleBillingHelper::removeProductDetails(_tag, _id); -} - -Purchase::~Purchase() { - GoogleBillingHelper::removePurchase(_tag, _id); -} - void BillingClient::startConnection(se::Object* listener) { auto it = std::find(_billingClientStateListeners.begin(), _billingClientStateListeners.end(), listener); if (it == _billingClientStateListeners.end()) { diff --git a/native/vendor/google/billing/GoogleBilling.h b/native/vendor/google/billing/GoogleBilling.h index ef71f8dc2e4..71ce6445c86 100644 --- a/native/vendor/google/billing/GoogleBilling.h +++ b/native/vendor/google/billing/GoogleBilling.h @@ -28,895 +28,21 @@ #include "base/Macros.h" #include "base/RefCounted.h" -#include "cocos/bindings/jswrapper/SeApi.h" -namespace cc { - -class CC_DLL BillingResult : public cc::RefCounted { -public: - int getResponseCode() const { - return this->_responseCode; - } - - std::string getDebugMessage() const { - return this->_debugMessage; - } - - std::string toStr() const { - return this->_toString; - } - class Builder { - private: - int _responseCode{0}; - std::string _debugMessage; - std::string _toStr; - - public: - Builder& setDebugMessage(const std::string debugMsg) { - this->_debugMessage = debugMsg; - return *this; - } - Builder& setResponseCode(int responseCode) { - this->_responseCode = responseCode; - return *this; - } - BillingResult* build() { - auto* p = new BillingResult(); - p->_responseCode = _responseCode; - p->_debugMessage = _debugMessage; - return p; - } - }; - static Builder* newBuilder() { - return new Builder(); - } - -private: - friend class GoogleBillingToNative; - int _responseCode{0}; - std::string _debugMessage; - std::string _toString; -}; - -class CC_DLL ProductDetails : public cc::RefCounted { -public: - ~ProductDetails() override; - class OneTimePurchaseOfferDetails { - public: - long getPriceAmountMicros() const { - return this->_priceAmountMicros; - } - - std::string getFormattedPrice() const { - return this->_formattedPrice; - } - - std::string getPriceCurrencyCode() const { - return this->_priceCurrencyCode; - } - - private: - friend class GoogleBillingToNative; - long _priceAmountMicros{0}; - std::string _formattedPrice; - std::string _priceCurrencyCode; - }; - - class InstallmentPlanDetails { - public: - int getInstallmentPlanCommitmentPaymentsCount() const { - return this->_commitmentPaymentsCount; - } - int getSubsequentInstallmentPlanCommitmentPaymentsCount() const { - return this->_subsequentCommitmentPaymentsCount; - } - - private: - friend class GoogleBillingToNative; - int _commitmentPaymentsCount{0}; - int _subsequentCommitmentPaymentsCount{0}; - }; - - class PricingPhase { - public: - int getBillingCycleCount() const { - return this->_billingCycleCount; - } - - int getRecurrenceMode() const { - return this->_priceAmountMicros; - } - - long getPriceAmountMicros() const { - return this->_recurrenceMode; - } - - std::string getBillingPeriod() const { - return this->_billingPeriod; - } - std::string getFormattedPrice() const { - return this->_formattedPrice; - } - - std::string getPriceCurrencyCode() const { - return this->_priceCurrencyCode; - } - - private: - friend class GoogleBillingToNative; - int _billingCycleCount{0}; - long _priceAmountMicros{0}; - int _recurrenceMode{0}; - std::string _billingPeriod; - std::string _formattedPrice; - std::string _priceCurrencyCode; - }; - - class PricingPhases { - public: - std::vector getPricingPhaseList() const { - return this->_pricingPhaseList; - } - ~PricingPhases() { - for (auto* pricingPhase : _pricingPhaseList) { - delete pricingPhase; - } - _pricingPhaseList.clear(); - } - - private: - friend class GoogleBillingToNative; - std::vector _pricingPhaseList; - }; - class SubscriptionOfferDetails { - public: - ~SubscriptionOfferDetails() { - if (this->_pricingPhases != nullptr) { - delete this->_pricingPhases; - this->_pricingPhases = nullptr; - } - - if (this->_installmentPlanDetails != nullptr) { - delete this->_installmentPlanDetails; - this->_installmentPlanDetails = nullptr; - } - } - InstallmentPlanDetails* getInstallmentPlanDetails() const { - return this->_installmentPlanDetails; - } - - PricingPhases* getPricingPhases() const { - return this->_pricingPhases; - } - - std::string getBasePlanId() const { - return this->_basePlanId; - } - - std::string getOfferId() const { - return this->_offerId; - } - - std::string getOfferToken() const { - return this->_offerToken; - } - - std::vector getOfferTags() const { - return this->_offerTags; - } - - private: - friend class GoogleBillingToNative; - std::string _basePlanId; - std::string _offerId; - std::string _offerToken; - std::vector _offerTags; - PricingPhases* _pricingPhases{nullptr}; - InstallmentPlanDetails* _installmentPlanDetails{nullptr}; - }; - int hashCode() const { - return this->_hashCode; - } - - OneTimePurchaseOfferDetails* getOneTimePurchaseOfferDetails() const { - return this->_oneTimePurchaseOfferDetails; - } - - std::string getDescription() const { - return this->_description; - } - - std::string getName() const { - return this->_name; - } - - std::string getProductId() const { - return this->_productId; - } - - std::string getProductType() const { - return this->_productType; - } - - std::string getTitle() const { - return this->_title; - } - - std::string toStr() const { - return this->_toString; - } - - bool equals(const ProductDetails& other) const { - return this->_hashCode == other._hashCode; - } - - std::vector getSubscriptionOfferDetails() const { - return this->_subscriptionOfferDetails; - } - -private: - friend class GoogleBillingToNative; - friend class GoogleBillingHelper; - int _id{-1}; // This is an ID that is not visible to ts and is used to free the java object. - int _tag{-1}; // This is an ID that is not visible to ts and is used to specify which billingclient. - int _hashCode{0}; - std::string _description; - std::string _name; - std::string _productId; - std::string _productType; - std::string _title; - std::string _toString; - OneTimePurchaseOfferDetails* _oneTimePurchaseOfferDetails{nullptr}; - std::vector _subscriptionOfferDetails; -}; -class CC_DLL AccountIdentifiers { -public: - std::string getObfuscatedAccountId() const { - return this->_obfuscatedAccountId; - } - - std::string getObfuscatedProfileId() const { - return this->_obfuscatedProfileId; - } - -private: - friend class GoogleBillingToNative; - friend class Purchase; - std::string _obfuscatedAccountId; - std::string _obfuscatedProfileId; -}; - -class CC_DLL Purchase : public cc::RefCounted { -public: - class CC_DLL PendingPurchaseUpdate { - public: - std::string getPurchaseToken() const { - return this->_purchaseToken; - } - - std::vector getProducts() const { - return this->_products; - } - - private: - friend class GoogleBillingToNative; - std::string _purchaseToken; - std::vector _products; - }; - - int getPurchaseState() const { - return this->_purchaseState; - } - int getQuantity() const { - return this->_quantity; - } - - int hashCode() const { - return this->_hashCode; - } - - long getPurchaseTime() const { - return this->_purchaseTime; - } - - AccountIdentifiers* getAccountIdentifiers() const { - return this->_accountIdentifiers; - } - PendingPurchaseUpdate* getPendingPurchaseUpdate() const { - return this->_pendingPurchaseUpdate; - } - - std::string getDeveloperPayload() const { - return this->_developerPayload; - } - - std::string getOrderId() const { - return this->_orderId; - } - - std::string getOriginalJson() const { - return this->_originalJson; - } - - std::string getPackageName() const { - return this->_packageName; - } - - std::string getPurchaseToken() const { - return this->_purchaseToken; - } - - std::string getSignature() const { - return this->_signature; - } - - std::string toStr() const { - return this->_toString; - } - - std::vector getProducts() const { - return this->_products; - } - bool isAcknowledged() const { - return this->_isAcknowledged; - } - - bool isAutoRenewing() const { - return this->_isAutoRenewing; - } - ~Purchase() override; - bool equals(const Purchase& other) const { - return this->_hashCode == other._hashCode; - } - -private: - friend class GoogleBillingToNative; - friend class GoogleBillingHelper; - int _id{-1}; // This is an ID that is not visible to ts and is used to free the java object. - int _tag{-1}; // This is an ID that is not visible to ts and is used to specify which billingclient. - bool _isAcknowledged{false}; - bool _isAutoRenewing{false}; - int _purchaseState{0}; - int _hashCode{0}; - int _quantity{0}; - long _purchaseTime{0}; - std::string _developerPayload; - std::string _orderId; - std::string _originalJson; - std::string _packageName; - std::string _purchaseToken; - std::string _signature; - std::string _toString; - AccountIdentifiers* _accountIdentifiers{nullptr}; - PendingPurchaseUpdate* _pendingPurchaseUpdate{nullptr}; - std::vector _products; -}; - -class CC_DLL BillingConfig : public cc::RefCounted { -public: - std::string getCountryCode() const { - return this->_countryCode; - } - static BillingConfig* forCountryCode(const std::string countryCode) { - return new BillingConfig(countryCode); - } - -private: - friend class GoogleBillingToNative; - BillingConfig(const std::string countryCode) { - this->_countryCode = countryCode; - } - std::string _countryCode; -}; - -class AlternativeBillingOnlyReportingDetails : public cc::RefCounted { -public: - std::string getExternalTransactionToken() const { - return this->_externalTransactionToken; - } - -private: - friend class GoogleBillingToNative; - std::string _externalTransactionToken; -}; - -class ExternalOfferReportingDetails : public cc::RefCounted { -public: - std::string getExternalTransactionToken() const { - return this->_externalTransactionToken; - } - -private: - friend class GoogleBillingToNative; - std::string _externalTransactionToken; -}; - -class InAppMessageResult : public cc::RefCounted { -public: - int getResponseCode() const { - return this->_responseCode; - } - - std::string getPurchaseToken() const { - return this->_purchaseToken; - } - - InAppMessageResult(int responseCode, const std::string& purchaseToken) { - this->_responseCode = responseCode; - this->_purchaseToken = purchaseToken; - } - -private: - friend class GoogleBillingToNative; - int _responseCode{0}; - std::string _purchaseToken; -}; - -class UserChoiceDetails : public cc::RefCounted { -public: - class Product { - public: - int hashCode() const { - return _hashCode; - } - std::string getId() const { - return _id; - } - std::string getOfferToken() const { - return _type; - } - std::string getType() const { - return _offerToken; - } - std::string toStr() const { - return _toStr; - } - bool equals(const Product& p) { - if (&p == this) { - return true; - } - return p._id == _id && p._type == _type && p._offerToken == _offerToken; - } - - private: - friend class GoogleBillingToNative; - int _hashCode{0}; - std::string _id; - std::string _type; - std::string _offerToken; - std::string _toStr; - }; - - ~UserChoiceDetails() { - for (auto* product : _products) { - delete product; - } - _products.clear(); - } - std::string getExternalTransactionToken() const { - return _externalTransactionToken; - } - std::string getOriginalExternalTransactionId() const { - return _originalExternalTransactionId; - } - - std::vector getProducts() { - return this->_products; - } - -private: - friend class GoogleBillingToNative; - std::string _externalTransactionToken; - std::string _originalExternalTransactionId; - std::vector _products; -}; - -class PendingPurchasesParams { -public: - class Builder { - private: - bool _enableOneTimeProducts; - bool _enablePrepaidPlans; - - public: - Builder& enableOneTimeProducts() { - this->_enableOneTimeProducts = true; - return *this; - } - Builder& enablePrepaidPlans() { - this->_enablePrepaidPlans = true; - return *this; - } - PendingPurchasesParams* build() { - if (!this->_enableOneTimeProducts) { - return nullptr; - } - return new PendingPurchasesParams(this->_enableOneTimeProducts, this->_enablePrepaidPlans); - } - }; - - static Builder* newBuilder() { - return new Builder(); - } - -private: - PendingPurchasesParams(bool enableOneTimeProducts, bool enablePrepaidPlans) { - this->_enableOneTimeProducts = enableOneTimeProducts; - this->_enablePrepaidPlans = enablePrepaidPlans; - } - -private: - friend class GoogleBillingToNative; - friend class BillingClient; - bool _enableOneTimeProducts{false}; - bool _enablePrepaidPlans{false}; -}; - -class PurchasesUpdatedListener { -public: - void onPurchasesUpdated(BillingResult, Purchase) { - } -}; - -class Product { -public: - class Builder { - private: - std::string _productID; - std::string _productType; - - public: - Builder& setProductId(const std::string& productID) { - this->_productID = productID; - return *this; - } - Builder& setProductType(const std::string& productType) { - this->_productType = productType; - return *this; - } - Product* build() { - if (_productID.empty()) { - } else if (_productType.empty()) { - } - return new Product(_productID, _productType); - } - }; - - static Builder* newBuilder() { - return new Builder(); - } - -private: - Product(const std::string& productID, const std::string& productType) { - this->_productID = productID; - this->_productType = productType; - } - -private: - friend class BillingClient; - std::string _productID; - std::string _productType; -}; - -class QueryProductDetailsParams { -public: - class Builder { - private: - std::vector _productList; - - public: - Builder& setProductList(const std::vector& productList) { - _productList = productList; - return *this; - } - - QueryProductDetailsParams* build() { - if (this->_productList.empty()) { - return nullptr; - } - return new QueryProductDetailsParams(this->_productList); - } - }; - - static Builder* newBuilder() { - return new Builder(); - } - -private: - QueryProductDetailsParams(const std::vector& productLists) { - _productList = productLists; - } - -private: - friend class BillingClient; - std::vector _productList; -}; - -class CC_DLL BillingFlowParams { -public: - class SubscriptionUpdateParams { - public: - class Builder { - public: - Builder& setOldPurcchaseToken(const std::string& purchaseToken) { - this->_purchaseToken = purchaseToken; - return *this; - } - Builder& setOriginalExternalTransactionId(const std::string& externalTransactionId) { - this->_externalTransactionId = externalTransactionId; - return *this; - } - Builder& setSubscriptionReplacementMode(int subscriptionReplacementMode) { - this->_subscriptionReplacementMode = subscriptionReplacementMode; - return *this; - } - SubscriptionUpdateParams* build() { - return new SubscriptionUpdateParams(_subscriptionReplacementMode, _purchaseToken, _externalTransactionId); - } - - private: - int _subscriptionReplacementMode; - std::string _purchaseToken; - std::string _externalTransactionId; - }; - static Builder* newBuilder() { - return new Builder(); - } - - private: - SubscriptionUpdateParams(int subscriptionReplacementMode, const std::string& purchaseToken, const std::string& externalTransactionId) { - this->_subscriptionReplacementMode = subscriptionReplacementMode; - this->_purchaseToken = purchaseToken; - this->_externalTransactionId = externalTransactionId; - } - friend class GoogleBillingToNative; - int _subscriptionReplacementMode; - std::string _purchaseToken; - std::string _externalTransactionId; - }; - - class ProductDetailsParams { - public: - class Builder { - public: - Builder& setOfferToken(const std::string& offerToken) { - this->_offerToken = offerToken; - return *this; - } - Builder& setProductDetails(ProductDetails* productDetails) { - this->_productDetails = productDetails; - return *this; - } - ProductDetailsParams* build() { - return new ProductDetailsParams(_offerToken, _productDetails); - } - - private: - std::string _offerToken; - ProductDetails* _productDetails; - }; - static Builder* newBuilder() { - return new Builder(); - } - - private: - friend class GoogleBillingToNative; - ProductDetailsParams(std::string offerToken, ProductDetails* _productDetails) { - this->_offerToken = offerToken; - this->_productDetails = _productDetails; - } - - std::string _offerToken; - ProductDetails* _productDetails{nullptr}; - }; - - class Builder { - public: - Builder& setIsOfferPersonalized(bool isOfferPersonalized) { - this->_isOfferPersonalized = isOfferPersonalized; - return *this; - } - Builder& setObfuscatedAccountId(const std::string& obfuscatedAccountid) { - this->_obfuscatedAccountid = obfuscatedAccountid; - return *this; - } - Builder& setObfuscatedProfileId(const std::string& obfuscatedProfileId) { - this->_obfuscatedProfileId = obfuscatedProfileId; - return *this; - } - Builder& setProductDetailsParamsList(const std::vector& productDetailsParamsList) { - this->_productDetailsParamsList = productDetailsParamsList; - return *this; - } - Builder& setSubscriptionUpdateParams(SubscriptionUpdateParams* subscriptionUpdateParams) { - this->_subscriptionUpdateParams = subscriptionUpdateParams; - return *this; - } - BillingFlowParams* build() { - return new BillingFlowParams(_isOfferPersonalized, _obfuscatedAccountid, _obfuscatedProfileId, _productDetailsParamsList, _subscriptionUpdateParams); - } - - private: - friend class GoogleBillingToNative; - bool _isOfferPersonalized{false}; - std::string _obfuscatedAccountid; - std::string _obfuscatedProfileId; - std::vector _productDetailsParamsList; - SubscriptionUpdateParams* _subscriptionUpdateParams{nullptr}; - }; - static Builder* newBuilder() { - return new Builder(); - } - -private: - friend class GoogleBillingHelper; - friend class GoogleBillingToNative; - BillingFlowParams(bool isOfferPersonalized, - const std::string& obfuscatedAccountid, - const std::string& obfuscatedProfileId, - const std::vector& productDetailsParamsList, - SubscriptionUpdateParams* subscriptionUpdateParams) { - _isOfferPersonalized = isOfferPersonalized; - _obfuscatedAccountid = obfuscatedAccountid; - _obfuscatedProfileId = obfuscatedProfileId; - _productDetailsParamsList = productDetailsParamsList; - _subscriptionUpdateParams = subscriptionUpdateParams; - } - bool _isOfferPersonalized{false}; - std::string _obfuscatedAccountid; - std::string _obfuscatedProfileId; - std::vector _productDetailsParamsList; - SubscriptionUpdateParams* _subscriptionUpdateParams{nullptr}; -}; - -class ConsumeParams { -public: - class Builder { - public: - Builder& setPurchaseToken(const std::string& purchaseToken) { - this->_purchaseToken = purchaseToken; - return *this; - } - - ConsumeParams* build() { - return new ConsumeParams(this->_purchaseToken); - } - - private: - std::string _purchaseToken; - }; - - std::string getPurchaseToken() const { - return _purchaseToken; - } - - static Builder* newBuilder() { - return new Builder(); - } - -private: - ConsumeParams(const std::string& purchaseToken) { - this->_purchaseToken = purchaseToken; - } - - std::string _purchaseToken; -}; - -class AcknowledgePurchaseParams { -public: - class Builder { - public: - Builder& setPurchaseToken(const std::string& purchaseToken) { - this->_purchaseToken = purchaseToken; - return *this; - } - - AcknowledgePurchaseParams* build() { - return new AcknowledgePurchaseParams(this->_purchaseToken); - } - - private: - std::string _purchaseToken; - }; - - std::string getPurchaseToken() const { - return _purchaseToken; - } - - static Builder* newBuilder() { - return new Builder(); - } - -private: - AcknowledgePurchaseParams(const std::string& purchaseToken) { - this->_purchaseToken = purchaseToken; - } - - std::string _purchaseToken; -}; - -class QueryPurchasesParams { -public: - class Builder { - public: - Builder& setProductType(const std::string& productType) { - this->_productType = productType; - return *this; - } - - QueryPurchasesParams* build() { - return new QueryPurchasesParams(this->_productType); - } - - private: - std::string _productType; - }; - - static Builder* newBuilder() { - return new Builder(); - } - -private: - QueryPurchasesParams(const std::string& productType) { - this->_productType = productType; - } - friend class BillingClient; - std::string _productType; -}; - - -class InAppMessageParams { -public: - class Builder { - public: - Builder& addAllInAppMessageCategoriesToShow() { - this->_inAppMessageCategoryIds.push_back(2); - return *this; - } - - Builder& addInAppMessageCategoryToShow(int inAppMessageCategoryId) { - this->_inAppMessageCategoryIds.push_back(inAppMessageCategoryId); - return *this; - } - - InAppMessageParams* build() { - return new InAppMessageParams(this->_inAppMessageCategoryIds); - } - - private: - std::vector _inAppMessageCategoryIds; - }; - - static Builder* newBuilder() { - return new Builder(); - } - -private: - InAppMessageParams(const std::vector& inAppMessageCategoryIds) { - this->_inAppMessageCategoryIds = inAppMessageCategoryIds; - } - friend class BillingClient; - std::vector _inAppMessageCategoryIds; -}; - -class GetBillingConfigParams { -public: - class Builder { - public: - GetBillingConfigParams* build() { - return new GetBillingConfigParams(); - } - }; - - static Builder* newBuilder() { - return new Builder(); - } - -private: - GetBillingConfigParams() { - } -}; +namespace se { +class Object; +} +namespace cc { +class PendingPurchasesParams; +class QueryProductDetailsParams; +class BillingFlowParams; +class ConsumeParams; +class AcknowledgePurchaseParams; +class QueryPurchasesParams; +class GetBillingConfigParams; +class InAppMessageParams; +class BillingResult; class CC_DLL BillingClient : public cc::RefCounted { public: @@ -937,20 +63,9 @@ class CC_DLL BillingClient : public cc::RefCounted { return *this; } - Builder& enableUserChoiceBilling(se::Object* listener) { - listener->root(); - listener->incRef(); - userChoiceBillingListener = listener; - return *this; - } + Builder& enableUserChoiceBilling(se::Object* listener) ; - Builder& setListener(se::Object* listener) { - listener->root(); - listener->incRef(); - purchasesUpdatedListener = listener; - // this->invokeListener(); - return *this; - } + Builder& setListener(se::Object* listener) ; BillingClient* build() { return new BillingClient(this); @@ -958,12 +73,12 @@ class CC_DLL BillingClient : public cc::RefCounted { private: friend class BillingClient; - friend class GoogleBillingToNative; + friend class JniBilling; bool _enableAlternativeBillingOnly; bool _enableExternalOffer; PendingPurchasesParams* _pendingPurchasesParams; - se::Object* purchasesUpdatedListener; - se::Object* userChoiceBillingListener; + se::Object* _purchasesUpdatedListener; + se::Object* _userChoiceBillingListener; }; static Builder* newBuilder() { return new Builder(); @@ -997,8 +112,8 @@ class CC_DLL BillingClient : public cc::RefCounted { bool _enableAlternativeBillingOnly{false}; bool _enableExternalOffer{false}; - se::Object* purchasesUpdatedListener{nullptr}; - se::Object* userChoiceBillingListener{nullptr}; + se::Object* _purchasesUpdatedListener{nullptr}; + se::Object* _userChoiceBillingListener{nullptr}; PendingPurchasesParams* _pendingPurchasesParams{nullptr}; std::vector _billingClientStateListeners; diff --git a/native/vendor/google/billing/GoogleBillingHelper.cpp b/native/vendor/google/billing/GoogleBillingHelper.cpp index d862232fe6a..15dd4dbe97b 100644 --- a/native/vendor/google/billing/GoogleBillingHelper.cpp +++ b/native/vendor/google/billing/GoogleBillingHelper.cpp @@ -34,8 +34,12 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global_init.h" #include "vendor/google/billing/GoogleBilling.h" -#include "vendor/google/billing/GoogleBillingToNative.h" +#include "vendor/google/billing/JniBilling.h" #include "vendor/google/billing/GoogleBillingManager.h" +#include "vendor/google/billing/result-values/Purchase.h" +#include "vendor/google/billing/build-params/AcknowledgePurchaseParams.h" +#include "vendor/google/billing/result-values/ProductDetails.h" +#include "vendor/google/billing/build-params/ConsumeParams.h" namespace { #ifndef JCLS_BILLING @@ -87,10 +91,9 @@ template void callJSfunc(se::Object* obj, const char*, BillingResult*&&, Alterna template void callJSfunc(se::Object* obj, const char*, BillingResult*&&, ExternalOfferReportingDetails*&&); template void callJSfunc(se::Object* obj, const char*, InAppMessageResult*&&); -int GoogleBillingHelper::createBillingClient(void* params) { +int GoogleBillingHelper::createBillingClient(BillingClient::Builder* builder) { int tag = JniHelper::callStaticIntMethod(JCLS_BILLING, "newTag"); - auto* builder = reinterpret_cast(params); - jobject buildObj = GoogleBillingToNative::newBillingClientBuilderObject(tag, builder); + jobject buildObj = JniBilling::newBillingClientBuilderObject(tag, builder); cc::JniMethodInfo t; cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, "createBillingClient", "(ILcom/android/billingclient/api/BillingClient$Builder;)V"); @@ -157,11 +160,11 @@ void GoogleBillingHelper::isExternalOfferAvailableAsync(int tag, int callbackId) } BillingResult* GoogleBillingHelper::showAlternativeBillingOnlyInformationDialog(int tag, int callbackId) { - return cc::GoogleBillingToNative::callFunctionAndReturnBillingResult("showAlternativeBillingOnlyInformationDialog", tag, callbackId); + return cc::JniBilling::callFunctionAndReturnBillingResult("showAlternativeBillingOnlyInformationDialog", tag, callbackId); } BillingResult* GoogleBillingHelper::showExternalOfferInformationDialog(int tag, int callbackId) { - return cc::GoogleBillingToNative::callFunctionAndReturnBillingResult("showExternalOfferInformationDialog", tag, callbackId); + return cc::JniBilling::callFunctionAndReturnBillingResult("showExternalOfferInformationDialog", tag, callbackId); } BillingResult* GoogleBillingHelper::showInAppMessages(int tag, int callbackId, const std::vector& inAppMessageCategoryId) { @@ -177,62 +180,15 @@ BillingResult* GoogleBillingHelper::showInAppMessages(int tag, int callbackId, c env->SetIntArrayRegion(result, 0, size, buf); delete[] buf; jobject obj = t.env->CallStaticObjectMethod(t.classID, t.methodID, tag, callbackId, result); - return cc::GoogleBillingToNative::toBillingResult(env, obj); + return cc::JniBilling::toBillingResult(env, obj); } return nullptr; } void GoogleBillingHelper::launchBillingFlow(int tag, BillingFlowParams* params) { - - - JNIEnv *env = cc::JniHelper::getEnv(); - cc::JniMethodInfo t; - cc::JniHelper::getStaticMethodInfo(t, "com/android/billingclient/api/BillingFlowParams", "newBuilder", "()Lcom/android/billingclient/api/BillingFlowParams$Builder;"); - jobject builder = t.env->CallStaticObjectMethod(t.classID, t.methodID); - jclass builderClass = env->GetObjectClass(builder); - - jmethodID setIsOfferPersonalizedMethodId = env->GetMethodID(builderClass, "setIsOfferPersonalized", "(Z)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); - env->CallObjectMethod(builder, setIsOfferPersonalizedMethodId, params->_isOfferPersonalized); - - jmethodID setObfuscatedAccountIdMethodId = env->GetMethodID(builderClass, "setObfuscatedAccountId", "(Ljava/lang/String;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); - env->CallObjectMethod(builder, setObfuscatedAccountIdMethodId, cc::StringUtils::newStringUTFJNI(env, params->_obfuscatedAccountid)); - - jmethodID setObfuscatedProfileIdMethodId = env->GetMethodID(builderClass, "setObfuscatedProfileId", "(Ljava/lang/String;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); - env->CallObjectMethod(builder, setObfuscatedProfileIdMethodId, cc::StringUtils::newStringUTFJNI(env, params->_obfuscatedProfileId)); - - jobject listObjs = GoogleBillingToNative::newProductDetailsParamsListObject(params->_productDetailsParamsList); - jmethodID setProductDetailsParamsListMethodId = env->GetMethodID(builderClass, "setProductDetailsParamsList", "(Ljava/util/List;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); - env->CallObjectMethod(builder, setProductDetailsParamsListMethodId, listObjs); - - if(params->_subscriptionUpdateParams) { - jobject subscriptionOfferDetailsObj = GoogleBillingToNative::newSubscriptionUpdateParamsObject(params->_subscriptionUpdateParams); - jmethodID setSubscriptionUpdateParamsMethodId = env->GetMethodID(builderClass, "setSubscriptionUpdateParams", "(Lcom/android/billingclient/api/BillingFlowParams$SubscriptionUpdateParams;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); - env->CallObjectMethod(builder, setSubscriptionUpdateParamsMethodId, subscriptionOfferDetailsObj); - } - - jmethodID buildMethodId = env->GetMethodID(builderClass, "build", "()Lcom/android/billingclient/api/BillingFlowParams;"); - jobject billingFlowParamsObj = env->CallObjectMethod(builder, buildMethodId); - cc::JniMethodInfo t1; cc::JniHelper::getStaticMethodInfo(t1, JCLS_BILLING, "launchBillingFlow", "(ILcom/android/billingclient/api/BillingFlowParams;)V"); - t1.env->CallStaticVoidMethod(t1.classID, t1.methodID, tag, billingFlowParamsObj); - - // if (productDetailsList.empty()) { - // return; - // } - // auto* env = JniHelper::getEnv(); - // const int size = productDetailsList.size(); - // jintArray result = env->NewIntArray(size); - // jint* buf = new jint[size]; - // for (int i = 0; i < size; ++i) { - // buf[i] = productDetailsList[i]->_id; - // } - // env->SetIntArrayRegion(result, 0, size, buf); - // delete[] buf; - // cc::JniMethodInfo t; - // cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, "launchBillingFlow", "([ILjava/lang/String;)V"); - // jstring offerToken = env->NewStringUTF(selectedOfferToken.c_str()); - // t.env->CallStaticVoidMethod(t.classID, t.methodID, result, offerToken); + t1.env->CallStaticVoidMethod(t1.classID, t1.methodID, tag, JniBilling::newBillingFlowParamsObject(params)); } void GoogleBillingHelper::consumeAsync(int tag, int callbackId, ConsumeParams* purchase) { @@ -255,7 +211,7 @@ BillingResult* GoogleBillingHelper::isFeatureSupported(int tag, const std::strin if (cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, "isFeatureSupported", "(Ljava/lang/String;)Lcom/android/billingclient/api/BillingResult;")) { jstring jFeature = cc::StringUtils::newStringUTFJNI(env, feature); jobject obj = t.env->CallStaticObjectMethod(t.classID, t.methodID, jFeature); - return cc::GoogleBillingToNative::toBillingResult(env, obj); + return cc::JniBilling::toBillingResult(env, obj); } return nullptr; } @@ -264,7 +220,7 @@ void GoogleBillingHelper::onBillingSetupFinished(JNIEnv* env, jclass clazz, jint auto* billingClient = GoogleBillingManager::getInstance()->getBillingClient(tag); if (billingClient) { CC_ASSERT(callbackID >= 0 && callbackID < billingClient->_billingClientStateListeners.size()); - cc::callJSfunc(billingClient->_billingClientStateListeners[callbackID], "onBillingSetupFinished", cc::GoogleBillingToNative::toBillingResult(env, billingResultObj)); + cc::callJSfunc(billingClient->_billingClientStateListeners[callbackID], "onBillingSetupFinished", cc::JniBilling::toBillingResult(env, billingResultObj)); } } @@ -282,8 +238,8 @@ void GoogleBillingHelper::onProductDetailsResponse(JNIEnv* env, jclass clazz, jobject billingResultObj, jobject productDetailsListObj, jint startID) { - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); - std::vector productDetailsList = cc::GoogleBillingToNative::toProductDetailList(env, productDetailsListObj, startID); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); + std::vector productDetailsList = cc::JniBilling::toProductDetailList(env, productDetailsListObj, startID); auto* billingClient = GoogleBillingManager::getInstance()->getBillingClient(tag); if (billingClient) { CC_ASSERT(callbackID >= 0 && callbackID < billingClient->_productDetailsResponseListeners.size()); @@ -298,21 +254,21 @@ void GoogleBillingHelper::onPurchasesUpdated(JNIEnv* env, jclass clazz, jint startID) { auto* billingClient = GoogleBillingManager::getInstance()->getBillingClient(tag); - if (billingClient && billingClient->purchasesUpdatedListener) { - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + if (billingClient && billingClient->_purchasesUpdatedListener) { + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); std::vector purchasesList; if (purchasesListObj != nullptr) { - purchasesList = cc::GoogleBillingToNative::toPurchaseList(env, purchasesListObj, startID); + purchasesList = cc::JniBilling::toPurchaseList(env, purchasesListObj, startID); } - cc::callJSfunc(billingClient->purchasesUpdatedListener, "onPurchasesUpdated", billingResult, purchasesList); + cc::callJSfunc(billingClient->_purchasesUpdatedListener, "onPurchasesUpdated", billingResult, purchasesList); } } void GoogleBillingHelper::userSelectedAlternativeBilling(JNIEnv *env, jclass clazz, jint tag, jobject userChoiceDetailsObj) { auto* billingClient = GoogleBillingManager::getInstance()->getBillingClient(tag); - if (billingClient && billingClient->userChoiceBillingListener) { - auto* userChoiceDetails = cc::GoogleBillingToNative::toUserChoiceDetails(env, userChoiceDetailsObj); - cc::callJSfunc(billingClient->userChoiceBillingListener, "userSelectedAlternativeBilling", userChoiceDetails); + if (billingClient && billingClient->_userChoiceBillingListener) { + auto* userChoiceDetails = cc::JniBilling::toUserChoiceDetails(env, userChoiceDetailsObj); + cc::callJSfunc(billingClient->_userChoiceBillingListener, "userSelectedAlternativeBilling", userChoiceDetails); } } @@ -320,7 +276,7 @@ void GoogleBillingHelper::onConsumeResponse(JNIEnv* env, jclass clazz, jint tag, auto* billingClient = GoogleBillingManager::getInstance()->getBillingClient(tag); if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_consumeResponseListeners.size()); - auto *billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto *billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::callJSfunc(billingClient->_consumeResponseListeners[callbackId], "onConsumeResponse", billingResult, cc::StringUtils::getStringUTFCharsJNI(env,static_cast(purchaseToken))); @@ -332,7 +288,7 @@ void GoogleBillingHelper::onAcknowledgePurchaseResponse(JNIEnv* env, jclass claz if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_acknowledgePurchaseResponseListeners.size()); - auto *billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto *billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::callJSfunc(billingClient->_acknowledgePurchaseResponseListeners[callbackId], "onAcknowledgePurchaseResponse", billingResult); } } @@ -342,8 +298,8 @@ void GoogleBillingHelper::onQueryPurchasesResponse(JNIEnv* env, jclass clazz, ji if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_queryPurchasesResponseListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); - std::vector purchasesList = cc::GoogleBillingToNative::toPurchaseList(env, purchasesListObj, startID); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); + std::vector purchasesList = cc::JniBilling::toPurchaseList(env, purchasesListObj, startID); cc::callJSfunc(billingClient->_queryPurchasesResponseListeners[callbackId], "onQueryPurchasesResponse", billingResult, purchasesList); } } @@ -353,10 +309,10 @@ void GoogleBillingHelper::onBillingConfigResponse(JNIEnv* env, jclass clazz, jin if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_billingConfigListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::BillingConfig* billingConfig = nullptr; if (billingConfigObj) { - billingConfig = cc::GoogleBillingToNative::toBillingConfig(env, billingConfigObj); + billingConfig = cc::JniBilling::toBillingConfig(env, billingConfigObj); } cc::callJSfunc(billingClient->_billingConfigListeners[callbackId], "onBillingConfigResponse", billingResult, billingConfig); } @@ -367,10 +323,10 @@ void GoogleBillingHelper::onAlternativeBillingOnlyTokenResponse(JNIEnv* env, jcl if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_alternativeBillingOnlyReportingDetailsListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::AlternativeBillingOnlyReportingDetails* toAlternativeBillingOnlyReporting = nullptr; if (alternativeBillingOnlyReportingDetailsObj) { - toAlternativeBillingOnlyReporting = cc::GoogleBillingToNative::toAlternativeBillingOnlyReportingDetails(env, alternativeBillingOnlyReportingDetailsObj); + toAlternativeBillingOnlyReporting = cc::JniBilling::toAlternativeBillingOnlyReportingDetails(env, alternativeBillingOnlyReportingDetailsObj); } cc::callJSfunc(billingClient->_alternativeBillingOnlyReportingDetailsListeners[callbackId], "onAlternativeBillingOnlyTokenResponse", billingResult, toAlternativeBillingOnlyReporting); } @@ -381,10 +337,10 @@ void GoogleBillingHelper::onExternalOfferReportingDetailsResponse(JNIEnv* env, j if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_externalOfferReportingDetailsListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::ExternalOfferReportingDetails* externalOfferReportingDetails = nullptr; if (externalOfferReportingDetailsObj) { - externalOfferReportingDetails = cc::GoogleBillingToNative::toExternalOfferReportingDetails(env, externalOfferReportingDetailsObj); + externalOfferReportingDetails = cc::JniBilling::toExternalOfferReportingDetails(env, externalOfferReportingDetailsObj); } cc::callJSfunc(billingClient->_externalOfferReportingDetailsListeners[callbackId], "onExternalOfferReportingDetailsResponse", billingResult, externalOfferReportingDetails); } @@ -395,7 +351,7 @@ void GoogleBillingHelper::onAlternativeBillingOnlyAvailabilityResponse(JNIEnv* e if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_alternativeBillingOnlyAvailabilityListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::callJSfunc(billingClient->_alternativeBillingOnlyAvailabilityListeners[callbackId], "onAlternativeBillingOnlyAvailabilityResponse", billingResult); } } @@ -405,7 +361,7 @@ void GoogleBillingHelper::onExternalOfferAvailabilityResponse(JNIEnv* env, jclas if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_externalOfferAvailabilityListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::callJSfunc(billingClient->_externalOfferAvailabilityListeners[callbackId], "onExternalOfferAvailabilityResponse", billingResult); } } @@ -415,7 +371,7 @@ void GoogleBillingHelper::onAlternativeBillingOnlyInformationDialogResponse(JNIE if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_alternativeBillingOnlyInformationDialogListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::callJSfunc(billingClient->_alternativeBillingOnlyInformationDialogListeners[callbackId], "onAlternativeBillingOnlyInformationDialogResponse", billingResult); } } @@ -425,7 +381,7 @@ void GoogleBillingHelper::onExternalOfferInformationDialogResponse(JNIEnv* env, if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_externalOfferInformationDialogListeners.size()); - auto* billingResult = cc::GoogleBillingToNative::toBillingResult(env, billingResultObj); + auto* billingResult = cc::JniBilling::toBillingResult(env, billingResultObj); cc::callJSfunc(billingClient->_externalOfferInformationDialogListeners[callbackId], "onExternalOfferInformationDialogResponse", billingResult); } } @@ -435,7 +391,7 @@ void GoogleBillingHelper::onInAppMessageResponse(JNIEnv* env, jclass clazz, jint if (billingClient) { CC_ASSERT(callbackId >= 0 && callbackId < billingClient->_inappListeners.size()); - auto* inAppMessageResult = cc::GoogleBillingToNative::toInAppMessageResult(env, inAppMessageResultObj); + auto* inAppMessageResult = cc::JniBilling::toInAppMessageResult(env, inAppMessageResultObj); cc::callJSfunc(billingClient->_inappListeners[callbackId], "onInAppMessageResponse", inAppMessageResult); } } diff --git a/native/vendor/google/billing/GoogleBillingHelper.h b/native/vendor/google/billing/GoogleBillingHelper.h index 8771dc02327..a43e6f261f8 100644 --- a/native/vendor/google/billing/GoogleBillingHelper.h +++ b/native/vendor/google/billing/GoogleBillingHelper.h @@ -29,7 +29,7 @@ #include #include "base/Macros.h" - +#include "vendor/google/billing/GoogleBilling.h" namespace cc { class BillingResult; class ProductDetails; @@ -51,7 +51,7 @@ class AcknowledgePurchaseParams; class CC_DLL GoogleBillingHelper { public: - static int createBillingClient(void* builder); + static int createBillingClient(BillingClient::Builder* builder); static void removeBillingClient(int tag); static void removeProductDetails(int tag, int productDetailsID); static void removePurchase(int tag, int purchaseID); diff --git a/native/vendor/google/billing/GoogleBillingToNative.cpp b/native/vendor/google/billing/JniBilling.cpp similarity index 81% rename from native/vendor/google/billing/GoogleBillingToNative.cpp rename to native/vendor/google/billing/JniBilling.cpp index e779d74035d..e0036c7e97e 100644 --- a/native/vendor/google/billing/GoogleBillingToNative.cpp +++ b/native/vendor/google/billing/JniBilling.cpp @@ -21,7 +21,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ -#include "vendor/google/billing/GoogleBillingToNative.h" +#include "vendor/google/billing/JniBilling.h" #include "platform/java/jni/JniHelper.h" @@ -34,6 +34,8 @@ #include "cocos/bindings/manual/jsb_conversions.h" #include "cocos/bindings/manual/jsb_global_init.h" #include "vendor/google/billing/GoogleBilling.h" +#include "vendor/google/billing/build-params/PendingPurchasesParams.h" + namespace { #ifndef JCLS_BILLING @@ -74,7 +76,7 @@ long callLongMethod(JNIEnv* env, jclass clazz, jobject obj, const char* methodNa } // namespace -cc::BillingResult* GoogleBillingToNative::toBillingResult(JNIEnv* env, jobject obj) { +cc::BillingResult* JniBilling::toBillingResult(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* billingResult = ccnew cc::BillingResult; billingResult->_debugMessage = callStringMethod(env, clazz, obj, "getDebugMessage"); @@ -83,7 +85,7 @@ cc::BillingResult* GoogleBillingToNative::toBillingResult(JNIEnv* env, jobject o return billingResult; } -cc::ProductDetails::OneTimePurchaseOfferDetails* GoogleBillingToNative::toOneTimePurchaseOfferDetails(JNIEnv* env, jobject obj) { +cc::ProductDetails::OneTimePurchaseOfferDetails* JniBilling::toOneTimePurchaseOfferDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto oneTimePurchaseOfferDetails = new cc::ProductDetails::OneTimePurchaseOfferDetails; oneTimePurchaseOfferDetails->_formattedPrice = callStringMethod(env, clazz, obj, "getFormattedPrice"); @@ -92,7 +94,7 @@ cc::ProductDetails::OneTimePurchaseOfferDetails* GoogleBillingToNative::toOneTim return oneTimePurchaseOfferDetails; } -cc::ProductDetails::InstallmentPlanDetails* GoogleBillingToNative::toInstallmentPlanDetails(JNIEnv* env, jobject obj) { +cc::ProductDetails::InstallmentPlanDetails* JniBilling::toInstallmentPlanDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* installmentPlanDetails = new cc::ProductDetails::InstallmentPlanDetails; installmentPlanDetails->_commitmentPaymentsCount = callIntMethod(env, clazz, obj, "getInstallmentPlanCommitmentPaymentsCount"); @@ -100,7 +102,7 @@ cc::ProductDetails::InstallmentPlanDetails* GoogleBillingToNative::toInstallment return installmentPlanDetails; } -cc::ProductDetails::PricingPhase* GoogleBillingToNative::toPricingPhase(JNIEnv* env, jobject obj) { +cc::ProductDetails::PricingPhase* JniBilling::toPricingPhase(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* pricingPhase = new cc::ProductDetails::PricingPhase; @@ -113,7 +115,7 @@ cc::ProductDetails::PricingPhase* GoogleBillingToNative::toPricingPhase(JNIEnv* return pricingPhase; } -cc::ProductDetails::PricingPhases* GoogleBillingToNative::toPricingPhases(JNIEnv* env, jobject obj) { +cc::ProductDetails::PricingPhases* JniBilling::toPricingPhases(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* pricingPhases = new cc::ProductDetails::PricingPhases; @@ -130,7 +132,7 @@ cc::ProductDetails::PricingPhases* GoogleBillingToNative::toPricingPhases(JNIEnv return pricingPhases; } -cc::ProductDetails::SubscriptionOfferDetails* GoogleBillingToNative::toSubscriptionOfferDetails(JNIEnv* env, jobject obj) { +cc::ProductDetails::SubscriptionOfferDetails* JniBilling::toSubscriptionOfferDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* details = ccnew cc::ProductDetails::SubscriptionOfferDetails; details->_basePlanId = callStringMethod(env, clazz, obj, @@ -158,21 +160,21 @@ cc::ProductDetails::SubscriptionOfferDetails* GoogleBillingToNative::toSubscript return details; } -std::vector GoogleBillingToNative::toProductDetailList(JNIEnv* env, jobject productListObj, jint startID) { +std::vector JniBilling::toProductDetailList(JNIEnv* env, jobject productListObj, jint startID) { jclass clazz = env->GetObjectClass(productListObj); jmethodID listGetMethod = env->GetMethodID(clazz, "get", "(I)Ljava/lang/Object;"); int size = callIntMethod(env, clazz, productListObj, "size"); std::vector productDetailsList; for (int i = 0; i < size; ++i) { jobject productDetailObj = env->CallObjectMethod(productListObj, listGetMethod, i); - cc::ProductDetails* productDetails = cc::GoogleBillingToNative::toProductDetail(env, productDetailObj); + cc::ProductDetails* productDetails = cc::JniBilling::toProductDetail(env, productDetailObj); productDetails->_id = startID++; productDetailsList.push_back(productDetails); } return std::move(productDetailsList); } -cc::ProductDetails* GoogleBillingToNative::toProductDetail(JNIEnv* env, jobject productObj) { +cc::ProductDetails* JniBilling::toProductDetail(JNIEnv* env, jobject productObj) { jclass clazz = env->GetObjectClass(productObj); auto* productDetails = new cc::ProductDetails; @@ -207,7 +209,7 @@ cc::ProductDetails* GoogleBillingToNative::toProductDetail(JNIEnv* env, jobject return productDetails; } -cc::AccountIdentifiers* GoogleBillingToNative::toAccountIdentifiers(JNIEnv* env, jobject obj) { +cc::AccountIdentifiers* JniBilling::toAccountIdentifiers(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* accountIdentifiers = new cc::AccountIdentifiers; accountIdentifiers->_obfuscatedAccountId = callStringMethod(env, clazz, obj, "getObfuscatedAccountId"); @@ -215,7 +217,7 @@ cc::AccountIdentifiers* GoogleBillingToNative::toAccountIdentifiers(JNIEnv* env, return accountIdentifiers; } -cc::Purchase::PendingPurchaseUpdate* GoogleBillingToNative::toPendingPurchaseUpdate(JNIEnv* env, jobject obj) { +cc::Purchase::PendingPurchaseUpdate* JniBilling::toPendingPurchaseUpdate(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* pendingPurchaseUpdate = new cc::Purchase::PendingPurchaseUpdate; jmethodID methodId = env->GetMethodID(clazz, "getProducts", "()Ljava/util/List;"); @@ -231,21 +233,21 @@ cc::Purchase::PendingPurchaseUpdate* GoogleBillingToNative::toPendingPurchaseUpd return pendingPurchaseUpdate; } -std::vector GoogleBillingToNative::toPurchaseList(JNIEnv* env, jobject productsListObj, jint startID) { +std::vector JniBilling::toPurchaseList(JNIEnv* env, jobject productsListObj, jint startID) { jclass clazz = env->GetObjectClass(productsListObj); jmethodID listGetMethod = env->GetMethodID(clazz, "get", "(I)Ljava/lang/Object;"); int size = callIntMethod(env, clazz, productsListObj, "size"); std::vector purchases; for (int i = 0; i < size; ++i) { jobject purchaseObj = env->CallObjectMethod(productsListObj, listGetMethod, i); - cc::Purchase* purchase = cc::GoogleBillingToNative::toPurchase(env, purchaseObj); + cc::Purchase* purchase = cc::JniBilling::toPurchase(env, purchaseObj); purchase->_id = startID++; purchases.push_back(purchase); } return std::move(purchases); } -cc::Purchase* GoogleBillingToNative::toPurchase(JNIEnv* env, jobject purchaseObj) { +cc::Purchase* JniBilling::toPurchase(JNIEnv* env, jobject purchaseObj) { jclass clazz = env->GetObjectClass(purchaseObj); auto* purchase = new cc::Purchase; @@ -288,28 +290,28 @@ cc::Purchase* GoogleBillingToNative::toPurchase(JNIEnv* env, jobject purchaseObj return purchase; } -cc::BillingConfig* GoogleBillingToNative::toBillingConfig(JNIEnv* env, jobject obj) { +cc::BillingConfig* JniBilling::toBillingConfig(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* billingConfig = new cc::BillingConfig(""); billingConfig->_countryCode = callStringMethod(env, clazz, obj, "getCountryCode"); return billingConfig; } -cc::AlternativeBillingOnlyReportingDetails* GoogleBillingToNative::toAlternativeBillingOnlyReportingDetails(JNIEnv* env, jobject obj) { +cc::AlternativeBillingOnlyReportingDetails* JniBilling::toAlternativeBillingOnlyReportingDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* alternativeBillingOnlyReportingDetails = new cc::AlternativeBillingOnlyReportingDetails; alternativeBillingOnlyReportingDetails->_externalTransactionToken = callStringMethod(env, clazz, obj, "getExternalTransactionToken"); return alternativeBillingOnlyReportingDetails; } -cc::ExternalOfferReportingDetails* GoogleBillingToNative::toExternalOfferReportingDetails(JNIEnv* env, jobject obj) { +cc::ExternalOfferReportingDetails* JniBilling::toExternalOfferReportingDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* externalOfferReportingDetails = new cc::ExternalOfferReportingDetails; externalOfferReportingDetails->_externalTransactionToken = callStringMethod(env, clazz, obj, "getExternalTransactionToken"); return externalOfferReportingDetails; } -cc::InAppMessageResult* GoogleBillingToNative::toInAppMessageResult(JNIEnv* env, jobject obj) { +cc::InAppMessageResult* JniBilling::toInAppMessageResult(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* inAppMessageResult = new cc::InAppMessageResult(0, ""); inAppMessageResult->_responseCode = callIntMethod(env, clazz, obj, "getResponseCode"); @@ -317,7 +319,7 @@ cc::InAppMessageResult* GoogleBillingToNative::toInAppMessageResult(JNIEnv* env, return inAppMessageResult; } -cc::UserChoiceDetails::Product* GoogleBillingToNative::toUserChoiceDetailsProduct(JNIEnv* env, jobject obj) { +cc::UserChoiceDetails::Product* JniBilling::toUserChoiceDetailsProduct(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* product = new cc::UserChoiceDetails::Product(); product->_hashCode = callIntMethod(env, clazz, obj, "hashCode"); @@ -328,7 +330,7 @@ cc::UserChoiceDetails::Product* GoogleBillingToNative::toUserChoiceDetailsProduc return product; } -cc::UserChoiceDetails* GoogleBillingToNative::toUserChoiceDetails(JNIEnv* env, jobject obj) { +cc::UserChoiceDetails* JniBilling::toUserChoiceDetails(JNIEnv* env, jobject obj) { jclass clazz = env->GetObjectClass(obj); auto* userChoiceDetails = new cc::UserChoiceDetails(); userChoiceDetails->_externalTransactionToken = callStringMethod(env, clazz, obj, "getExternalTransactionToken"); @@ -347,17 +349,17 @@ cc::UserChoiceDetails* GoogleBillingToNative::toUserChoiceDetails(JNIEnv* env, j return userChoiceDetails; } -BillingResult* GoogleBillingToNative::callFunctionAndReturnBillingResult(const std::string& functionName, int tag, int callbackId) { +BillingResult* JniBilling::callFunctionAndReturnBillingResult(const std::string& functionName, int tag, int callbackId) { auto* env = JniHelper::getEnv(); cc::JniMethodInfo t; if (cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, functionName.c_str(), "(II)Lcom/android/billingclient/api/BillingResult;")) { jobject obj = t.env->CallStaticObjectMethod(t.classID, t.methodID, tag, callbackId); - return cc::GoogleBillingToNative::toBillingResult(env, obj); + return cc::JniBilling::toBillingResult(env, obj); } return nullptr; } -jobject GoogleBillingToNative::newSubscriptionUpdateParamsObject(BillingFlowParams::SubscriptionUpdateParams* params) { +jobject JniBilling::newSubscriptionUpdateParamsObject(BillingFlowParams::SubscriptionUpdateParams* params) { if(!params) { return nullptr; } @@ -380,7 +382,7 @@ jobject GoogleBillingToNative::newSubscriptionUpdateParamsObject(BillingFlowPara return env->CallObjectMethod(builder, buildMethodIdMethodId); } -jobject GoogleBillingToNative::newProductDetailsParamsObject(BillingFlowParams::ProductDetailsParams* params) { +jobject JniBilling::newProductDetailsParamsObject(BillingFlowParams::ProductDetailsParams* params) { auto* env = JniHelper::getEnv(); cc::JniMethodInfo t; cc::JniHelper::getStaticMethodInfo(t, "com/android/billingclient/api/BillingFlowParams$ProductDetailsParams", "newBuilder", "()Lcom/android/billingclient/api/BillingFlowParams$ProductDetailsParams$Builder;"); @@ -402,7 +404,7 @@ jobject GoogleBillingToNative::newProductDetailsParamsObject(BillingFlowParams:: return env->CallObjectMethod(builder, buildMethodId); } -jobject GoogleBillingToNative::newProductDetailsParamsListObject(std::vector listParams) { +jobject JniBilling::newProductDetailsParamsListObject(std::vector listParams) { JNIEnv *env = cc::JniHelper::getEnv(); jclass listClass = env->FindClass("java/util/ArrayList"); jmethodID methodInit = env->GetMethodID(listClass, "", "()V"); /* 无参构造 */ @@ -414,7 +416,37 @@ jobject GoogleBillingToNative::newProductDetailsParamsListObject(std::vectorCallStaticObjectMethod(t.classID, t.methodID); + jclass builderClass = env->GetObjectClass(builder); + + jmethodID setIsOfferPersonalizedMethodId = env->GetMethodID(builderClass, "setIsOfferPersonalized", "(Z)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); + env->CallObjectMethod(builder, setIsOfferPersonalizedMethodId, params->_isOfferPersonalized); + + jmethodID setObfuscatedAccountIdMethodId = env->GetMethodID(builderClass, "setObfuscatedAccountId", "(Ljava/lang/String;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); + env->CallObjectMethod(builder, setObfuscatedAccountIdMethodId, cc::StringUtils::newStringUTFJNI(env, params->_obfuscatedAccountid)); + + jmethodID setObfuscatedProfileIdMethodId = env->GetMethodID(builderClass, "setObfuscatedProfileId", "(Ljava/lang/String;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); + env->CallObjectMethod(builder, setObfuscatedProfileIdMethodId, cc::StringUtils::newStringUTFJNI(env, params->_obfuscatedProfileId)); + + jobject listObjs = JniBilling::newProductDetailsParamsListObject(params->_productDetailsParamsList); + jmethodID setProductDetailsParamsListMethodId = env->GetMethodID(builderClass, "setProductDetailsParamsList", "(Ljava/util/List;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); + env->CallObjectMethod(builder, setProductDetailsParamsListMethodId, listObjs); + + if(params->_subscriptionUpdateParams) { + jobject subscriptionOfferDetailsObj = JniBilling::newSubscriptionUpdateParamsObject(params->_subscriptionUpdateParams); + jmethodID setSubscriptionUpdateParamsMethodId = env->GetMethodID(builderClass, "setSubscriptionUpdateParams", "(Lcom/android/billingclient/api/BillingFlowParams$SubscriptionUpdateParams;)Lcom/android/billingclient/api/BillingFlowParams$Builder;"); + env->CallObjectMethod(builder, setSubscriptionUpdateParamsMethodId, subscriptionOfferDetailsObj); + } + + jmethodID buildMethodId = env->GetMethodID(builderClass, "build", "()Lcom/android/billingclient/api/BillingFlowParams;"); + return env->CallObjectMethod(builder, buildMethodId); + } + +jobject JniBilling::newPendingPurchasesParamsObject(PendingPurchasesParams* params) { auto* env = JniHelper::getEnv(); cc::JniMethodInfo t; cc::JniHelper::getStaticMethodInfo(t, "com/android/billingclient/api/PendingPurchasesParams", "newBuilder", "()Lcom/android/billingclient/api/PendingPurchasesParams$Builder;"); @@ -434,7 +466,7 @@ jobject GoogleBillingToNative::newPendingPurchasesParamsObject(PendingPurchasesP return env->CallObjectMethod(builder, buildMethodId); } -jobject GoogleBillingToNative::newCustomListenerObject(int tag, const std::string& functionName) { +jobject JniBilling::newCustomListenerObject(int tag, const std::string& functionName) { auto* env = JniHelper::getEnv(); std::string listener = std::string(JCLS_BILLING) + "$" + functionName; @@ -444,16 +476,15 @@ jobject GoogleBillingToNative::newCustomListenerObject(int tag, const std::strin return t.env->NewObject(t.classID, t.methodID, tag); } -jobject GoogleBillingToNative::newPurchaseUpdateListenerObject(int tag) { +jobject JniBilling::newPurchaseUpdateListenerObject(int tag) { return newCustomListenerObject(tag, "BillingClientPurchasesUpdatedListener"); } -jobject GoogleBillingToNative::newUserChoiceBillingListenerObj(int tag) { +jobject JniBilling::newUserChoiceBillingListenerObj(int tag) { return newCustomListenerObject(tag, "BillingClientUserChoiceBillingListener"); } - -jobject GoogleBillingToNative::newBillingClientBuilderObject(int tag, BillingClient::Builder* params) { +jobject JniBilling::newBillingClientBuilderObject(int tag, BillingClient::Builder* params) { auto* env = JniHelper::getEnv(); cc::JniMethodInfo t; auto *javaGameActivity = cc::JniHelper::getActivity(); @@ -478,13 +509,13 @@ jobject GoogleBillingToNative::newBillingClientBuilderObject(int tag, BillingCli env->CallObjectMethod(builder, methodId, pendingPurchasesParamsObj); } - if(params->purchasesUpdatedListener) { + if(params->_purchasesUpdatedListener) { jobject listenerObj = newPurchaseUpdateListenerObject(tag); jmethodID methodId = env->GetMethodID(builderClass, "setListener", "(Lcom/android/billingclient/api/PurchasesUpdatedListener;)Lcom/android/billingclient/api/BillingClient$Builder;"); env->CallObjectMethod(builder, methodId, listenerObj); } - if(params->userChoiceBillingListener) { + if(params->_userChoiceBillingListener) { jobject userChoiceBillingListenerObj = newUserChoiceBillingListenerObj(tag); jmethodID methodId = env->GetMethodID(builderClass, "enableUserChoiceBilling", "(Lcom/android/billingclient/api/UserChoiceBillingListener;)Lcom/android/billingclient/api/BillingClient$Builder;"); env->CallObjectMethod(builder, methodId, userChoiceBillingListenerObj); diff --git a/native/vendor/google/billing/GoogleBillingToNative.h b/native/vendor/google/billing/JniBilling.h similarity index 83% rename from native/vendor/google/billing/GoogleBillingToNative.h rename to native/vendor/google/billing/JniBilling.h index 6f1ff36b0b6..4c294c85d13 100644 --- a/native/vendor/google/billing/GoogleBillingToNative.h +++ b/native/vendor/google/billing/JniBilling.h @@ -30,9 +30,20 @@ #include "base/Macros.h" #include "vendor/google/billing/GoogleBilling.h" +#include "vendor/google/billing/result-values/AccountIdentifiers.h" +#include "vendor/google/billing/result-values/AlternativeBillingOnlyReportingDetails.h" +#include "vendor/google/billing/result-values/BillingConfig.h" +#include "vendor/google/billing/result-values/BillingResult.h" +#include "vendor/google/billing/result-values/ExternalOfferReportingDetails.h" +#include "vendor/google/billing/result-values/InAppMessageResult.h" +#include "vendor/google/billing/result-values/Purchase.h" +#include "vendor/google/billing/result-values/ProductDetails.h" +#include "vendor/google/billing/result-values/UserChoiceDetails.h" +#include "vendor/google/billing/build-params/BillingFlowParams.h" + namespace cc { -class CC_DLL GoogleBillingToNative { +class CC_DLL JniBilling { public: static BillingResult *toBillingResult(JNIEnv *env, jobject obj); static std::vector toProductDetailList(JNIEnv *env, jobject productsObj, jint startID); @@ -51,17 +62,21 @@ class CC_DLL GoogleBillingToNative { static ProductDetails::PricingPhase *toPricingPhase(JNIEnv *env, jobject obj); static ProductDetails::PricingPhases *toPricingPhases(JNIEnv* env, jobject obj); static BillingResult *callFunctionAndReturnBillingResult(const std::string &functionName, int tag, int callbackId); + + static UserChoiceDetails::Product* toUserChoiceDetailsProduct(JNIEnv* env, jobject obj); + static UserChoiceDetails* toUserChoiceDetails(JNIEnv* env, jobject obj); + + + static jobject newBillingFlowParamsObject(BillingFlowParams* params); + static jobject newBillingClientBuilderObject(int tag, BillingClient::Builder* params); +private: static jobject newSubscriptionUpdateParamsObject(BillingFlowParams::SubscriptionUpdateParams* params); static jobject newProductDetailsParamsObject(BillingFlowParams::ProductDetailsParams* params); static jobject newProductDetailsParamsListObject(std::vector listParams); - static UserChoiceDetails::Product* toUserChoiceDetailsProduct(JNIEnv* env, jobject obj); - static UserChoiceDetails* toUserChoiceDetails(JNIEnv* env, jobject obj); - + static jobject newPurchaseUpdateListenerObject(int tag); static jobject newUserChoiceBillingListenerObj(int tag); static jobject newPendingPurchasesParamsObject(PendingPurchasesParams* params); - static jobject newBillingClientBuilderObject(int tag, BillingClient::Builder* params); -private: static jobject newCustomListenerObject(int tag, const std::string& functionName); }; diff --git a/native/vendor/google/billing/build-params/AcknowledgePurchaseParams.h b/native/vendor/google/billing/build-params/AcknowledgePurchaseParams.h new file mode 100644 index 00000000000..aeb50e761d9 --- /dev/null +++ b/native/vendor/google/billing/build-params/AcknowledgePurchaseParams.h @@ -0,0 +1,67 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { +class AcknowledgePurchaseParams { +public: + class Builder { + public: + Builder& setPurchaseToken(const std::string& purchaseToken) { + this->_purchaseToken = purchaseToken; + return *this; + } + + AcknowledgePurchaseParams* build() { + return new AcknowledgePurchaseParams(this->_purchaseToken); + } + + private: + std::string _purchaseToken; + }; + + std::string getPurchaseToken() const { + return _purchaseToken; + } + + static Builder* newBuilder() { + return new Builder(); + } + +private: + AcknowledgePurchaseParams(const std::string& purchaseToken) { + this->_purchaseToken = purchaseToken; + } + + std::string _purchaseToken; +}; + + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/BillingFlowParams.h b/native/vendor/google/billing/build-params/BillingFlowParams.h new file mode 100644 index 00000000000..159364eb7d8 --- /dev/null +++ b/native/vendor/google/billing/build-params/BillingFlowParams.h @@ -0,0 +1,171 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" +#include "vendor/google/billing/result-values/ProductDetails.h" + +namespace cc { +class CC_DLL BillingFlowParams { +public: + class SubscriptionUpdateParams { + public: + class Builder { + public: + Builder& setOldPurcchaseToken(const std::string& purchaseToken) { + this->_purchaseToken = purchaseToken; + return *this; + } + Builder& setOriginalExternalTransactionId(const std::string& externalTransactionId) { + this->_externalTransactionId = externalTransactionId; + return *this; + } + Builder& setSubscriptionReplacementMode(int subscriptionReplacementMode) { + this->_subscriptionReplacementMode = subscriptionReplacementMode; + return *this; + } + SubscriptionUpdateParams* build() { + return new SubscriptionUpdateParams(_subscriptionReplacementMode, _purchaseToken, _externalTransactionId); + } + + private: + int _subscriptionReplacementMode; + std::string _purchaseToken; + std::string _externalTransactionId; + }; + static Builder* newBuilder() { + return new Builder(); + } + + private: + SubscriptionUpdateParams(int subscriptionReplacementMode, const std::string& purchaseToken, const std::string& externalTransactionId) { + this->_subscriptionReplacementMode = subscriptionReplacementMode; + this->_purchaseToken = purchaseToken; + this->_externalTransactionId = externalTransactionId; + } + friend class JniBilling; + int _subscriptionReplacementMode; + std::string _purchaseToken; + std::string _externalTransactionId; + }; + + class ProductDetailsParams { + public: + class Builder { + public: + Builder& setOfferToken(const std::string& offerToken) { + this->_offerToken = offerToken; + return *this; + } + Builder& setProductDetails(ProductDetails* productDetails) { + this->_productDetails = productDetails; + return *this; + } + ProductDetailsParams* build() { + return new ProductDetailsParams(_offerToken, _productDetails); + } + + private: + std::string _offerToken; + ProductDetails* _productDetails; + }; + static Builder* newBuilder() { + return new Builder(); + } + + private: + friend class JniBilling; + ProductDetailsParams(std::string offerToken, ProductDetails* _productDetails) { + this->_offerToken = offerToken; + this->_productDetails = _productDetails; + } + + std::string _offerToken; + ProductDetails* _productDetails{nullptr}; + }; + + class Builder { + public: + Builder& setIsOfferPersonalized(bool isOfferPersonalized) { + this->_isOfferPersonalized = isOfferPersonalized; + return *this; + } + Builder& setObfuscatedAccountId(const std::string& obfuscatedAccountid) { + this->_obfuscatedAccountid = obfuscatedAccountid; + return *this; + } + Builder& setObfuscatedProfileId(const std::string& obfuscatedProfileId) { + this->_obfuscatedProfileId = obfuscatedProfileId; + return *this; + } + Builder& setProductDetailsParamsList(const std::vector& productDetailsParamsList) { + this->_productDetailsParamsList = productDetailsParamsList; + return *this; + } + Builder& setSubscriptionUpdateParams(SubscriptionUpdateParams* subscriptionUpdateParams) { + this->_subscriptionUpdateParams = subscriptionUpdateParams; + return *this; + } + BillingFlowParams* build() { + return new BillingFlowParams(_isOfferPersonalized, _obfuscatedAccountid, _obfuscatedProfileId, _productDetailsParamsList, _subscriptionUpdateParams); + } + + private: + friend class JniBilling; + bool _isOfferPersonalized{false}; + std::string _obfuscatedAccountid; + std::string _obfuscatedProfileId; + std::vector _productDetailsParamsList; + SubscriptionUpdateParams* _subscriptionUpdateParams{nullptr}; + }; + static Builder* newBuilder() { + return new Builder(); + } + +private: + friend class GoogleBillingHelper; + friend class JniBilling; + BillingFlowParams(bool isOfferPersonalized, + const std::string& obfuscatedAccountid, + const std::string& obfuscatedProfileId, + const std::vector& productDetailsParamsList, + SubscriptionUpdateParams* subscriptionUpdateParams) { + _isOfferPersonalized = isOfferPersonalized; + _obfuscatedAccountid = obfuscatedAccountid; + _obfuscatedProfileId = obfuscatedProfileId; + _productDetailsParamsList = productDetailsParamsList; + _subscriptionUpdateParams = subscriptionUpdateParams; + } + bool _isOfferPersonalized{false}; + std::string _obfuscatedAccountid; + std::string _obfuscatedProfileId; + std::vector _productDetailsParamsList; + SubscriptionUpdateParams* _subscriptionUpdateParams{nullptr}; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/ConsumeParams.h b/native/vendor/google/billing/build-params/ConsumeParams.h new file mode 100644 index 00000000000..345ba597dd6 --- /dev/null +++ b/native/vendor/google/billing/build-params/ConsumeParams.h @@ -0,0 +1,67 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class ConsumeParams { +public: + class Builder { + public: + Builder& setPurchaseToken(const std::string& purchaseToken) { + this->_purchaseToken = purchaseToken; + return *this; + } + + ConsumeParams* build() { + return new ConsumeParams(this->_purchaseToken); + } + + private: + std::string _purchaseToken; + }; + + std::string getPurchaseToken() const { + return _purchaseToken; + } + + static Builder* newBuilder() { + return new Builder(); + } + +private: + ConsumeParams(const std::string& purchaseToken) { + this->_purchaseToken = purchaseToken; + } + + std::string _purchaseToken; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/GetBillingConfigParams.h b/native/vendor/google/billing/build-params/GetBillingConfigParams.h new file mode 100644 index 00000000000..820bd68e0f6 --- /dev/null +++ b/native/vendor/google/billing/build-params/GetBillingConfigParams.h @@ -0,0 +1,54 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class GetBillingConfigParams { +public: + class Builder { + public: + GetBillingConfigParams* build() { + return new GetBillingConfigParams(); + } + }; + + static Builder* newBuilder() { + return new Builder(); + } + +private: + GetBillingConfigParams() { + } +}; + + + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/InAppMessageParams.h b/native/vendor/google/billing/build-params/InAppMessageParams.h new file mode 100644 index 00000000000..107778d263f --- /dev/null +++ b/native/vendor/google/billing/build-params/InAppMessageParams.h @@ -0,0 +1,68 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class InAppMessageParams { +public: + class Builder { + public: + Builder& addAllInAppMessageCategoriesToShow() { + this->_inAppMessageCategoryIds.push_back(2); + return *this; + } + + Builder& addInAppMessageCategoryToShow(int inAppMessageCategoryId) { + this->_inAppMessageCategoryIds.push_back(inAppMessageCategoryId); + return *this; + } + + InAppMessageParams* build() { + return new InAppMessageParams(this->_inAppMessageCategoryIds); + } + + private: + std::vector _inAppMessageCategoryIds; + }; + + static Builder* newBuilder() { + return new Builder(); + } + +private: + InAppMessageParams(const std::vector& inAppMessageCategoryIds) { + this->_inAppMessageCategoryIds = inAppMessageCategoryIds; + } + friend class BillingClient; + std::vector _inAppMessageCategoryIds; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/PendingPurchasesParams.h b/native/vendor/google/billing/build-params/PendingPurchasesParams.h new file mode 100644 index 00000000000..d8c077f0dad --- /dev/null +++ b/native/vendor/google/billing/build-params/PendingPurchasesParams.h @@ -0,0 +1,75 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class PendingPurchasesParams { +public: + class Builder { + private: + bool _enableOneTimeProducts; + bool _enablePrepaidPlans; + + public: + Builder& enableOneTimeProducts() { + this->_enableOneTimeProducts = true; + return *this; + } + Builder& enablePrepaidPlans() { + this->_enablePrepaidPlans = true; + return *this; + } + PendingPurchasesParams* build() { + if (!this->_enableOneTimeProducts) { + return nullptr; + } + return new PendingPurchasesParams(this->_enableOneTimeProducts, this->_enablePrepaidPlans); + } + }; + + static Builder* newBuilder() { + return new Builder(); + } + +private: + PendingPurchasesParams(bool enableOneTimeProducts, bool enablePrepaidPlans) { + this->_enableOneTimeProducts = enableOneTimeProducts; + this->_enablePrepaidPlans = enablePrepaidPlans; + } + +private: + friend class JniBilling; + friend class BillingClient; + bool _enableOneTimeProducts{false}; + bool _enablePrepaidPlans{false}; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/QueryProductDetailsParams.h b/native/vendor/google/billing/build-params/QueryProductDetailsParams.h new file mode 100644 index 00000000000..430ecdd9cee --- /dev/null +++ b/native/vendor/google/billing/build-params/QueryProductDetailsParams.h @@ -0,0 +1,106 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { +class QueryProductDetailsParams { +public: + class Product { + public: + class Builder { + private: + std::string _productID; + std::string _productType; + + public: + Builder& setProductId(const std::string& productID) { + this->_productID = productID; + return *this; + } + Builder& setProductType(const std::string& productType) { + this->_productType = productType; + return *this; + } + Product* build() { + if (_productID.empty()) { + } else if (_productType.empty()) { + } + return new Product(_productID, _productType); + } + }; + + static Builder* newBuilder() { + return new Builder(); + } + + private: + Product(const std::string& productID, const std::string& productType) { + this->_productID = productID; + this->_productType = productType; + } + + private: + friend class BillingClient; + std::string _productID; + std::string _productType; + }; + class Builder { + private: + std::vector _productList; + + public: + Builder& setProductList(const std::vector& productList) { + _productList = productList; + return *this; + } + + QueryProductDetailsParams* build() { + if (this->_productList.empty()) { + return nullptr; + } + return new QueryProductDetailsParams(this->_productList); + } + }; + + static Builder* newBuilder() { + return new Builder(); + } + +private: + QueryProductDetailsParams(const std::vector& productLists) { + _productList = productLists; + } + +private: + friend class BillingClient; + std::vector _productList; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/build-params/QueryPurchasesParams.h b/native/vendor/google/billing/build-params/QueryPurchasesParams.h new file mode 100644 index 00000000000..0e755db826b --- /dev/null +++ b/native/vendor/google/billing/build-params/QueryPurchasesParams.h @@ -0,0 +1,63 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class QueryPurchasesParams { +public: + class Builder { + public: + Builder& setProductType(const std::string& productType) { + this->_productType = productType; + return *this; + } + + QueryPurchasesParams* build() { + return new QueryPurchasesParams(this->_productType); + } + + private: + std::string _productType; + }; + + static Builder* newBuilder() { + return new Builder(); + } + +private: + QueryPurchasesParams(const std::string& productType) { + this->_productType = productType; + } + friend class BillingClient; + std::string _productType; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/AccountIdentifiers.h b/native/vendor/google/billing/result-values/AccountIdentifiers.h new file mode 100644 index 00000000000..ede7e45f73b --- /dev/null +++ b/native/vendor/google/billing/result-values/AccountIdentifiers.h @@ -0,0 +1,51 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class CC_DLL AccountIdentifiers { +public: + std::string getObfuscatedAccountId() const { + return this->_obfuscatedAccountId; + } + + std::string getObfuscatedProfileId() const { + return this->_obfuscatedProfileId; + } + +private: + friend class JniBilling; + friend class Purchase; + std::string _obfuscatedAccountId; + std::string _obfuscatedProfileId; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/AlternativeBillingOnlyReportingDetails.h b/native/vendor/google/billing/result-values/AlternativeBillingOnlyReportingDetails.h new file mode 100644 index 00000000000..584a995faa7 --- /dev/null +++ b/native/vendor/google/billing/result-values/AlternativeBillingOnlyReportingDetails.h @@ -0,0 +1,45 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class AlternativeBillingOnlyReportingDetails : public cc::RefCounted { +public: + std::string getExternalTransactionToken() const { + return this->_externalTransactionToken; + } + +private: + friend class JniBilling; + std::string _externalTransactionToken; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/BillingConfig.h b/native/vendor/google/billing/result-values/BillingConfig.h new file mode 100644 index 00000000000..f18747ed7e1 --- /dev/null +++ b/native/vendor/google/billing/result-values/BillingConfig.h @@ -0,0 +1,51 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class CC_DLL BillingConfig : public cc::RefCounted { +public: + std::string getCountryCode() const { + return this->_countryCode; + } + static BillingConfig* forCountryCode(const std::string countryCode) { + return new BillingConfig(countryCode); + } + +private: + friend class JniBilling; + BillingConfig(const std::string countryCode) { + this->_countryCode = countryCode; + } + std::string _countryCode; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/BillingResult.h b/native/vendor/google/billing/result-values/BillingResult.h new file mode 100644 index 00000000000..eec5197d7d5 --- /dev/null +++ b/native/vendor/google/billing/result-values/BillingResult.h @@ -0,0 +1,79 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { +class CC_DLL BillingResult : public cc::RefCounted { +public: + int getResponseCode() const { + return this->_responseCode; + } + + std::string getDebugMessage() const { + return this->_debugMessage; + } + + std::string toStr() const { + return this->_toString; + } + class Builder { + private: + int _responseCode{0}; + std::string _debugMessage; + std::string _toStr; + + public: + Builder& setDebugMessage(const std::string debugMsg) { + this->_debugMessage = debugMsg; + return *this; + } + Builder& setResponseCode(int responseCode) { + this->_responseCode = responseCode; + return *this; + } + BillingResult* build() { + auto* p = new BillingResult(); + p->_responseCode = _responseCode; + p->_debugMessage = _debugMessage; + return p; + } + }; + static Builder* newBuilder() { + return new Builder(); + } + +private: + friend class JniBilling; + int _responseCode{0}; + std::string _debugMessage; + std::string _toString; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/ExternalOfferReportingDetails.h b/native/vendor/google/billing/result-values/ExternalOfferReportingDetails.h new file mode 100644 index 00000000000..046d027cbb6 --- /dev/null +++ b/native/vendor/google/billing/result-values/ExternalOfferReportingDetails.h @@ -0,0 +1,46 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class ExternalOfferReportingDetails : public cc::RefCounted { +public: + std::string getExternalTransactionToken() const { + return this->_externalTransactionToken; + } + +private: + friend class JniBilling; + std::string _externalTransactionToken; +}; + + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/InAppMessageResult.h b/native/vendor/google/billing/result-values/InAppMessageResult.h new file mode 100644 index 00000000000..b1e50afece0 --- /dev/null +++ b/native/vendor/google/billing/result-values/InAppMessageResult.h @@ -0,0 +1,54 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class InAppMessageResult : public cc::RefCounted { +public: + int getResponseCode() const { + return this->_responseCode; + } + + std::string getPurchaseToken() const { + return this->_purchaseToken; + } + + InAppMessageResult(int responseCode, const std::string& purchaseToken) { + this->_responseCode = responseCode; + this->_purchaseToken = purchaseToken; + } + +private: + friend class JniBilling; + int _responseCode{0}; + std::string _purchaseToken; +}; +} // namespace cc diff --git a/native/vendor/google/billing/result-values/ProductDetails.cpp b/native/vendor/google/billing/result-values/ProductDetails.cpp new file mode 100644 index 00000000000..41757798e11 --- /dev/null +++ b/native/vendor/google/billing/result-values/ProductDetails.cpp @@ -0,0 +1,43 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#include +#include "vendor/google/billing/result-values/ProductDetails.h" +#include "vendor/google/billing/GoogleBillingHelper.h" + +namespace cc { + +ProductDetails::~ProductDetails() { + if (_oneTimePurchaseOfferDetails) { + delete _oneTimePurchaseOfferDetails; + _oneTimePurchaseOfferDetails = nullptr; + } + for (auto* ptr : _subscriptionOfferDetails) { + delete ptr; + } + _subscriptionOfferDetails.clear(); + GoogleBillingHelper::removeProductDetails(_tag, _id); +} + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/ProductDetails.h b/native/vendor/google/billing/result-values/ProductDetails.h new file mode 100644 index 00000000000..cec612b0d8f --- /dev/null +++ b/native/vendor/google/billing/result-values/ProductDetails.h @@ -0,0 +1,226 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { + +class CC_DLL ProductDetails : public cc::RefCounted { +public: + ~ProductDetails() override; + class OneTimePurchaseOfferDetails { + public: + long getPriceAmountMicros() const { + return this->_priceAmountMicros; + } + + std::string getFormattedPrice() const { + return this->_formattedPrice; + } + + std::string getPriceCurrencyCode() const { + return this->_priceCurrencyCode; + } + + private: + friend class JniBilling; + long _priceAmountMicros{0}; + std::string _formattedPrice; + std::string _priceCurrencyCode; + }; + + class InstallmentPlanDetails { + public: + int getInstallmentPlanCommitmentPaymentsCount() const { + return this->_commitmentPaymentsCount; + } + int getSubsequentInstallmentPlanCommitmentPaymentsCount() const { + return this->_subsequentCommitmentPaymentsCount; + } + + private: + friend class JniBilling; + int _commitmentPaymentsCount{0}; + int _subsequentCommitmentPaymentsCount{0}; + }; + + class PricingPhase { + public: + int getBillingCycleCount() const { + return this->_billingCycleCount; + } + + int getRecurrenceMode() const { + return this->_priceAmountMicros; + } + + long getPriceAmountMicros() const { + return this->_recurrenceMode; + } + + std::string getBillingPeriod() const { + return this->_billingPeriod; + } + std::string getFormattedPrice() const { + return this->_formattedPrice; + } + + std::string getPriceCurrencyCode() const { + return this->_priceCurrencyCode; + } + + private: + friend class JniBilling; + int _billingCycleCount{0}; + long _priceAmountMicros{0}; + int _recurrenceMode{0}; + std::string _billingPeriod; + std::string _formattedPrice; + std::string _priceCurrencyCode; + }; + + class PricingPhases { + public: + std::vector getPricingPhaseList() const { + return this->_pricingPhaseList; + } + ~PricingPhases() { + for (auto* pricingPhase : _pricingPhaseList) { + delete pricingPhase; + } + _pricingPhaseList.clear(); + } + + private: + friend class JniBilling; + std::vector _pricingPhaseList; + }; + class SubscriptionOfferDetails { + public: + ~SubscriptionOfferDetails() { + if (this->_pricingPhases != nullptr) { + delete this->_pricingPhases; + this->_pricingPhases = nullptr; + } + + if (this->_installmentPlanDetails != nullptr) { + delete this->_installmentPlanDetails; + this->_installmentPlanDetails = nullptr; + } + } + InstallmentPlanDetails* getInstallmentPlanDetails() const { + return this->_installmentPlanDetails; + } + + PricingPhases* getPricingPhases() const { + return this->_pricingPhases; + } + + std::string getBasePlanId() const { + return this->_basePlanId; + } + + std::string getOfferId() const { + return this->_offerId; + } + + std::string getOfferToken() const { + return this->_offerToken; + } + + std::vector getOfferTags() const { + return this->_offerTags; + } + + private: + friend class JniBilling; + std::string _basePlanId; + std::string _offerId; + std::string _offerToken; + std::vector _offerTags; + PricingPhases* _pricingPhases{nullptr}; + InstallmentPlanDetails* _installmentPlanDetails{nullptr}; + }; + int hashCode() const { + return this->_hashCode; + } + + OneTimePurchaseOfferDetails* getOneTimePurchaseOfferDetails() const { + return this->_oneTimePurchaseOfferDetails; + } + + std::string getDescription() const { + return this->_description; + } + + std::string getName() const { + return this->_name; + } + + std::string getProductId() const { + return this->_productId; + } + + std::string getProductType() const { + return this->_productType; + } + + std::string getTitle() const { + return this->_title; + } + + std::string toStr() const { + return this->_toString; + } + + bool equals(const ProductDetails& other) const { + return this->_hashCode == other._hashCode; + } + + std::vector getSubscriptionOfferDetails() const { + return this->_subscriptionOfferDetails; + } + +private: + friend class JniBilling; + friend class GoogleBillingHelper; + int _id{-1}; // This is an ID that is not visible to ts and is used to free the java object. + int _tag{-1}; // This is an ID that is not visible to ts and is used to specify which billingclient. + int _hashCode{0}; + std::string _description; + std::string _name; + std::string _productId; + std::string _productType; + std::string _title; + std::string _toString; + OneTimePurchaseOfferDetails* _oneTimePurchaseOfferDetails{nullptr}; + std::vector _subscriptionOfferDetails; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/GoogleBillingManager.cpp b/native/vendor/google/billing/result-values/Purchase.cpp similarity index 81% rename from native/vendor/google/billing/GoogleBillingManager.cpp rename to native/vendor/google/billing/result-values/Purchase.cpp index 15033eacaef..83d06995400 100644 --- a/native/vendor/google/billing/GoogleBillingManager.cpp +++ b/native/vendor/google/billing/result-values/Purchase.cpp @@ -21,3 +21,16 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ****************************************************************************/ + +#include + +#include "vendor/google/billing/result-values/Purchase.h" +#include "vendor/google/billing/GoogleBillingHelper.h" + +namespace cc { + +Purchase::~Purchase() { + GoogleBillingHelper::removePurchase(_tag, _id); +} + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/Purchase.h b/native/vendor/google/billing/result-values/Purchase.h new file mode 100644 index 00000000000..7f8cd6ff9ad --- /dev/null +++ b/native/vendor/google/billing/result-values/Purchase.h @@ -0,0 +1,141 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" +#include "vendor/google/billing/result-values/AccountIdentifiers.h" + +namespace cc { + +class CC_DLL Purchase : public cc::RefCounted { +public: + class CC_DLL PendingPurchaseUpdate { + public: + std::string getPurchaseToken() const { + return this->_purchaseToken; + } + + std::vector getProducts() const { + return this->_products; + } + + private: + friend class JniBilling; + std::string _purchaseToken; + std::vector _products; + }; + + int getPurchaseState() const { + return this->_purchaseState; + } + int getQuantity() const { + return this->_quantity; + } + + int hashCode() const { + return this->_hashCode; + } + + long getPurchaseTime() const { + return this->_purchaseTime; + } + + AccountIdentifiers* getAccountIdentifiers() const { + return this->_accountIdentifiers; + } + PendingPurchaseUpdate* getPendingPurchaseUpdate() const { + return this->_pendingPurchaseUpdate; + } + + std::string getDeveloperPayload() const { + return this->_developerPayload; + } + + std::string getOrderId() const { + return this->_orderId; + } + + std::string getOriginalJson() const { + return this->_originalJson; + } + + std::string getPackageName() const { + return this->_packageName; + } + + std::string getPurchaseToken() const { + return this->_purchaseToken; + } + + std::string getSignature() const { + return this->_signature; + } + + std::string toStr() const { + return this->_toString; + } + + std::vector getProducts() const { + return this->_products; + } + bool isAcknowledged() const { + return this->_isAcknowledged; + } + + bool isAutoRenewing() const { + return this->_isAutoRenewing; + } + ~Purchase() override; + bool equals(const Purchase& other) const { + return this->_hashCode == other._hashCode; + } + +private: + friend class JniBilling; + friend class GoogleBillingHelper; + int _id{-1}; // This is an ID that is not visible to ts and is used to free the java object. + int _tag{-1}; // This is an ID that is not visible to ts and is used to specify which billingclient. + bool _isAcknowledged{false}; + bool _isAutoRenewing{false}; + int _purchaseState{0}; + int _hashCode{0}; + int _quantity{0}; + long _purchaseTime{0}; + std::string _developerPayload; + std::string _orderId; + std::string _originalJson; + std::string _packageName; + std::string _purchaseToken; + std::string _signature; + std::string _toString; + AccountIdentifiers* _accountIdentifiers{nullptr}; + PendingPurchaseUpdate* _pendingPurchaseUpdate{nullptr}; + std::vector _products; +}; + +} // namespace cc diff --git a/native/vendor/google/billing/result-values/UserChoiceDetails.h b/native/vendor/google/billing/result-values/UserChoiceDetails.h new file mode 100644 index 00000000000..31d05d1055c --- /dev/null +++ b/native/vendor/google/billing/result-values/UserChoiceDetails.h @@ -0,0 +1,92 @@ +/**************************************************************************** + Copyright (c) 2024 Xiamen Yaji Software Co., Ltd. + + http://www.cocos.com + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do so, + subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +****************************************************************************/ + +#pragma once + +#include + +#include "base/Macros.h" +#include "base/RefCounted.h" + +namespace cc { +class UserChoiceDetails : public cc::RefCounted { +public: + class Product { + public: + int hashCode() const { + return _hashCode; + } + std::string getId() const { + return _id; + } + std::string getOfferToken() const { + return _type; + } + std::string getType() const { + return _offerToken; + } + std::string toStr() const { + return _toStr; + } + bool equals(const Product& p) { + if (&p == this) { + return true; + } + return p._id == _id && p._type == _type && p._offerToken == _offerToken; + } + + private: + friend class JniBilling; + int _hashCode{0}; + std::string _id; + std::string _type; + std::string _offerToken; + std::string _toStr; + }; + + ~UserChoiceDetails() { + for (auto* product : _products) { + delete product; + } + _products.clear(); + } + std::string getExternalTransactionToken() const { + return _externalTransactionToken; + } + std::string getOriginalExternalTransactionId() const { + return _originalExternalTransactionId; + } + + std::vector getProducts() { + return this->_products; + } + +private: + friend class JniBilling; + std::string _externalTransactionToken; + std::string _originalExternalTransactionId; + std::vector _products; +}; + +} // namespace cc diff --git a/vendor/google/billing/billing-enum.ts b/vendor/google/billing/billing-enum.ts index 9ae3f7244b2..7b6ad5fbedb 100644 --- a/vendor/google/billing/billing-enum.ts +++ b/vendor/google/billing/billing-enum.ts @@ -63,4 +63,36 @@ jsb.BillingClient.ProductType = { INAPP: 'inapp', SUBS: 'subs', }; + +jsb.InAppMessageParams.InAppMessageCategoryId = { + UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID: 0, + TRANSACTIONAL: 2, +}; + +jsb.InAppMessageResult.InAppMessageResponseCode = { + NO_ACTION_NEEDED: 0, + SUBSCRIPTION_STATUS_UPDATED: 1, +}; + +jsb.BillingFlowParams.SubscriptionUpdateParams.ReplacementMode = { + UNKNOWN_REPLACEMENT_MODE: 0, + WITH_TIME_PRORATION: 1, + CHARGE_PRORATED_PRICE: 2, + WITHOUT_PRORATION: 3, + CHARGE_FULL_PRICE: 5, + DEFERRED: 6, +}; + +jsb.ProductDetails.RecurrenceMode = { + INFINITE_RECURRING: 1, + FINITE_RECURRING: 2, + NON_RECURRING: 3, +}; + +jsb.Purchase.PurchaseState = { + PENDING: 2, + PURCHASED: 1, + UNSPECIFIED_STATE: 0, +}; + export {}; diff --git a/vendor/google/billing/billing.ts b/vendor/google/billing/billing.ts index d37b12fa4fc..6d604914a97 100644 --- a/vendor/google/billing/billing.ts +++ b/vendor/google/billing/billing.ts @@ -54,10 +54,10 @@ export declare namespace google { export type InstallmentPlanDetails = jsb.InstallmentPlanDetails; export type PricingPhase = jsb.PricingPhase; export type SubscriptionOfferDetails = jsb.SubscriptionOfferDetails; - export type ProductDetails = jsb.ProductDetails; + export type AccountIdentifiers = jsb.AccountIdentifiers; export type PendingPurchaseUpdate = jsb.PendingPurchaseUpdate; - export type Purchase = jsb.Purchase; + export type BillingConfig = jsb.BillingConfig; export type AlternativeBillingOnlyReportingDetails = jsb.AlternativeBillingOnlyReportingDetails; export type ExternalOfferReportingDetails = jsb.ExternalOfferReportingDetails; @@ -65,8 +65,16 @@ export declare namespace google { export type BillingResult = jsb.BillingResult; export type PendingPurchasesParams = jsb.PendingPurchasesParams; - export type QueryProductDetailsParams = jsb.QueryProductDetailsParams; - export type Product = jsb.Product; + + export namespace ProductDetails { + export type RecurrenceMode = jsb.RecurrenceMode; + } + export type ProductDetails = jsb.ProductDetails; + + export namespace Purchase { + export type PurchaseState = jsb.PurchaseState; + } + export type Purchase = jsb.Purchase; export type BillingClient = jsb.BillingClient; export namespace BillingFlowParams { @@ -74,8 +82,13 @@ export declare namespace google { export type SubscriptionUpdateParams = jsb.SubscriptionUpdateParams; export type ProductDetailsParams = jsb.ProductDetailsParams; } - export type BillingFlowParams = jsb.BillingFlowParams; + + export namespace QueryProductDetailsParams { + export type Product = jsb.Product; + } + export type QueryProductDetailsParams = jsb.QueryProductDetailsParams; + export type ConsumeParams = jsb.ConsumeParams; export type AcknowledgePurchaseParams = jsb.AcknowledgePurchaseParams; export type QueryPurchasesParams = jsb.QueryPurchasesParams;