feat:补充异常信息展示

This commit is contained in:
max
2024-07-09 20:07:30 +08:00
parent 86b498c00e
commit 049006aa8b

View File

@@ -123,7 +123,7 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.
tryLaunch()
} else {
callFailed(
IPaymentClient.CODE_UNAVAILABLE
IPaymentClient.CODE_UNAVAILABLE, billingResult
)
}
}
@@ -135,7 +135,7 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.
handlePurchases(true, it)
}
} else {
callFailed(IPaymentClient.CODE_PURCHASE_FAILED)
callFailed(IPaymentClient.CODE_PURCHASE_FAILED, billingResult)
}
}
@@ -175,7 +175,7 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.
callSuccess(orderId)
}
} else {
callFailed(IPaymentClient.CODE_CONSUME_ORDER_FAILED)
callFailed(IPaymentClient.CODE_CONSUME_ORDER_FAILED, billingResult)
}
}
}
@@ -195,10 +195,10 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.
if (item != null) {
tryLaunch()
} else {
callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND)
callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND, billingResult)
}
} else {
callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND)
callFailed(IPaymentClient.CODE_PRODUCT_NOT_FOUND, billingResult)
}
}
@@ -221,6 +221,17 @@ class GPaymentClient(val activity: Activity) : IPaymentClient, IBillingService2.
)
}
private fun callFailed(code: Int, billingResult: IBillingResult) {
callFailed(
code,
PaymentException(
code,
message = activity.getString(R.string.common_operation_prompt_format)
.format("$code-${billingResult.getResponseCode()}")
)
)
}
private fun callFailed(code: Int, throwable: Throwable) {
throwable.printStackTrace()
logD("callFailed() code:${code} throwable:${throwable.message}")