diff --git a/@types/jsb.d.ts b/@types/jsb.d.ts index 0f45f4911c7..ccff9eb7cff 100644 --- a/@types/jsb.d.ts +++ b/@types/jsb.d.ts @@ -364,7 +364,7 @@ declare namespace jsb { getOfferToken(): string; getType(): string; toStr(): string; - equals(product: Product): boolean; + equals(product: UserChoiceDetailsProduct): boolean; } export class UserChoiceDetails { getExternalTransactionToken(): string; @@ -501,7 +501,7 @@ declare namespace jsb { * @zh 代表一次性或订阅产品的详细信息。 */ export class ProductDetails { - static RecurrenceMode: jsb.RecurrenceMode; + static RecurrenceMode: typeof jsb.RecurrenceMode; equals(other: ProductDetails): boolean; /** * @en Hash code @@ -768,7 +768,7 @@ declare namespace jsb { }; getResponseCode(): number; getDebugMessage(): string; - toStr(): string; + toString(): string; public static newBuilder(): BillingResultBuilder; } @@ -1302,7 +1302,7 @@ declare namespace jsb { } export interface ProductDetailsParamsBuilder { - setOfferToken: (purchaseToken: string) => ProductDetailsParamsBuilder; + setOfferToken: (offerToken: string) => ProductDetailsParamsBuilder; setProductDetails: (productDetails: ProductDetails) => ProductDetailsParamsBuilder; build: () => ProductDetailsParams; } @@ -1312,7 +1312,7 @@ declare namespace jsb { } export interface SubscriptionUpdateParamsBuilder { - setOldPurcchaseToken: (purchaseToken: string) => SubscriptionUpdateParamsBuilder; + setOldPurchaseToken: (purchaseToken: string) => SubscriptionUpdateParamsBuilder; setOriginalExternalTransactionId: (externalTransactionId: string) => SubscriptionUpdateParamsBuilder; setSubscriptionReplacementMode: (subscriptionReplacementMode: number) => SubscriptionUpdateParamsBuilder; build: () => SubscriptionUpdateParams; @@ -1411,135 +1411,6 @@ declare namespace jsb { showExternalOfferInformationDialog: (listener: ExternalOfferInformationDialogListener) => BillingResult; showInAppMessages: (params: InAppMessageParams, listener: InAppMessageResponseListener) => BillingResult; } - - // /** - // * @en Main interface for communication between the Google Play library and user application code. - // * @zh 产品 ID。 - // */ - // const googleBilling: { - // enableAlternativeBillingOnly(): void; - // enableExternalOffer(): void; - // isEnabledForOneTimeProducts(): boolean; - // isEnabledForPrepaidPlans(): boolean; - // /** - // * @en Starts up BillingClient setup process asynchronously. - // * @zh 异步启动 BillingClient 设置过程。 - // */ - // startConnection(): void; - - // /** - // * @en Closes the connection and releases all held resources such as service connections. - // * @zh 关闭连接并释放所有持有的资源,例如服务连接。 - // */ - // endConnection(): void; - - // /** - // * @en Get the current billing client connection state. - // * @zh 获取当前计费客户端连接状态。 - // */ - // getConnectionState(): number; - - // /** - // * @en Checks if the client is currently connected to the service, so that requests to other methods will succeed. - // Returns true if the client is currently connected to the service, false otherwise. - // * @zh 检查客户端当前是否连接到服务,以便对其他方法的请求能够成功。 - // 如果客户端当前已连接到服务,则返回 true,否则返回 false。 - // */ - // isReady(): boolean; - - // /** - // * @en Performs a network query the details of products available for sale in your app. - // * @zh 执行网络查询您的应用中可供销售的产品的详细信息。 - // */ - // queryProductDetailsAsync(productId: string[], productType: string[]): void; - // /** - // * @en Initiates the billing flow for an in-app purchase or subscription. - // * @zh 启动应用内购买或订阅的计费流程。 - // */ - // launchBillingFlow(productDetails: ProductDetails[], selectedOfferToken: string | null): void; - // /** - // * @en Consumes a given in-app product. - // * @zh 消费指定的应用内产品。 - // */ - // consumeAsync(purchases: Purchase[]): void; - // /** - // * @en Returns purchases details for currently owned items bought within your app. - // * @zh 返回您应用内当前拥有的购买商品的购买详情。 - // */ - // queryPurchasesAsync(productType: string): void; - // /** - // * @en Acknowledges in-app purchases.. - // * @zh 确认应用内购买。 - // */ - // acknowledgePurchase(purchases: Purchase[]): void; - // /** - // * @en Gets the billing config, which stores configuration used to perform billing operations. - // * @zh 获取计费配置,其中存储用于执行计费操作的配置。 - // */ - // getBillingConfigAsync(): void; - - // /** - // * @en Creates alternative billing only purchase details that can be used to report a transaction made via alternative billing without user choice to use Google Play billing. - // * @zh 创建仅限替代结算的购买详情,可用于报告通过替代结算进行的交易,而无需用户选择使用 Google Play Billing。 - // */ - // createAlternativeBillingOnlyReportingDetailsAsync(): void; - // /** - // * @en Checks the availability of offering alternative billing without user choice to use Google Play Billing. - // * @zh 检查是否可以提供替代结算方式,而无需用户选择使用 Google Play Billing方式。 - // */ - // isAlternativeBillingOnlyAvailableAsync(): void; - - // /** - // * @en Creates purchase details that can be used to report a transaction made via external offer. - // * @zh 创建可用于报告通过外部报价进行的交易的购买详情。 - // */ - // createExternalOfferReportingDetailsAsync(): void; - // /** - // * @en Checks the availability of providing external offer. - // * @zh 检查提供外部报价的可用性。 - // */ - // isExternalOfferAvailableAsync(): void; - - // /** - // * @en Checks if the specified feature or capability is supported by the Play Store. - // * @zh 检查 Play Store 是否支持指定的功能。 - // */ - // isFeatureSupported(feature: string): BillingResult; - - // /** - // * @en Shows the alternative billing only information dialog on top of the calling app. - // * @zh 在调用应用程序顶部显示仅显示备用计费信息对话框。 - // */ - // showAlternativeBillingOnlyInformationDialog(): BillingResult; - - // /** - // * @en Shows the external offer information dialog on top of the calling app. - // * @zh 在调用应用程序顶部显示外部优惠信息对话框。 - // */ - // showExternalOfferInformationDialog(): BillingResult; - - // /** - // * @en Overlays billing related messages on top of the calling app. - // * @zh 在调用应用程序上叠加与计费相关的消息。 - // */ - // showInAppMessages(): BillingResult; - // } | undefined; - // export let onBillingSetupFinished: (result: BillingResult) => void | undefined; - // export let onBillingServiceDisconnected: () => void | undefined; - // export let onProductDetailsResponse: (result: BillingResult, productDetailsList: ProductDetails[]) => void | undefined; - // export let onPurchasesUpdated: (result: BillingResult, purchaseList: Purchase[]) => void | undefined; - // export let userSelectedAlternativeBilling: (userChoiceDetails: UserChoiceDetails) => void; - // export let onConsumeResponse: (result: BillingResult, purchaseToken: string) => void | undefined; - // export let onAcknowledgePurchaseResponse: (result: BillingResult) => void | undefined; - // export let onQueryPurchasesResponse: (result: BillingResult, purchaseList: Purchase[]) => void | undefined; - // export let onBillingConfigResponse: (result: BillingResult, config: BillingConfig) => void | undefined; - // export let onAlternativeBillingOnlyTokenResponse: (result: BillingResult, details: AlternativeBillingOnlyReportingDetails) => void | undefined; - // export let onExternalOfferReportingDetailsResponse: (result: BillingResult, details: ExternalOfferReportingDetails) => void | undefined; - // export let onAlternativeBillingOnlyAvailabilityResponse: (result: BillingResult) => void | undefined; - // export let onExternalOfferAvailabilityResponse: (result: BillingResult) => void | undefined; - // export let onAlternativeBillingOnlyInformationDialogResponse: (result: BillingResult) => void | undefined; - // export let onExternalOfferInformationDialogResponse: (result: BillingResult) => void | undefined; - // export let onInAppMessageResponse: (result: InAppMessageResult) => void | undefined; } declare namespace ns { 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 b88d52d5f3f..d73b278d1fc 100644 --- a/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java +++ b/native/cocos/platform/android/java/vendor/google/billing/GoogleBilling.java @@ -151,10 +151,6 @@ public boolean isReady() { return _billingClient.isReady(); } - public boolean isConnected() { - return getConnectionState() == BillingClient.ConnectionState.CONNECTED; - } - public void createAlternativeBillingOnlyReportingDetailsAsync(@NonNull AlternativeBillingOnlyReportingDetailsListener listener) { _billingClient.createAlternativeBillingOnlyReportingDetailsAsync(listener); } @@ -173,50 +169,46 @@ public void isExternalOfferAvailableAsync(@NonNull ExternalOfferAvailabilityList public void queryProductDetailsAsync(String[] productIds, String[] productTypes, ProductDetailsResponseListener listener) { - if(!isConnected()) { - Log.e(TAG, "Must be connected before use this interface"); - return; - } if(productIds.length == 0) { - Log.e(TAG, "Product ID cannot be empty"); + Log.e(TAG, "Product id must be provided."); return; } if(productIds.length != productTypes.length) { Log.e(TAG, "Product ID does not match the number of product types"); return; } - List products = new ArrayList<>(); - for(int i = 0; i < productIds.length; ++i) { - - String inputType; - if(productTypes[i].equals(BillingClient.ProductType.INAPP)) { - inputType = BillingClient.ProductType.INAPP; - } else if(productTypes[i].equals(BillingClient.ProductType.SUBS)) { - inputType = BillingClient.ProductType.SUBS; - } else { - Log.e(TAG, "Undefined product types."); - continue; + try { + List products = new ArrayList<>(); + for(int i = 0; i < productIds.length; ++i) { + String inputType = ""; + if(productTypes[i].equals(BillingClient.ProductType.INAPP)) { + inputType = BillingClient.ProductType.INAPP; + } else if(productTypes[i].equals(BillingClient.ProductType.SUBS)) { + inputType = BillingClient.ProductType.SUBS; + } + products.add( + QueryProductDetailsParams.Product.newBuilder() + .setProductId(productIds[i]) + .setProductType(inputType) + .build()); } - products.add( - QueryProductDetailsParams.Product.newBuilder() - .setProductId(productIds[i]) - .setProductType(inputType) - .build()); + QueryProductDetailsParams params = + QueryProductDetailsParams.newBuilder().setProductList(products).build(); + _billingClient.queryProductDetailsAsync(params, listener); + } catch (RuntimeException e) { + Log.e(TAG, e.getMessage()); } - QueryProductDetailsParams params = - QueryProductDetailsParams.newBuilder().setProductList(products).build(); - _billingClient.queryProductDetailsAsync(params, listener); } public void launchBillingFlow(BillingFlowParams params) { - _billingClient.launchBillingFlow(GlobalObject.getActivity(), params); + try { + _billingClient.launchBillingFlow(GlobalObject.getActivity(), params); + } catch (RuntimeException e) { + Log.e(TAG, e.getMessage()); + } } public void queryPurchasesAsync(String type, @NonNull PurchasesResponseListener listener) { - if(!isConnected()) { - Log.w(TAG, "Must be connected before use this interface"); - return; - } - String inputType; + String inputType = ""; if(type.equals(BillingClient.ProductType.INAPP)) { inputType = BillingClient.ProductType.INAPP; } else if(type.equals(BillingClient.ProductType.SUBS)) { @@ -225,26 +217,42 @@ public void queryPurchasesAsync(String type, @NonNull PurchasesResponseListener Log.w(TAG, "Undefined product types."); return; } - _billingClient.queryPurchasesAsync(QueryPurchasesParams.newBuilder() - .setProductType(inputType) - .build(), listener); + try { + _billingClient.queryPurchasesAsync(QueryPurchasesParams.newBuilder() + .setProductType(inputType) + .build(), listener); + } catch (RuntimeException e) { + Log.e(TAG, e.getMessage()); + } } public void consumeAsync(String purchaseToken, ConsumeResponseListener listener) { - _billingClient.consumeAsync(ConsumeParams.newBuilder() - .setPurchaseToken(purchaseToken).build(), - listener); + try { + _billingClient.consumeAsync(ConsumeParams.newBuilder() + .setPurchaseToken(purchaseToken).build(), + listener); + } catch (RuntimeException e) { + Log.e(TAG, e.getMessage()); + } } public void acknowledgePurchase(@Nullable String purchaseToken, AcknowledgePurchaseResponseListener listener) { - _billingClient.acknowledgePurchase( - AcknowledgePurchaseParams.newBuilder().setPurchaseToken(purchaseToken).build(), - listener); + try { + _billingClient.acknowledgePurchase( + AcknowledgePurchaseParams.newBuilder().setPurchaseToken(purchaseToken).build(), + listener); + } catch (RuntimeException e) { + Log.e(TAG, e.getMessage()); + } } public void getBillingConfigAsync( @NonNull BillingConfigResponseListener listener) { - GetBillingConfigParams getBillingConfigParams = GetBillingConfigParams.newBuilder().build(); - _billingClient.getBillingConfigAsync(getBillingConfigParams, listener); + try { + GetBillingConfigParams getBillingConfigParams = GetBillingConfigParams.newBuilder().build(); + _billingClient.getBillingConfigAsync(getBillingConfigParams, listener); + } catch (RuntimeException e) { + Log.e(TAG, e.getMessage()); + } } public BillingResult showAlternativeBillingOnlyInformationDialog(@NonNull AlternativeBillingOnlyInformationDialogListener listener) { 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 a9265687c61..a3db032a644 100644 --- a/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java +++ b/native/cocos/platform/android/java/vendor/google/billing/GoogleBillingHelper.java @@ -67,7 +67,7 @@ public class GoogleBillingHelper { public static int newTag() { return billingTag++; } - public static void createBillingClient(int tag, BillingClient.Builder builder) { + public static void createGoogleBilling(int tag, BillingClient.Builder builder) { GlobalObject.runOnUiThread(new Runnable() { @Override public void run() { diff --git a/native/vendor/google/billing/GoogleBilling.cpp b/native/vendor/google/billing/GoogleBilling.cpp index 9813487408b..cfaf99c9429 100644 --- a/native/vendor/google/billing/GoogleBilling.cpp +++ b/native/vendor/google/billing/GoogleBilling.cpp @@ -61,7 +61,7 @@ BillingClient::BillingClient(Builder* builder) { this->_purchasesUpdatedListener = builder->_purchasesUpdatedListener; this->_userChoiceBillingListener = builder->_userChoiceBillingListener; - _tag = GoogleBillingHelper::createBillingClient(builder); + _tag = GoogleBillingHelper::createGoogleBilling(builder); CC_ASSERT(_tag >= 0); GoogleBillingManager::getInstance()->pushBillingClient(_tag, this); diff --git a/native/vendor/google/billing/GoogleBillingHelper.cpp b/native/vendor/google/billing/GoogleBillingHelper.cpp index 15dd4dbe97b..5d5de54b54c 100644 --- a/native/vendor/google/billing/GoogleBillingHelper.cpp +++ b/native/vendor/google/billing/GoogleBillingHelper.cpp @@ -91,12 +91,12 @@ 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(BillingClient::Builder* builder) { +int GoogleBillingHelper::createGoogleBilling(BillingClient::Builder* builder) { int tag = JniHelper::callStaticIntMethod(JCLS_BILLING, "newTag"); jobject buildObj = JniBilling::newBillingClientBuilderObject(tag, builder); cc::JniMethodInfo t; - cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, "createBillingClient", "(ILcom/android/billingclient/api/BillingClient$Builder;)V"); + cc::JniHelper::getStaticMethodInfo(t, JCLS_BILLING, "createGoogleBilling", "(ILcom/android/billingclient/api/BillingClient$Builder;)V"); t.env->CallStaticVoidMethod(t.classID, t.methodID, tag, buildObj); return tag; diff --git a/native/vendor/google/billing/GoogleBillingHelper.h b/native/vendor/google/billing/GoogleBillingHelper.h index a43e6f261f8..174ab81619c 100644 --- a/native/vendor/google/billing/GoogleBillingHelper.h +++ b/native/vendor/google/billing/GoogleBillingHelper.h @@ -51,7 +51,7 @@ class AcknowledgePurchaseParams; class CC_DLL GoogleBillingHelper { public: - static int createBillingClient(BillingClient::Builder* builder); + static int createGoogleBilling(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/result-values/BillingResult.h b/native/vendor/google/billing/result-values/BillingResult.h index eec5197d7d5..75e1533910d 100644 --- a/native/vendor/google/billing/result-values/BillingResult.h +++ b/native/vendor/google/billing/result-values/BillingResult.h @@ -40,7 +40,7 @@ class CC_DLL BillingResult : public cc::RefCounted { return this->_debugMessage; } - std::string toStr() const { + std::string toString() const { return this->_toString; } class Builder { @@ -68,7 +68,6 @@ class CC_DLL BillingResult : public cc::RefCounted { static Builder* newBuilder() { return new Builder(); } - private: friend class JniBilling; int _responseCode{0}; diff --git a/native/vendor/google/billing/result-values/ProductDetails.h b/native/vendor/google/billing/result-values/ProductDetails.h index cec612b0d8f..8702246981c 100644 --- a/native/vendor/google/billing/result-values/ProductDetails.h +++ b/native/vendor/google/billing/result-values/ProductDetails.h @@ -195,7 +195,7 @@ class CC_DLL ProductDetails : public cc::RefCounted { return this->_title; } - std::string toStr() const { + std::string toString() const { return this->_toString; } diff --git a/native/vendor/google/billing/result-values/Purchase.h b/native/vendor/google/billing/result-values/Purchase.h index 7f8cd6ff9ad..dc1a024e726 100644 --- a/native/vendor/google/billing/result-values/Purchase.h +++ b/native/vendor/google/billing/result-values/Purchase.h @@ -96,7 +96,7 @@ class CC_DLL Purchase : public cc::RefCounted { return this->_signature; } - std::string toStr() const { + std::string toString() const { return this->_toString; } diff --git a/vendor/google/billing/billing-enum.ts b/vendor/google/billing/billing-enum.ts index 7b6ad5fbedb..aa9fd2a0a52 100644 --- a/vendor/google/billing/billing-enum.ts +++ b/vendor/google/billing/billing-enum.ts @@ -22,77 +22,80 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *****************************************************************************/ +import { JSB } from 'internal:constants'; declare const jsb: any; -jsb.BillingClient.ConnectionState = { - DISCONNECTED: 0, - CONNECTING: 1, - CONNECTED: 2, - CLOSED: 3, -}; -jsb.BillingClient.BillingResponseCode = { - SERVICE_TIMEOUT: -3, - FEATURE_NOT_SUPPORTED: -2, - SERVICE_DISCONNECTED: -1, - OK: 0, - USER_CANCELED: 1, - SERVICE_UNAVAILABLE: 2, - BILLING_UNAVAILABLE: 3, - ITEM_UNAVAILABLE: 4, - DEVELOPER_ERROR: 5, +if (JSB) { + jsb.BillingClient.ConnectionState = { + DISCONNECTED: 0, + CONNECTING: 1, + CONNECTED: 2, + CLOSED: 3, + }; + jsb.BillingClient.BillingResponseCode = { + SERVICE_TIMEOUT: -3, + FEATURE_NOT_SUPPORTED: -2, + SERVICE_DISCONNECTED: -1, + OK: 0, + USER_CANCELED: 1, + SERVICE_UNAVAILABLE: 2, + BILLING_UNAVAILABLE: 3, + ITEM_UNAVAILABLE: 4, + DEVELOPER_ERROR: 5, - ERROR: 6, - ITEM_ALREADY_OWNED: 7, - ITEM_NOT_OWNED: 8, - NETWORK_ERROR: 12, -}; + ERROR: 6, + ITEM_ALREADY_OWNED: 7, + ITEM_NOT_OWNED: 8, + NETWORK_ERROR: 12, + }; -jsb.BillingClient.FeatureType = { - SUBSCRIPTIONS: 'subscriptions', - SUBSCRIPTIONS_UPDATE: 'subscriptionsUpdate', - PRICE_CHANGE_CONFIRMATION: 'priceChangeConfirmation', - IN_APP_MESSAGING: 'bbb', - PRODUCT_DETAILS: 'fff', - BILLING_CONFIG: 'ggg', - ALTERNATIVE_BILLING_ONLY: 'jjj', - EXTERNAL_OFFER: 'kkk', -}; + jsb.BillingClient.FeatureType = { + SUBSCRIPTIONS: 'subscriptions', + SUBSCRIPTIONS_UPDATE: 'subscriptionsUpdate', + PRICE_CHANGE_CONFIRMATION: 'priceChangeConfirmation', + IN_APP_MESSAGING: 'bbb', + PRODUCT_DETAILS: 'fff', + BILLING_CONFIG: 'ggg', + ALTERNATIVE_BILLING_ONLY: 'jjj', + EXTERNAL_OFFER: 'kkk', + }; -jsb.BillingClient.ProductType = { - INAPP: 'inapp', - SUBS: 'subs', -}; + jsb.BillingClient.ProductType = { + INAPP: 'inapp', + SUBS: 'subs', + }; -jsb.InAppMessageParams.InAppMessageCategoryId = { - UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID: 0, - TRANSACTIONAL: 2, -}; + jsb.InAppMessageParams.InAppMessageCategoryId = { + UNKNOWN_IN_APP_MESSAGE_CATEGORY_ID: 0, + TRANSACTIONAL: 2, + }; -jsb.InAppMessageResult.InAppMessageResponseCode = { - NO_ACTION_NEEDED: 0, - SUBSCRIPTION_STATUS_UPDATED: 1, -}; + 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.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.ProductDetails.RecurrenceMode = { + INFINITE_RECURRING: 1, + FINITE_RECURRING: 2, + NON_RECURRING: 3, + }; -jsb.Purchase.PurchaseState = { - PENDING: 2, - PURCHASED: 1, - UNSPECIFIED_STATE: 0, -}; + 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 6d604914a97..035aa95e2c2 100644 --- a/vendor/google/billing/billing.ts +++ b/vendor/google/billing/billing.ts @@ -23,27 +23,29 @@ THE SOFTWARE. *****************************************************************************/ -import { EventTarget } from '../../../cocos/core/event'; +import { JSB } from 'internal:constants'; import './billing-enum'; +declare const jsb: any; + export namespace google { export namespace billing { - export const BillingClient = jsb.BillingClient; - export const BillingResult = jsb.BillingResult; + export const BillingClient = JSB ? jsb.BillingClient : null; + export const BillingResult = JSB ? jsb.BillingResult : null; - export const PendingPurchasesParams = jsb.PendingPurchasesParams; + export const PendingPurchasesParams = JSB ? jsb.PendingPurchasesParams : null; // export const ProductDetailsParams = jsb.ProductDetailsParams; - export const QueryProductDetailsParams = jsb.QueryProductDetailsParams; + export const QueryProductDetailsParams = JSB ? jsb.QueryProductDetailsParams : null; - export const Product = jsb.Product; - export const BillingFlowParams = jsb.BillingFlowParams; + export const Product = JSB ? jsb.Product : null; + export const BillingFlowParams = JSB ? jsb.BillingFlowParams : null; - export const ConsumeParams = jsb.ConsumeParams; - export const AcknowledgePurchaseParams = jsb.AcknowledgePurchaseParams; - export const QueryPurchasesParams = jsb.QueryPurchasesParams; - export const InAppMessageParams = jsb.InAppMessageParams; - export const GetBillingConfigParams = jsb.GetBillingConfigParams; + export const ConsumeParams = JSB ? jsb.ConsumeParams : null; + export const AcknowledgePurchaseParams = JSB ? jsb.AcknowledgePurchaseParams : null; + export const QueryPurchasesParams = JSB ? jsb.QueryPurchasesParams : null; + export const InAppMessageParams = JSB ? jsb.InAppMessageParams : null; + export const GetBillingConfigParams = JSB ? jsb.GetBillingConfigParams : null; } }