From 6df95cf11f6117e2329dbb764b1f8eecee4495f8 Mon Sep 17 00:00:00 2001 From: max Date: Tue, 9 Jul 2024 14:36:12 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E9=80=82=E9=85=8DBillingService2=EF=BC=8C?= =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/chwl/app/application/App.java | 3 +- .../app/ui/wallet/payment/GPaymentClient.kt | 167 ++++++++++++------ .../app/ui/wallet/payment/IPaymentClient.kt | 21 ++- .../app/ui/wallet/payment/PaymentException.kt | 13 ++ .../com/chwl/app/ui/webview/JSInterface.java | 4 +- .../app/ui/webview/SimpleJSInterface.java | 3 +- core/src/main/res/values-ar/strings.xml | 1 + core/src/main/res/values-zh-rTW/strings.xml | 2 + core/src/main/res/values/strings.xml | 1 + .../java/com/chwl/library/utils/AppUtils.java | 22 --- .../support/billing/IBillingService.kt | 6 +- .../support/billing/IBillingService2.kt | 31 ++++ .../billing/OnBillingClientStateListener.kt | 5 + .../billing/OnConsumeResponseListener.kt | 8 + .../OnProductDetailsResponseListener.kt | 8 + .../billing/OnPurchasesResponseListener.kt | 5 + .../support/google/IGoogleService.kt | 13 ++ 17 files changed, 224 insertions(+), 89 deletions(-) create mode 100644 app/src/main/java/com/chwl/app/ui/wallet/payment/PaymentException.kt delete mode 100644 library/src/main/java/com/chwl/library/utils/AppUtils.java create mode 100644 modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService2.kt create mode 100644 modules/module_base/src/main/java/com/example/module_base/support/billing/OnBillingClientStateListener.kt create mode 100644 modules/module_base/src/main/java/com/example/module_base/support/billing/OnConsumeResponseListener.kt create mode 100644 modules/module_base/src/main/java/com/example/module_base/support/billing/OnProductDetailsResponseListener.kt create mode 100644 modules/module_base/src/main/java/com/example/module_base/support/billing/OnPurchasesResponseListener.kt diff --git a/app/src/main/java/com/chwl/app/application/App.java b/app/src/main/java/com/chwl/app/application/App.java index 9282a9aed..ba627c915 100644 --- a/app/src/main/java/com/chwl/app/application/App.java +++ b/app/src/main/java/com/chwl/app/application/App.java @@ -84,7 +84,6 @@ import com.chwl.library.common.file.FileHelper; import com.chwl.library.net.rxnet.RxNet; import com.chwl.library.net.rxnet.converter.GsonConverterPlugins; import com.chwl.library.utils.AppMetaDataUtil; -import com.chwl.library.utils.AppUtils; import com.chwl.library.utils.DeviceUuidFactory; import com.chwl.library.utils.ResUtil; import com.chwl.library.utils.SingleToastUtil; @@ -419,7 +418,7 @@ public class App extends BaseApp { httpParams.put("netType", String.valueOf(SystemUtils.getNetworkType(context))); httpParams.put("model", SystemUtils.getPhoneModel()); httpParams.put("appVersion", VersionUtil.getLocalName(context)); - httpParams.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context))); + httpParams.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context))); httpParams.put("deviceId", DeviceUuidFactory.getDeviceId(context)); httpParams.put("androidId", MD5Utils.getMD5String(Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID))); httpParams.put("channel", AppMetaDataUtil.getChannelID()); diff --git a/app/src/main/java/com/chwl/app/ui/wallet/payment/GPaymentClient.kt b/app/src/main/java/com/chwl/app/ui/wallet/payment/GPaymentClient.kt index ccc3896ac..4c252e85b 100644 --- a/app/src/main/java/com/chwl/app/ui/wallet/payment/GPaymentClient.kt +++ b/app/src/main/java/com/chwl/app/ui/wallet/payment/GPaymentClient.kt @@ -11,18 +11,22 @@ import com.chwl.core.pay.bean.PayRecordId import com.chwl.library.utils.SingleToastUtil import com.example.lib_utils.log.ILog import com.example.module_base.support.billing.IBillingResult -import com.example.module_base.support.billing.IBillingService +import com.example.module_base.support.billing.IBillingService2 import com.example.module_base.support.billing.IProductDetails import com.example.module_base.support.billing.IPurchase +import com.example.module_base.support.billing.OnBillingClientStateListener +import com.example.module_base.support.billing.OnConsumeResponseListener +import com.example.module_base.support.billing.OnProductDetailsResponseListener +import com.example.module_base.support.billing.OnPurchasesResponseListener import com.example.module_base.support.google.IGoogleService import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.Disposable -class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.Listener, - IBillingService.ProductDetailsResponseListener, LifecycleEventObserver, ILog { +class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.Listener, + OnProductDetailsResponseListener, LifecycleEventObserver, ILog, OnBillingClientStateListener { private var compositeDisposable: CompositeDisposable? = null - private var _billingService: IBillingService? = null + private var _billingService: IBillingService2? = null private val dialogManager = DialogManager(activity) private var paymentIntent: PaymentIntent? = null @@ -35,9 +39,11 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L (activity as? LifecycleOwner)?.lifecycle?.addObserver(this) } - private fun getBillingService(): IBillingService? { + private fun getBillingService(): IBillingService2? { if (_billingService == null) { - _billingService = IGoogleService.newBillingService(activity, this) + _billingService = IGoogleService.newBillingService2(activity, this) + _billingService?.setLogEnabled(true) + _billingService?.startConnection(this) } return _billingService } @@ -54,6 +60,14 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L } private fun tryLaunch() { + val billingService = getBillingService() + if (billingService == null) { + callFailed( + IPaymentClient.CODE_NONSUPPORT, + PaymentException(activity.getString(R.string.bean_response_serviceresult_015)) + ) + return + } val productId = paymentIntent?.productId val productItem = productItem logD("tryLaunch() productId:$productId productItem:$productItem") @@ -78,7 +92,7 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L { recordId: PayRecordId -> if (paymentIntent?.productId == productItem.getProductId()) { orderId = recordId.recordId - getBillingService()?.initiatePurchaseFlow( + getBillingService()?.launchBillingFlow( productItem, recordId.recordId ) @@ -91,47 +105,94 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L }) } - override fun onBillingClientSetupFinished() { - logD("onBillingClientSetupFinished()") - tryLaunch() + override fun onBillingSetupFinished(billingResult: IBillingResult) { + if (billingResult.isResponseOk()) { + logD("onBillingClientSetupFinished()") + getBillingService()?.queryPurchases(object : OnPurchasesResponseListener { + override fun onQueryPurchasesResponse( + billingResult: IBillingResult, + purchases: List + ) { + if (billingResult.isResponseOk() && purchases.isNotEmpty()) { + purchases.forEach { + handlePurchases(false, it) + } + } + } + }) + tryLaunch() + } else { + callFailed( + IPaymentClient.CODE_UNAVAILABLE + ) + } } - override fun onPurchasesUpdated(purchases: List) { - logD("onPurchasesUpdated() purchases:${purchases.size}") - purchases.forEach { - logD("onPurchasesUpdated() item.state:${it.getPurchaseState()}") - logD("onPurchasesUpdated() item.orderId:${it.getOrderId()}") - logD("onPurchasesUpdated() item.token:${it.getPurchaseToken()}") - logD("onPurchasesUpdated() item.data:${it.getData()}") - val identifiers = it.getAccountIdentifiers() - if (it.isPurchasedState() && identifiers != null) { - addDisposable( - PayModel.get().verifyOrder( - identifiers.getObfuscatedAccountId(), - it.getProducts().firstOrNull(), - it.getPackageName(), - it.getPurchaseToken() - ).subscribe({ - getBillingService()?.consumeAsync(it) - }, { - callFailed(IPaymentClient.CODE_VERIFY_ORDER_FAILED, it) - }) - ) + override fun onPurchasesUpdated(billingResult: IBillingResult, purchases: List?) { + logD("onPurchasesUpdated() billingResult:${billingResult.getResponseCode()} purchases:${purchases?.size}") + if (billingResult.isResponseOk() && !purchases.isNullOrEmpty()) { + purchases.forEach { + handlePurchases(true, it) } + } else { + callFailed(IPaymentClient.CODE_PURCHASE_FAILED) } } - override fun onConsumeFinished(token: String?, result: Int) { - logD("onConsumeFinished() token:${token} result:$result") - val orderId = orderId - if (orderId != null) { - callSuccess(orderId) + private fun handlePurchases(isCurrentPaying: Boolean, purchases: IPurchase) { + logD("handlePurchases state:${purchases.getPurchaseState()}") + logD("handlePurchases orderId:${purchases.getOrderId()}") + logD("handlePurchases token:${purchases.getPurchaseToken()}") + logD("handlePurchases data:${purchases.getData()}") + logD( + "handlePurchases obfuscatedAccountId:${ + purchases.getAccountIdentifiers()?.getObfuscatedAccountId() + }" + ) + logD( + "handlePurchases obfuscatedProfileId:${ + purchases.getAccountIdentifiers()?.getObfuscatedProfileId() + }" + ) + val identifiers = purchases.getAccountIdentifiers() + if (purchases.isPurchasedState() && identifiers != null) { + logD("handlePurchases() verifyOrder") + addDisposable( + PayModel.get().verifyOrder( + identifiers.getObfuscatedAccountId(), + purchases.getProducts().firstOrNull(), + purchases.getPackageName(), + purchases.getPurchaseToken() + ).subscribe({ + logD("handlePurchases() verifyOrder consumeAsync") + consumeAsync(isCurrentPaying, it) + }, { + logD("handlePurchases() error:${it.message}") + if (isCurrentPaying) { + callFailed(IPaymentClient.CODE_VERIFY_ORDER_FAILED, it) + } + }) + ) } } - override fun onFailedHandle(result: Int) { - logD("onFailedHandle() result:${result}") - callFailed(IPaymentClient.CODE_OTHER) + private fun consumeAsync(isCurrentPaying: Boolean, token: String) { + logD("consumeAsync() isCurrentPaying:${isCurrentPaying} token:$token") + getBillingService()?.consumeAsync(token, object : OnConsumeResponseListener { + override fun onConsumeResponse(billingResult: IBillingResult, purchaseToken: String) { + logD("consumeAsync() onConsumeResponse billingResult:${billingResult} purchaseToken:$purchaseToken") + if (isCurrentPaying) { + if (billingResult.isResponseOk()) { + val orderId = orderId + if (orderId != null) { + callSuccess(orderId) + } + } else { + callFailed(IPaymentClient.CODE_CONSUME_ORDER_FAILED) + } + } + } + }) } override fun onProductDetailsResponse( @@ -147,10 +208,10 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L if (item != null) { tryLaunch() } else { - callFailed(IPaymentClient.CODE_NOT_FOUND) + callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND) } } else { - callFailed(IPaymentClient.CODE_NOT_FOUND) + callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND) } } @@ -163,10 +224,20 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L dialogManager.dismissDialog() } - private fun callFailed(code: Int, throwable: Throwable? = null) { - throwable?.printStackTrace() - logD("callFailed() code:${code} throwable:${throwable?.message}") - throwable?.let { + private fun callFailed(code: Int) { + callFailed( + code, + PaymentException( + code, + message = activity.getString(R.string.common_operation_prompt_format).format(code) + ) + ) + } + + private fun callFailed(code: Int, throwable: Throwable) { + throwable.printStackTrace() + logD("callFailed() code:${code} throwable:${throwable.message}") + throwable.let { SingleToastUtil.showToast( it.message ) @@ -202,12 +273,6 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService.L override fun onStateChanged(source: LifecycleOwner, event: Lifecycle.Event) { logD("onStateChanged() event:$event") when (event) { - Lifecycle.Event.ON_RESUME -> { - if (_billingService?.isServiceConnected() == true) { - _billingService?.onQueryPurchases() - } - } - Lifecycle.Event.ON_DESTROY -> { (activity as? LifecycleOwner)?.lifecycle?.removeObserver(this) onCleared() diff --git a/app/src/main/java/com/chwl/app/ui/wallet/payment/IPaymentClient.kt b/app/src/main/java/com/chwl/app/ui/wallet/payment/IPaymentClient.kt index 6d0e8b10e..0dcbef53b 100644 --- a/app/src/main/java/com/chwl/app/ui/wallet/payment/IPaymentClient.kt +++ b/app/src/main/java/com/chwl/app/ui/wallet/payment/IPaymentClient.kt @@ -10,17 +10,26 @@ interface IPaymentClient : ICleared { // 未知异常原因 const val CODE_OTHER = 0 - // 服务不可用 - const val CODE_UNAVAILABLE = 1 + // 不支持该功能 + const val CODE_NONSUPPORT = 1 - // 查询订单信息失败 - const val CODE_NOT_FOUND = 2 + // 服务暂不可用 + const val CODE_UNAVAILABLE = 2 + + // 未查询到购买信息 + const val CODE_PRODUCT_NOT_FOUND = 3 // 预下单失败 - const val CODE_PLACE_ORDER_FAILED = 3 + const val CODE_PLACE_ORDER_FAILED = 4 + + // 购买失败 + const val CODE_PURCHASE_FAILED = 5 // 验证订单失败 - const val CODE_VERIFY_ORDER_FAILED = 4 + const val CODE_VERIFY_ORDER_FAILED = 6 + + // 核消订单失败 + const val CODE_CONSUME_ORDER_FAILED = 7 } fun launchPayment(intent: PaymentIntent) diff --git a/app/src/main/java/com/chwl/app/ui/wallet/payment/PaymentException.kt b/app/src/main/java/com/chwl/app/ui/wallet/payment/PaymentException.kt new file mode 100644 index 000000000..da7d1b4ea --- /dev/null +++ b/app/src/main/java/com/chwl/app/ui/wallet/payment/PaymentException.kt @@ -0,0 +1,13 @@ +package com.chwl.app.ui.wallet.payment + +import androidx.annotation.Keep + +@Keep +class PaymentException : Exception { + var code = 0 + + constructor(message: String) : super(message) + constructor(code: Int, message: String) : super(message) { + this.code = code + } +} \ No newline at end of file diff --git a/app/src/main/java/com/chwl/app/ui/webview/JSInterface.java b/app/src/main/java/com/chwl/app/ui/webview/JSInterface.java index 5d9c7defc..74d271319 100644 --- a/app/src/main/java/com/chwl/app/ui/webview/JSInterface.java +++ b/app/src/main/java/com/chwl/app/ui/webview/JSInterface.java @@ -59,7 +59,6 @@ import com.chwl.library.record.AuditRecorderConfiguration; import com.chwl.library.record.ExtAudioRecorder; import com.chwl.library.rxbus.RxBus; import com.chwl.library.utils.AppMetaDataUtil; -import com.chwl.library.utils.AppUtils; import com.chwl.library.utils.DeviceUuidFactory; import com.chwl.library.utils.SystemUtils; import com.chwl.library.utils.VersionUtil; @@ -545,7 +544,7 @@ public class JSInterface implements ICleared { jsonObject.put("netType", String.valueOf(SystemUtils.getNetworkType(context))); jsonObject.put("model", SystemUtils.getPhoneModel()); jsonObject.put("appVersion", VersionUtil.getLocalName(context)); - jsonObject.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context))); + jsonObject.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context))); jsonObject.put("deviceId", DeviceUtil.getDeviceId(context)); jsonObject.put("channel", AppMetaDataUtil.getChannelID()); jsonObject.put("Accept-Language", LanguageHelper.INSTANCE.getCurrentLanguageType()); @@ -630,7 +629,6 @@ public class JSInterface implements ICleared { @Override public void onCleared() { - ICleared.super.onCleared(); if (paymentClient != null) { paymentClient.onCleared(); } diff --git a/app/src/main/java/com/chwl/app/ui/webview/SimpleJSInterface.java b/app/src/main/java/com/chwl/app/ui/webview/SimpleJSInterface.java index e8fb46fe1..fe9e002cc 100644 --- a/app/src/main/java/com/chwl/app/ui/webview/SimpleJSInterface.java +++ b/app/src/main/java/com/chwl/app/ui/webview/SimpleJSInterface.java @@ -12,7 +12,6 @@ import com.tencent.vasdolly.helper.ChannelReaderUtil; import com.chwl.app.application.App; import com.chwl.core.XConstants; import com.chwl.core.Constants; -import com.chwl.library.utils.AppUtils; import com.chwl.library.utils.VersionUtil; /** @@ -108,7 +107,7 @@ public class SimpleJSInterface { jsonObject.put("os", "android"); jsonObject.put("app", XConstants.APP_MARK); jsonObject.put("appVersion", VersionUtil.getLocalName(context)); - jsonObject.put("appVersionCode", String.valueOf(AppUtils.getVersionCode(context))); + jsonObject.put("appVersionCode", String.valueOf(VersionUtil.getVersionCode(context))); jsonObject.put("channel", getChannel()); Log.e(TAG, "getDeviceInfo: " + jsonObject); return jsonObject.toJSONString(); diff --git a/core/src/main/res/values-ar/strings.xml b/core/src/main/res/values-ar/strings.xml index 14f1e4583..3badedc5b 100644 --- a/core/src/main/res/values-ar/strings.xml +++ b/core/src/main/res/values-ar/strings.xml @@ -683,4 +683,5 @@ خطأ في المعلمة رفض الطرف الآخر طلب الـ PK + 操作失敗 (%s) diff --git a/core/src/main/res/values-zh-rTW/strings.xml b/core/src/main/res/values-zh-rTW/strings.xml index 4b42429ba..e13da3260 100644 --- a/core/src/main/res/values-zh-rTW/strings.xml +++ b/core/src/main/res/values-zh-rTW/strings.xml @@ -670,4 +670,6 @@ 參數錯誤 對方拒絕你的PK請求 + + 操作失敗 (%s) diff --git a/core/src/main/res/values/strings.xml b/core/src/main/res/values/strings.xml index 53dce5c17..89760b24e 100644 --- a/core/src/main/res/values/strings.xml +++ b/core/src/main/res/values/strings.xml @@ -665,5 +665,6 @@ The opponent rejected your PK request + 操作失敗 (%s) diff --git a/library/src/main/java/com/chwl/library/utils/AppUtils.java b/library/src/main/java/com/chwl/library/utils/AppUtils.java deleted file mode 100644 index f5255365c..000000000 --- a/library/src/main/java/com/chwl/library/utils/AppUtils.java +++ /dev/null @@ -1,22 +0,0 @@ -package com.chwl.library.utils; - -import android.content.Context; -import android.content.pm.PackageManager; - -/** - *

- * - * @author jiahui - * date 2018/2/28 - */ -public class AppUtils { - - public static int getVersionCode(Context context) { - try { - return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; - } catch (PackageManager.NameNotFoundException e) { - e.printStackTrace(); - } - return 0; - } -} diff --git a/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService.kt b/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService.kt index 5425e4626..7d5d1435c 100644 --- a/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService.kt +++ b/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService.kt @@ -4,7 +4,9 @@ package com.example.module_base.support.billing * Created by Max on 2023/11/22 17:44 * Desc:支付 **/ +@Deprecated("逐步迁移到IBillingService2") interface IBillingService { + fun setLogEnabled(enabled: Boolean) fun isServiceConnected(): Boolean @@ -28,7 +30,5 @@ interface IBillingService { fun onFailedHandle(result: Int) } - interface ProductDetailsResponseListener { - fun onProductDetailsResponse(billingResult: IBillingResult, productDetails: List) - } + interface ProductDetailsResponseListener : OnProductDetailsResponseListener } \ No newline at end of file diff --git a/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService2.kt b/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService2.kt new file mode 100644 index 000000000..851b5a52e --- /dev/null +++ b/modules/module_base/src/main/java/com/example/module_base/support/billing/IBillingService2.kt @@ -0,0 +1,31 @@ +package com.example.module_base.support.billing + +/** + * Created by Max on 2023/11/22 17:44 + * Desc:支付 + **/ +interface IBillingService2 { + + fun setLogEnabled(enabled: Boolean) + + fun startConnection(listener: OnBillingClientStateListener) + + fun isServiceConnected(): Boolean + + fun queryPurchases(listener: OnPurchasesResponseListener) + + fun querySkuDetailsAsync( + productIdList: List, + listener: OnProductDetailsResponseListener + ) + + fun consumeAsync(purchaseToken: String, listener: OnConsumeResponseListener) + + fun launchBillingFlow(productDetails: IProductDetails, recordId: String) + + fun destroy() + + interface Listener { + fun onPurchasesUpdated(billingResult: IBillingResult, purchases: List?) + } +} \ No newline at end of file diff --git a/modules/module_base/src/main/java/com/example/module_base/support/billing/OnBillingClientStateListener.kt b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnBillingClientStateListener.kt new file mode 100644 index 000000000..95e660069 --- /dev/null +++ b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnBillingClientStateListener.kt @@ -0,0 +1,5 @@ +package com.example.module_base.support.billing + +interface OnBillingClientStateListener { + fun onBillingSetupFinished(billingResult: IBillingResult) +} \ No newline at end of file diff --git a/modules/module_base/src/main/java/com/example/module_base/support/billing/OnConsumeResponseListener.kt b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnConsumeResponseListener.kt new file mode 100644 index 000000000..03dc9df3f --- /dev/null +++ b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnConsumeResponseListener.kt @@ -0,0 +1,8 @@ +package com.example.module_base.support.billing + +interface OnConsumeResponseListener { + fun onConsumeResponse( + billingResult: IBillingResult, + purchaseToken: String + ) +} \ No newline at end of file diff --git a/modules/module_base/src/main/java/com/example/module_base/support/billing/OnProductDetailsResponseListener.kt b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnProductDetailsResponseListener.kt new file mode 100644 index 000000000..3ff458474 --- /dev/null +++ b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnProductDetailsResponseListener.kt @@ -0,0 +1,8 @@ +package com.example.module_base.support.billing + +interface OnProductDetailsResponseListener { + fun onProductDetailsResponse( + billingResult: IBillingResult, + productDetails: List + ) +} \ No newline at end of file diff --git a/modules/module_base/src/main/java/com/example/module_base/support/billing/OnPurchasesResponseListener.kt b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnPurchasesResponseListener.kt new file mode 100644 index 000000000..0ddd334f9 --- /dev/null +++ b/modules/module_base/src/main/java/com/example/module_base/support/billing/OnPurchasesResponseListener.kt @@ -0,0 +1,5 @@ +package com.example.module_base.support.billing + +interface OnPurchasesResponseListener { + fun onQueryPurchasesResponse(billingResult: IBillingResult, purchases: List) +} \ No newline at end of file diff --git a/modules/module_base/src/main/java/com/example/module_base/support/google/IGoogleService.kt b/modules/module_base/src/main/java/com/example/module_base/support/google/IGoogleService.kt index 3b9368958..c9ff25e0f 100644 --- a/modules/module_base/src/main/java/com/example/module_base/support/google/IGoogleService.kt +++ b/modules/module_base/src/main/java/com/example/module_base/support/google/IGoogleService.kt @@ -4,6 +4,7 @@ import android.app.Activity import com.alibaba.android.arouter.facade.template.IProvider import com.alibaba.android.arouter.launcher.ARouter import com.example.module_base.support.billing.IBillingService +import com.example.module_base.support.billing.IBillingService2 import com.example.module_base.support.login.ILoginService /** @@ -26,6 +27,13 @@ interface IGoogleService : IProvider { ): IBillingService? { return instance?.newBillingService(activity, listener) } + + fun newBillingService2( + activity: Activity, + listener: IBillingService2.Listener + ): IBillingService2? { + return instance?.newBillingService2(activity, listener) + } } fun newLoginService(): ILoginService @@ -34,4 +42,9 @@ interface IGoogleService : IProvider { activity: Activity, listener: IBillingService.Listener ): IBillingService + + fun newBillingService2( + activity: Activity, + listener: IBillingService2.Listener + ): IBillingService2 } \ No newline at end of file