REST Resource: purchases.subscriptionsv2

Resource: SubscriptionPurchaseV2

Indicates the status of a user's subscription purchase.

JSON representation
{
  "kind": string,
  "regionCode": string,
  "latestOrderId": string,
  "lineItems": [
    {
      object (SubscriptionPurchaseLineItem)
    }
  ],
  "startTime": string,
  "subscriptionState": enum (SubscriptionState),
  "linkedPurchaseToken": string,
  "pausedStateContext": {
    object (PausedStateContext)
  },
  "canceledStateContext": {
    object (CanceledStateContext)
  },
  "testPurchase": {
    object (TestPurchase)
  },
  "acknowledgementState": enum (AcknowledgementState),
  "externalAccountIdentifiers": {
    object (ExternalAccountIdentifiers)
  },
  "subscribeWithGoogleInfo": {
    object (SubscribeWithGoogleInfo)
  }
}
Fields
kind

string

This kind represents a SubscriptionPurchaseV2 object in the androidpublisher service.

regionCode

string

ISO 3166-1 alpha-2 billing country/region code of the user at the time the subscription was granted.

latestOrderId

string

The order id of the latest order associated with the purchase of the subscription. For autoRenewing subscription, this is the order id of signup order if it is not renewed yet, or the last recurring order id (success, pending, or declined order). For prepaid subscription, this is the order id associated with the queried purchase token.

lineItems[]

object (SubscriptionPurchaseLineItem)

Item-level info for a subscription purchase. The items in the same purchase should be either all with AutoRenewingPlan or all with PrepaidPlan.

startTime

string (Timestamp format)

Time at which the subscription was granted. Not set for pending subscriptions (subscription was created but awaiting payment during signup).

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

subscriptionState

enum (SubscriptionState)

The current state of the subscription.

linkedPurchaseToken

string

The purchase token of the old subscription if this subscription is one of the following: * Re-signup of a canceled but non-lapsed subscription * Upgrade/downgrade from a previous subscription. * Convert from prepaid to auto renewing subscription. * Convert from an auto renewing subscription to prepaid. * Topup a prepaid subscription.

pausedStateContext

object (PausedStateContext)

Additional context around paused subscriptions. Only present if the subscription currently has subscriptionState SUBSCRIPTION_STATE_PAUSED.

canceledStateContext

object (CanceledStateContext)

Additional context around canceled subscriptions. Only present if the subscription currently has subscriptionState SUBSCRIPTION_STATE_CANCELED.

testPurchase

object (TestPurchase)

Only present if this subscription purchase is a test purchase.

acknowledgementState

enum (AcknowledgementState)

The acknowledgement state of the subscription.

externalAccountIdentifiers

object (ExternalAccountIdentifiers)

User account identifier in the third-party service.

subscribeWithGoogleInfo

object (SubscribeWithGoogleInfo)

User profile associated with purchases made with 'Subscribe with Google'.

SubscriptionState

The potential states a subscription can be in, for example whether it is active or canceled. The items within a subscription purchase can either be all auto renewing plans or prepaid plans.

Enums
SUBSCRIPTION_STATE_UNSPECIFIED Unspecified subscription state.
SUBSCRIPTION_STATE_PENDING Subscription was created but awaiting payment during signup. In this state, all items are awaiting payment.
SUBSCRIPTION_STATE_ACTIVE Subscription is active. - (1) If the subscription is an auto renewing plan, at least one item is autoRenewEnabled and not expired. - (2) If the subscription is a prepaid plan, at least one item is not expired.
SUBSCRIPTION_STATE_PAUSED Subscription is paused. The state is only available when the subscription is an auto renewing plan. In this state, all items are in paused state.
SUBSCRIPTION_STATE_IN_GRACE_PERIOD Subscription is in grace period. The state is only available when the subscription is an auto renewing plan. In this state, all items are in grace period.
SUBSCRIPTION_STATE_ON_HOLD Subscription is on hold (suspended). The state is only available when the subscription is an auto renewing plan. In this state, all items are on hold.
SUBSCRIPTION_STATE_CANCELED Subscription is canceled but not expired yet. The state is only available when the subscription is an auto renewing plan. All items have autoRenewEnabled set to false.
SUBSCRIPTION_STATE_EXPIRED Subscription is expired. All items have expiryTime in the past.

PausedStateContext

Information specific to a subscription in paused state.

JSON representation
{
  "autoResumeTime": string
}
Fields
autoResumeTime

string (Timestamp format)

Time at which the subscription will be automatically resumed.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

CanceledStateContext

Information specific to a subscription in canceled state.

JSON representation
{

  // Union field cancellation_reason can be only one of the following:
  "userInitiatedCancellation": {
    object (UserInitiatedCancellation)
  },
  "systemInitiatedCancellation": {
    object (SystemInitiatedCancellation)
  },
  "developerInitiatedCancellation": {
    object (DeveloperInitiatedCancellation)
  },
  "replacementCancellation": {
    object (ReplacementCancellation)
  }
  // End of list of possible types for union field cancellation_reason.
}
Fields
Union field cancellation_reason. The reason why a subscription was canceled. cancellation_reason can be only one of the following:
userInitiatedCancellation

object (UserInitiatedCancellation)

Subscription was canceled by user.

systemInitiatedCancellation

object (SystemInitiatedCancellation)

Subscription was canceled by the system, for example because of a billing problem.

developerInitiatedCancellation

object (DeveloperInitiatedCancellation)

Subscription was canceled by the developer.

replacementCancellation

object (ReplacementCancellation)

Subscription was replaced by a new subscription.

UserInitiatedCancellation

Information specific to cancellations initiated by users.

JSON representation
{
  "cancelSurveyResult": {
    object (CancelSurveyResult)
  },
  "cancelTime": string
}
Fields
cancelSurveyResult

object (CancelSurveyResult)

Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).

cancelTime

string (Timestamp format)

The time at which the subscription was canceled by the user. The user might still have access to the subscription after this time. Use lineItems.expiry_time to determine if a user still has access.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

CancelSurveyResult

Result of the cancel survey when the subscription was canceled by the user.

JSON representation
{
  "reason": enum (CancelSurveyReason),
  "reasonUserInput": string
}
Fields
reason

enum (CancelSurveyReason)

The reason the user selected in the cancel survey.

reasonUserInput

string

Only set for CANCEL_SURVEY_REASON_OTHERS. This is the user's freeform response to the survey.

CancelSurveyReason

The reason the user selected in the cancel survey.

Enums
CANCEL_SURVEY_REASON_UNSPECIFIED Unspecified cancel survey reason.
CANCEL_SURVEY_REASON_NOT_ENOUGH_USAGE Not enough usage of the subscription.
CANCEL_SURVEY_REASON_TECHNICAL_ISSUES Technical issues while using the app.
CANCEL_SURVEY_REASON_FOUND_BETTER_APP The user found a better app.
CANCEL_SURVEY_REASON_OTHERS Other reasons.

SystemInitiatedCancellation

Information specific to cancellations initiated by Google system.

DeveloperInitiatedCancellation

Information specific to cancellations initiated by developers.

ReplacementCancellation

Information specific to cancellations caused by subscription replacement.

TestPurchase

Whether this subscription purchase is a test purchase.

AcknowledgementState

The possible acknowledgement states for a subscription.

Enums
ACKNOWLEDGEMENT_STATE_UNSPECIFIED Unspecified acknowledgement state.
ACKNOWLEDGEMENT_STATE_PENDING The subscription is not acknowledged yet.
ACKNOWLEDGEMENT_STATE_ACKNOWLEDGED The subscription is acknowledged.

ExternalAccountIdentifiers

User account identifier in the third-party service.

JSON representation
{
  "externalAccountId": string,
  "obfuscatedExternalAccountId": string,
  "obfuscatedExternalProfileId": string
}
Fields
externalAccountId

string

User account identifier in the third-party service. Only present if account linking happened as part of the subscription purchase flow.

obfuscatedExternalAccountId

string

An obfuscated version of the id that is uniquely associated with the user's account in your app. Present for the following purchases: * If account linking happened as part of the subscription purchase flow. * It was specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedaccountid when the purchase was made.

obfuscatedExternalProfileId

string

An obfuscated version of the id that is uniquely associated with the user's profile in your app. Only present if specified using https://developer.android.com/reference/com/android/billingclient/api/BillingFlowParams.Builder#setobfuscatedprofileid when the purchase was made.

SubscribeWithGoogleInfo

Information associated with purchases made with 'Subscribe with Google'.

JSON representation
{
  "profileId": string,
  "profileName": string,
  "emailAddress": string,
  "givenName": string,
  "familyName": string
}
Fields
profileId

string

The Google profile id of the user when the subscription was purchased.

profileName

string

The profile name of the user when the subscription was purchased.

emailAddress

string

The email address of the user when the subscription was purchased.

givenName

string

The given name of the user when the subscription was purchased.

familyName

string

The family name of the user when the subscription was purchased.

SubscriptionPurchaseLineItem

Item-level info for a subscription purchase.

JSON representation
{
  "productId": string,
  "expiryTime": string,

  // Union field plan_type can be only one of the following:
  "autoRenewingPlan": {
    object (AutoRenewingPlan)
  },
  "prepaidPlan": {
    object (PrepaidPlan)
  }
  // End of list of possible types for union field plan_type.
}
Fields
productId

string

The purchased product ID (for example, 'monthly001').

expiryTime

string (Timestamp format)

Time at which the subscription expired or will expire unless the access is extended (ex. renews).

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

Union field plan_type. The subscription plan type. plan_type can be only one of the following:
autoRenewingPlan

object (AutoRenewingPlan)

The item is auto renewing.

prepaidPlan

object (PrepaidPlan)

The item is prepaid.

AutoRenewingPlan

Information related to an auto renewing plan.

JSON representation
{
  "autoRenewEnabled": boolean
}
Fields
autoRenewEnabled

boolean

If the subscription is currently set to auto-renew, e.g. the user has not canceled the subscription

PrepaidPlan

Information related to a prepaid plan.

JSON representation
{
  "allowExtendAfterTime": string
}
Fields
allowExtendAfterTime

string (Timestamp format)

After this time, the subscription is allowed for a new top-up purchase. Not present if the subscription is already extended by a top-up purchase.

A timestamp in RFC3339 UTC "Zulu" format, with nanosecond resolution and up to nine fractional digits. Examples: "2014-10-02T15:01:23Z" and "2014-10-02T15:01:23.045123456Z".

Methods

get

Get metadata about a subscription