feat:适配BillingService2,完善支付回调
This commit is contained in:
@@ -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<IProductDetails>)
|
||||
}
|
||||
interface ProductDetailsResponseListener : OnProductDetailsResponseListener
|
||||
}
|
@@ -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<String>,
|
||||
listener: OnProductDetailsResponseListener
|
||||
)
|
||||
|
||||
fun consumeAsync(purchaseToken: String, listener: OnConsumeResponseListener)
|
||||
|
||||
fun launchBillingFlow(productDetails: IProductDetails, recordId: String)
|
||||
|
||||
fun destroy()
|
||||
|
||||
interface Listener {
|
||||
fun onPurchasesUpdated(billingResult: IBillingResult, purchases: List<IPurchase>?)
|
||||
}
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.example.module_base.support.billing
|
||||
|
||||
interface OnBillingClientStateListener {
|
||||
fun onBillingSetupFinished(billingResult: IBillingResult)
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.example.module_base.support.billing
|
||||
|
||||
interface OnConsumeResponseListener {
|
||||
fun onConsumeResponse(
|
||||
billingResult: IBillingResult,
|
||||
purchaseToken: String
|
||||
)
|
||||
}
|
@@ -0,0 +1,8 @@
|
||||
package com.example.module_base.support.billing
|
||||
|
||||
interface OnProductDetailsResponseListener {
|
||||
fun onProductDetailsResponse(
|
||||
billingResult: IBillingResult,
|
||||
productDetails: List<IProductDetails>
|
||||
)
|
||||
}
|
@@ -0,0 +1,5 @@
|
||||
package com.example.module_base.support.billing
|
||||
|
||||
interface OnPurchasesResponseListener {
|
||||
fun onQueryPurchasesResponse(billingResult: IBillingResult, purchases: List<IPurchase>)
|
||||
}
|
@@ -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
|
||||
}
|
Reference in New Issue
Block a user