gpt4 book ai didi

带有试用期的 Android In-App Billing V5 订阅

转载 作者:行者123 更新时间:2023-12-04 23:50:16 28 4
gpt4 key购买 nike

谷歌已经更新了它的计费系统,没有完整的信息如何处理它。
因此,而不是 SkyDetails我们有课ProductDetails .我们可以在 billingClient.queryProductDetailsAsync() 的回调中接收到这个对象.然后我们可以调用getSubscriptionOfferDetails()在此对象上并获得对 ProductDetails.PricingPhases 列表的访问权限.例如,如果产品有 2 个报价(基本报价和试用报价),我们会得到 2 个 ProductDetails.PricingPhases 的列表.
然后当用户想购买我们使用的产品时(来自官方文档):

val offerToken = productDetails.offerDetails(selectedOfferIndex).offerToken
什么是 selectedOfferIndex ?我们应该总是选择第一个项目还是取决于它?
提前感谢大家。

最佳答案

例如,您有 2 个这样的订阅(2 个产品)

[
ProductDetails{
parsedJson={
"productId": "...",
"subscriptionOfferDetails": [
{
"offerIdToken": "...token_1...",
"pricingPhases": [
{
"priceAmountMicros": 631000000000,
"priceCurrencyCode": "VND",
"formattedPrice": "₫631,000",
"billingPeriod": "P6M",

}
]
}
]
}
},
ProductDetails{
parsedJson={
"productId": "...",
"subscriptionOfferDetails": [
{
"offerIdToken": "...token_2...",
"pricingPhases": [
{
"priceAmountMicros": 0,
"priceCurrencyCode": "VND",
"formattedPrice": "Free",
"billingPeriod": "P1M",
"recurrenceMode": 2,
"billingCycleCount": 1
},
{
"priceAmountMicros": 112000000000,
"priceCurrencyCode": "VND",
"formattedPrice": "₫112,000",
"billingPeriod": "P6M",

}
],
{
"offerIdToken": "...token_3...",
"pricingPhases": [
{
"priceAmountMicros": 631000000000,
"priceCurrencyCode": "VND",
"formattedPrice": "₫631,000",
"billingPeriod": "P6M",
}
]
}
}
]
}
}
]
在第二次订阅时购买第一个计划(免费试用 1 个月)的示例(ProductDetails)
val productDetails2 = ...
val offerToken = "...token_2..."
// val offerToken = productDetails2.subscriptionOfferDetails.get(0).offerToken
// in json response, it name is offerIdToken but after parse it's offerToken

val productDetailsParamsList =
listOf(
BillingFlowParams.ProductDetailsParams.newBuilder()
.setProductDetails(productDetails2)
.setOfferToken(offerToken)
.build()
)
val billingFlowParams = BillingFlowParams.newBuilder()
.setProductDetailsParamsList(productDetailsParamsList)
.build()

billingClient.launchBillingFlow(this, billingFlowParams)

关于带有试用期的 Android In-App Billing V5 订阅,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72351444/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com