我已将我的 Kotlin 应用程序从 4.0 升级到 android-billing 5.0,因此,SkuDetails 现已弃用,因此我将使用迁移说明迁移到使用 ProductDetails 。
之前我使用SkuDetails.price向用户显示应用内购买的购买价格,但我在ProductDetails中找不到类似的方法。
在 Google Play Billing Library 5.0 中,是否有一种未弃用的方法来检索应用内购买或订阅的价格?
android in-app-billing kotlin android-billing play-billing-library
Android中如何获取PurchaseDetails对象的token?根据文档https://developer.android.com/google/play/billing/integrate#java,要启动购买流程,我们需要执行如下操作:
// An activity reference from which the billing flow will be launched.
Activity activity = ...;
ImmutableList productDetailsParamsList =
ImmutableList.of(
ProductDetailsParams.newBuilder()
// retrieve a value for "productDetails" by calling queryProductDetailsAsync()
.setProductDetails(productDetails)
// to get an offer token, call ProductDetails.getSubscriptionOfferDetails()
// for a list of offers that are available to the user
.setOfferToken(selectedOfferToken)
.build()
);
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setProductDetailsParamsList(productDetailsParamsList)
.build();
// Launch the billing flow
BillingResult billingResult = billingClient.launchBillingFlow(activity, billingFlowParams);
Run Code Online (Sandbox Code Playgroud)
请注意,它显示获取优惠令牌:
to get an offer …Run Code Online (Sandbox Code Playgroud) 我正在使用 Google Play Billing Library 5,并且有一个具有不同基本计划的订阅产品。
PurchasesUpdatedListener在或 的回调中处理购买时queryPurchasesAsync,我会收到一个对象列表Purchase,其中包含产品 ID、购买时间以及是否自动续订等内容。
但我如何知道用户选择了哪个基本计划以及该计划何时到期?
返回PurchaseHistoryRecord的queryPurchaseHistoryAsync似乎也不包含此信息。
我知道 Play Developer API 使用 来返回过期时间purchases.subscriptionsv2.get,但是直接使用 API 带来的不便是否有必要?
android in-app-billing android-billing play-billing-library google-play-billing
我正在使用Play Billing Library来触发和管理购买,从而解锁了应用中的额外功能.这部分正在运作.
但是,"恢复"购买的最佳方式是什么.比如说,购买该应用程序的人购买了一部新手机.登录Play商店,下载我的应用程序,然后发现正在显示"升级"的付款屏幕.iOS有一个特定的方法,但我不知道Android的一个方法.
我的想法是查询Play商店并确认该帐户以前是否已成功购买该商品,如果是,那么我将在应用程序内调用本地升级功能.
看来有两种类似的方法.但是我应该在这种情况下使用哪一个?用户要么擦了手机还是买了新手机?
queryPurchases()?还是queryPurchaseHistoryAsync()?
我正在使用三个保留的产品ID测试应用内购买,以测试静态Google Play结算响应:
然而,setSku和setType似乎在被弃用BillingFlowParams.Builder 类。相反,我们应该使用setSkuDetails(SkuDetails)。
如何更改BillingFlowParams示例代码中SkuDetails用于测试产品ID的代码?
BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSku(skuId)
.setType(SkuType.INAPP)
.build();
int responseCode = mBillingClient.launchBillingFlow(flowParams);
Run Code Online (Sandbox Code Playgroud) 如何确定用户是否有资格免费试用计费库?换句话说,如何知道用户之前没有使用过免费试用呢?我没有找到任何 API 可以帮助确定这一点。并且此信息与应用程序帐户无关,而是与用户的 Google Play 帐户相关。用户可以在应用程序中创建一个新帐户,但如果他已经参加了免费试用,即他之前使用当前的 Google 帐户(在 Google Play 中)购买了免费试用订阅,他将在弹出窗口中看到一条消息来自 Google“您已经参加了免费试用”。用户还可以随时更改其在 Google Play 中的 Google 帐户。因此,将用户已购买订阅的信息存储在服务器上是没有帮助的。我需要在应用程序用户界面上显示这些信息。
我在测试应用内结算时遇到问题。
(使用 Google Play In-app Billing Version 3 API)
问题:
退款的应用内购买仍然存在于购买列表中,由 提供BillingClient.queryPurchases()。
当我在 1 月份尝试退款时,退款的商品从购买清单中消失了。
我做了什么:
BillingClient.queryPurchases()在我的应用程序中检查了我的购买提供。最小校验码:
private val client: BillingClient // provided
fun check() {
// client.startConnection() already completed here
client.queryPurchases(BillingClient.SkuType.INAPP)
.run {
purchasesList
.map { it.originalJson }
.forEach { Log.d("billing", "json = $it") }
}
}
Run Code Online (Sandbox Code Playgroud)
我想做什么:
我想取消我所有的测试购买。
有没有人有什么建议?先感谢您。
android google-play android-billing google-play-services play-billing-library
我正在使用 Google Play 结算库在我的应用中提供一些应用内购买。一切正常,但我在 Crashlytics 上收到错误“Google Play In-app Billing API version is less than 3”,一些用户主要使用三星设备。
我搜索了类似的问题,我发现它可能是由于安装了过时的 Google Play 商店版本或未使用 Google 帐户登录造成的。问题是在许多报告的情况下,安装的 Play 商店版本是最新的并且帐户已正确登录,因为第一次连接到计费服务是成功的。
例如,安装20.39.15了 Play 服务和22.4.29-21Play 商店版本的用户有这种错误流:
BillingClientbillingClient.startConnectiononBillingSetupFinished带有响应代码的回调OK然后几秒钟后:
onBillingServiceDisconnected(此方法不起作用在我的实现)onBillingSetupFinished与responseCode3 debugMessage:“谷歌Play应用内结算API版本低于3”这是我正在使用的代码的一部分,为了清楚起见,我省略了日志记录:
class BillingManager(
private val application: Application
) : PurchasesUpdatedListener, BillingClientStateListener {
...
init {
billingClient = BillingClient.newBuilder(application.applicationContext)
.enablePendingPurchases()
.setListener(this)
.build()
connectToPlayBillingService()
}
private fun connectToPlayBillingService() { …Run Code Online (Sandbox Code Playgroud) 在尝试将 Google 结算集成从版本 4 迁移到版本 5 时,我在调用 queryProductDetailsAsync 时收到错误“客户端不支持 ProductDetails”。
List<QueryProductDetailsParams.Product> productList = List.of(QueryProductDetailsParams.Product.newBuilder()
.setProductId("ppgapp1")
.setProductType(BillingClient.ProductType.SUBS)
.build());
Run Code Online (Sandbox Code Playgroud)
QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build();
billingClient.queryProductDetailsAsync(params, listener);
Run Code Online (Sandbox Code Playgroud)
迁移时是否需要在控制台上进行任何更改?
提交到 Google 结算集成的封闭或内部测试轨道需要多长时间才能完成审核?
在旧的 Android 计费实现中,您将构建一个 sku 列表来查询产品:
List<String> skuList = new ArrayList<>();
skuList.add(SKU_POTION);
skuList.add(SKU_SWORD);
skuList.add(SKU_BOW);
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
Run Code Online (Sandbox Code Playgroud)
新的计费实施更加复杂,并且似乎限制您只能将一种产品添加到查询列表中:
ImmutableList<QueryProductDetailsParams.Product> productList = ImmutableList.from(QueryProductDetailsParams.Product.newBuilder()
.setProductId(SKU_POTION)
.setProductType(BillingClient.ProductType.INAPP)
.build());
QueryProductDetailsParams params = QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build();
billingClient.queryProductDetailsAsync(
params,
new ProductDetailsResponseListener() {
public void onProductDetailsResponse(BillingResult billingResult, List<ProductDetails> productDetailsList) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && productDetailsList != null) {
for (ProductDetails skuDetails : productDetailsList) {
mProductDetailsMap.put(skuDetails.getProductId(), skuDetails);
}
}
}
}
);
Run Code Online (Sandbox Code Playgroud)
它使您可以为启动购买流程所需的 mProductDetailsMap 的productDetailsList 构建productList:
puchasestring=SKU_POTION;
initiatePurchaseFlow(mProductDetailsMap.get(puchasestring));
Run Code Online (Sandbox Code Playgroud)
如何将多个产品添加到开始实施的产品列表中?我不想为每个项目重复整个代码段以添加到 mProductDetailsMap,这是我现在使用的 Primitive Pete 方法。