Sell subscriptions | Google Play’s billing system | Android Developers

This topic describes how to handle subscription lifecycle events, such as renewals and expirations. It also describes additional subscription features such as offering promotions and allowing your users to manage their own subscriptions .If you haven’t configured subscription products for your app, see Create and configure your products .A subscription represents a set of benefits users can access during a specified time period. For example, a subscription might entitle a user to access a music streaming service .

You can have multiple subscriptions within the same app, either to
represent different sets of benefits, or different tiers of a single
set of benefits (“Silver” and “Gold” tiers, for example).

Through base plans and offers, you can create multiple configurations for the same subscription product. For example, you can create an introductory offer for users who have never subscribed to your app. Similarly, you can create an tăng cấp offer for users who are already subscribed .For a detailed overview of subscription products, base plans, and offers, see the documentation in the Play Console Help Center .

Prepaid plans do not automatically renew upon expiration. To extend their
subscription entitlement without interruption, the user must top-up a
prepaid plan for the same subscription.

For top-ups, launch the billing flow as you would with the original purchase. You do not need to indicate that a purchase is a top-up .

Prepaid plan top-ups always use the IMMEDIATE_AND_CHARGE_FULL_PRICE
proration mode, and you don’t need to set this mode explicitly.
The user is immediately charged for a full billing period,
and their entitlement is extended by the duration specified in the top-up.

After a top-up, the following fields in the
result object are updated to reflect the most recent top-up purchase:

The following Purchase fields always contain the same data found in
the original purchase:

Similar to auto-renewing subscriptions, you must acknowledge prepaid plans after purchase. Both the initial purchase and any top-ups need to be acknowledged. For more information, see Processing purchases .Due to the potential for short prepaid plan durations, it is important to acknowledge the purchase as soon as possible .Prepaid plans with a duration of one week or longer must be acknowledged within three days .Prepaid plans with a duration shorter than one week must be acknowledged within half the plan duration. For example, developers have 1.5 days to acknowledge a three-day prepaid plan .As a developer, you must make it easy for your customers to manage their subscription. Your app should include a link on a settings or preferences màn hình hiển thị that allows users to manage their subscriptions. An example of this link is shown in figure 4 .

In this link’s click handler, add logic to determine whether the user has
any non-expired subscriptions for your app, where expiryTime is in
the future or autoRenewing is set to true.

Each subscription’s productId matches the product ID that you assigned
to it when creating it in the Play Console. To programmatically
determine the productId for an existing subscription, query your
app’s backend for a list of subscriptions associated with a particular user.

If the user has a non-expired subscription, you can direct them to a URL similar to the following, replacing ” your-sub-product-id ” and ” your-app-package ” with the subscription ID and app package info :If a user doesn’t have any non-expired subscriptions within your app, use the following URL to direct them to the page that shows all of their other subscriptions, as shown in figures 5 and 6 :You can find example code for subscription link logic in the Classy Taxi sample app .You can offer users different subscription tiers, such as a base tier and a premium tier. Figure 7 shows a màn hình hiển thị that offers two subscription tiers :Users should be able to access a màn hình hiển thị similar to figure 7 to tăng cấp or downgrade a subscription. When upgrading or downgrading a subscription, you can set the proration mode that determines how the change affects your subscribers .The following table lists available proration modes :If the user is changing subscription entitlements, you must specify the proration rate at runtime. For changes in entitlement, you cannot specify a default proration mode through the Google Play Console .

If the user is not changing subscription entitlements, you can use
the default proration mode configured through the Play Console. You can
also override this behavior by specifying a proration mode in
SubscriptionUpdateParams. Note the following restrictions:

To understand how each proration mode works, consider the following scenario:

Samwise has a subscription to online content from the Country Gardener app. He
currently has a monthly subscription to the Tier 1 version of the content,
which is text-only. This subscription costs him $2 per month, and it renews
on the first of the month.

On April 15, Samwise chose to upgrade to the annual version of the
Tier 2 subscription, which includes video updates and costs
$36 per year.

When upgrading the subscription, the developer selects a proration mode. The following list describes how each proration mode affects Samwise’s subscription :When choosing a proration mode, be sure to review our proration recommendations .Your app can offer users an tăng cấp or downgrade using the same steps as with launching a purchase flow. However, when upgrading or downgrading, you need to provide details for the current subscription, the future ( upgraded or downgraded ) subscription, and the proration mode to use, as shown in the following example :

For the immediate replacement proration modes, your app receives the new
purchase in your
The purchase is also available in
When you receive the purchase token, follow the same
verification process
as with verifying a new purchase token. Make sure to acknowledge these
purchases with
from the Google Play Billing Library or
from the Google Play Developer API.

The Google Play Developer API returns a linkedPurchaseToken in the
subscription resource.
Be sure to invalidate the token provided in the linkedPurchaseToken to
ensure that the old token is not used to gain access to your services. See
Upgrades, downgrades, and resignups
for information on handling upgrade and downgrade purchases.

For the deferred replacement mode, your app receives a call to your
with the purchase of the original subscription plan and a status of whether the
upgrade or downgrade was successful. Until the replacement takes effect,
continues to return the purchase for the original subscription plan. Once the
new plan takes effect, queryPurchasesAsync() returns the purchase data for
the new subscription, and a SUBSCRIPTION_RENEWED notification is sent to
your secure backend server. For deferred replacements, it is
strongly recommended to listen to this notification and to acknowledge
the purchase using
The linkedPurchaseToken in the subscription resource can be used to
determine which user in your subscription backend, if applicable, should be
updated with the new entitlement. Your app should not rely on the user
opening the app and acknowledging via
since the user might not open the app within three days of the plan change
taking effect.

Free trial eligibility settings apply when a user is upgrading or downgrading. You can adjust the không tính tiền trial eligibility settings in the Google Play Console .Note the following :The following table describes the behavior of each proration mode if both the new and old plans have a không lấy phí trial, and the user is upgrading during a không tính tiền trial :To understand how không tính tiền trial transitions work in the default case of one không lấy phí trial per app, consider the following scenario :

Maria has a subscription to online content from the Country Gardener app. She
currently has a monthly subscription to the Tier 1 version of the content,
which is text-only. This subscription costs her $10/month, and she
subscribed on April 1. She is enjoying a 30-day free trial as a first-time
subscriber, which means her first payment is due on May 1.

On April 15, Maria chooses to upgrade to the Tier 2 subscription, which
includes video updates and costs $20/month. This second subscription
has a 30-day trial as well.

The following list describes how the không tính tiền trial transition for each proration mode :The following list describes the transition behavior if the developer instead allows one không tính tiền trial per subscription :The following table shows diferrent proration scenarios along with what we recommend for each scenario :Using Real-time developer notifications, you can detect in real time when a user decides to cancel. When a user cancels, but before their subscription has expired, you can send them push notifications or in-app messages to ask them to resubscribe .After a user has cancelled their subscription, you can try to win them back either in your app, or through the Play store. The following table describes various subscription scenarios along with associated winback actions and app requirements .

Before subscription expiration After subscription expiration
In-app In Play Store In-app In Play Store
Winback feature In-app subscription Restore In-app subscription Resubscribe
User goes through checkout flow Yes No Yes Yes
User subscription remains associated with the same SKU User can sign up for same or different SKU Yes User can sign up for same or different SKU Yes
Creates new purchase token Yes No Yes Yes
Enabled by default No Yes, support required for all devs No Apps without Billing Library 2.0 + : No
Apps with Billing Library 2.0 + : Yes. Devs can opt-out in Console .
When user is charged

If using same SKU: end of current billing period.

If using different SKU : depends on proration mode .

End of current billing period Immediately Immediately
Implementation required Provide
a re-signup UI in your app
Detect change in subscription state

Deep-link to Play Store

Provide a re-signup UI in your app Handle out-of-app purchases
Sell subscriptions | Google Play’s billing system | Android Developers

Bài viết liên quan
Hotline 24/7: O984.666.352
Alternate Text Gọi ngay