如何在 Google Play 控制台中创建不可更新订阅
Posted
技术标签:
【中文标题】如何在 Google Play 控制台中创建不可更新订阅【英文标题】:How to create non renewable subscription in Google play console 【发布时间】:2021-12-22 20:56:31 【问题描述】:目前,我有自动续订订阅设置。但我想创建不可更新订阅,以便在每个计费周期结束时再次订阅。
在 google play 控制台中,没有选项可以创建像 ios 这样的不可更新订阅,如下所示。
iOS create plan page
请指导我如何在 google play 控制台中创建不可更新订阅。
【问题讨论】:
【参考方案1】:不可续订的订阅实际上是一种普通的一次性一次性产品。
订阅和一次性产品之间的唯一区别是订阅是重复的(续订)
来自Google Play's billing system overview
您可以使用 Google Play 的结算系统来销售以下类型的数字内容:
一次性产品:一次性产品是用户可以通过向用户付款方式一次性、非经常性收费购买的内容。
一次性产品可以是消耗品也可以是非消耗品:
消耗品产品是用户为接收应用内内容而消费的产品,例如游戏内货币。当用户消费产品时,您的应用会分发相关内容
and the user can then purchase the item again
。非消耗品是一种仅购买一次即可提供永久利益的产品。示例包括高级升级和关卡包。
订阅:订阅是一种产品,可让您访问
recurring basis
上的内容。订阅会自动续订,直到被取消。订阅示例包括访问在线杂志和音乐流媒体服务。
【讨论】:
不客气,我的回答对你有用吗?【参考方案2】:这对你有帮助!
//First, you need to initializes
private void Initialize()
billingClient = BillingClient.newBuilder(context)
.setListener(new PurchasesUpdatedListener()
@Override
public void onPurchasesUpdated(@NonNull @NotNull BillingResult billingResult, List<Purchase> list)
// Google Play calls this to deliver the result of the purchase operation to this listener
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null)
for(Purchase purchase : list)
// since we have only passes a productId at LaunchPurchaseFlow
activity.runOnUiThread(new Runnable()
@Override
public void run()
GotPurchase(purchase);
if(isAutoAcknowledge && !isSubscription)
HandleNonConsumable(purchase);
);
else if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED)
activity.runOnUiThread(new Runnable()
@Override
public void run()
PurchaseCancelled();
);
else
activity.runOnUiThread(new Runnable()
@Override
public void run()
PurchaseFailed(billingResult.getResponseCode());
);
)
.enablePendingPurchases()
.build();
// To start connection
public void StartConnection()
billingClient.startConnection(new BillingClientStateListener()
@Override
public void onBillingServiceDisconnected()
activity.runOnUiThread(new Runnable()
@Override
public void run()
BillingServiceDisconnect();
);
@Override
public void onBillingSetupFinished(@NonNull @NotNull BillingResult billingResult)
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK)
activity.runOnUiThread(new Runnable()
@Override
public void run()
BillingClientReady();
);
);
// To launch purchase flow use this method, productId is your product id and skuType can be subs or inapp . If you need for subs then pass skuType as subs
public void LaunchPurchaseFlow(String productId, String skuType)
String idOfProduct = isTest ? "android.test.purchased" : productId;
isSubscription = skuType.equals(BillingClient.SkuType.SUBS);
if(billingClient.isReady())
List<String> skuList = new ArrayList<>();
skuList.add(idOfProduct);
SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder()
.setSkusList(skuList)
.setType(skuType)
.build();
billingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener()
@Override
public void onSkuDetailsResponse(@NonNull @NotNull BillingResult billingResult, List<SkuDetails> list)
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && list != null)
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setSkuDetails(list.get(0))
.build();
billingClient.launchBillingFlow(activity , billingFlowParams);
else
FailedToLaunchPurchaseFlow(billingResult.getResponseCode());
);
else
OnError("Billing Client is not ready");
如果您正在为 InApp 购买,即消耗品或非消耗品,您应该像这样处理购买
// Consumable
public void HandleConsumable(Object purchase)
if(purchase instanceof Purchase)
Purchase purchase1 = (Purchase) purchase;
if(purchase1.getPurchaseState() == Purchase.PurchaseState.PENDING)
PurchaseStatePending();
else if(purchase1.getPurchaseState() == Purchase.PurchaseState.UNSPECIFIED_STATE)
PurchaseStateUnspecified();
else
if(!purchase1.isAcknowledged()) // TO know if payment is acknowledged, if not it means the payment is not successful/acknowledged yet.
ConsumeParams consumeParams = ConsumeParams.newBuilder()
.setPurchaseToken(purchase1.getPurchaseToken())
.build();
ConsumeResponseListener listener = new ConsumeResponseListener()
@Override
public void onConsumeResponse(@NonNull @NotNull BillingResult billingResult, @NonNull @NotNull String s)
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK)
activity.runOnUiThread(new Runnable()
@Override
public void run()
PurchaseSuccess();
);
else
activity.runOnUiThread(new Runnable()
@Override
public void run()
PurchaseFailed(billingResult.getResponseCode());
);
;
billingClient.consumeAsync(consumeParams , listener);
else
OnError("purchase is not an instance of Purchase");
// Non-Consumable or Acknowledged
public void HandleNonConsumable(Object purchase)
if(purchase instanceof Purchase)
Purchase purchase1 = (Purchase) purchase;
if(purchase1.getPurchaseState() == Purchase.PurchaseState.PENDING)
PurchaseStatePending();
else if(purchase1.getPurchaseState() == Purchase.PurchaseState.UNSPECIFIED_STATE)
PurchaseStateUnspecified();
else if(purchase1.getPurchaseState() == Purchase.PurchaseState.PURCHASED)
if(!purchase1.isAcknowledged())
AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase1.getPurchaseToken())
.build();
AcknowledgePurchaseResponseListener listener = new AcknowledgePurchaseResponseListener()
@Override
public void onAcknowledgePurchaseResponse(@NonNull @NotNull BillingResult billingResult)
if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK)
activity.runOnUiThread(new Runnable()
@Override
public void run()
PurchaseSuccess();
);
else
activity.runOnUiThread(new Runnable()
@Override
public void run()
PurchaseFailed(billingResult.getResponseCode());
);
;
billingClient.acknowledgePurchase(acknowledgePurchaseParams , listener);
else
OnError("purchase is not an instance of Purchase");
【讨论】:
以上是关于如何在 Google Play 控制台中创建不可更新订阅的主要内容,如果未能解决你的问题,请参考以下文章
错误状态:在 Google Play 控制台中创建订阅时出现无人认领的错误
无法在 Google Play 开发者控制台中创建应用内购买
Google Play 应用签名证书和上传证书都在 Google Play 控制台中创建了相同的 SHA1 密钥
Google Play Game RealTime Multiplayer 的快速匹配在 iOS 模拟器上的日志中创建错误