Google Play Android Developer API . purchases . subscriptions

Instance Methods

acknowledge(packageName, subscriptionId, token, body=None, x__xgafv=None)

Acknowledges a subscription purchase.

cancel(packageName, subscriptionId, token, x__xgafv=None)

Cancels a user's subscription purchase. The subscription remains valid until its expiration time.

close()

Close httplib2 connections.

defer(packageName, subscriptionId, token, body=None, x__xgafv=None)

Defers a user's subscription purchase until a specified future expiration time.

get(packageName, subscriptionId, token, x__xgafv=None)

Checks whether a user's subscription purchase is valid and returns its expiry time.

refund(packageName, subscriptionId, token, x__xgafv=None)

Refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.

revoke(packageName, subscriptionId, token, x__xgafv=None)

Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.

Method Details

acknowledge(packageName, subscriptionId, token, body=None, x__xgafv=None)
Acknowledges a subscription purchase.

Args:
  packageName: string, The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). (required)
  subscriptionId: string, The purchased subscription ID (for example, 'monthly001'). (required)
  token: string, The token provided to the user's device when the subscription was purchased. (required)
  body: object, The request body.
    The object takes the form of:

{ # Request for the purchases.subscriptions.acknowledge API.
  "developerPayload": "A String", # Payload to attach to the purchase.
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format
cancel(packageName, subscriptionId, token, x__xgafv=None)
Cancels a user's subscription purchase. The subscription remains valid until its expiration time.

Args:
  packageName: string, The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). (required)
  subscriptionId: string, The purchased subscription ID (for example, 'monthly001'). (required)
  token: string, The token provided to the user's device when the subscription was purchased. (required)
  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format
close()
Close httplib2 connections.
defer(packageName, subscriptionId, token, body=None, x__xgafv=None)
Defers a user's subscription purchase until a specified future expiration time.

Args:
  packageName: string, The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). (required)
  subscriptionId: string, The purchased subscription ID (for example, 'monthly001'). (required)
  token: string, The token provided to the user's device when the subscription was purchased. (required)
  body: object, The request body.
    The object takes the form of:

{ # Request for the purchases.subscriptions.defer API.
  "deferralInfo": { # A SubscriptionDeferralInfo contains the data needed to defer a subscription purchase to a future expiry time. # The information about the new desired expiry time for the subscription.
    "desiredExpiryTimeMillis": "A String", # The desired next expiry time to assign to the subscription, in milliseconds since the Epoch. The given time must be later/greater than the current expiry time for the subscription.
    "expectedExpiryTimeMillis": "A String", # The expected expiry time for the subscription. If the current expiry time for the subscription is not the value specified here, the deferral will not occur.
  },
}

  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # Response for the purchases.subscriptions.defer API.
  "newExpiryTimeMillis": "A String", # The new expiry time for the subscription in milliseconds since the Epoch.
}
get(packageName, subscriptionId, token, x__xgafv=None)
Checks whether a user's subscription purchase is valid and returns its expiry time.

Args:
  packageName: string, The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). (required)
  subscriptionId: string, The purchased subscription ID (for example, 'monthly001'). (required)
  token: string, The token provided to the user's device when the subscription was purchased. (required)
  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format

Returns:
  An object of the form:

    { # A SubscriptionPurchase resource indicates the status of a user's subscription purchase.
  "acknowledgementState": 42, # The acknowledgement state of the subscription product. Possible values are: 0. Yet to be acknowledged 1. Acknowledged
  "autoRenewing": True or False, # Whether the subscription will automatically be renewed when it reaches its current expiry time.
  "autoResumeTimeMillis": "A String", # Time at which the subscription will be automatically resumed, in milliseconds since the Epoch. Only present if the user has requested to pause the subscription.
  "cancelReason": 42, # The reason why a subscription was canceled or is not auto-renewing. Possible values are: 0. User canceled the subscription 1. Subscription was canceled by the system, for example because of a billing problem 2. Subscription was replaced with a new subscription 3. Subscription was canceled by the developer
  "cancelSurveyResult": { # Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey). # Information provided by the user when they complete the subscription cancellation flow (cancellation reason survey).
    "cancelSurveyReason": 42, # The cancellation reason the user chose in the survey. Possible values are: 0. Other 1. I don't use this service enough 2. Technical issues 3. Cost-related reasons 4. I found a better app
    "userInputCancelReason": "A String", # The customized input cancel reason from the user. Only present when cancelReason is 0.
  },
  "countryCode": "A String", # ISO 3166-1 alpha-2 billing country/region code of the user at the time the subscription was granted.
  "developerPayload": "A String", # A developer-specified string that contains supplemental information about an order.
  "emailAddress": "A String", # The email address of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
  "expiryTimeMillis": "A String", # Time at which the subscription will expire, in milliseconds since the Epoch.
  "externalAccountId": "A String", # User account identifier in the third-party service. Only present if account linking happened as part of the subscription purchase flow.
  "familyName": "A String", # The family name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
  "givenName": "A String", # The given name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
  "introductoryPriceInfo": { # Contains the introductory price information for a subscription. # Introductory price information of the subscription. This is only present when the subscription was purchased with an introductory price. This field does not indicate the subscription is currently in introductory price period.
    "introductoryPriceAmountMicros": "A String", # Introductory price of the subscription, not including tax. The currency is the same as price_currency_code. Price is expressed in micro-units, where 1,000,000 micro-units represents one unit of the currency. For example, if the subscription price is €1.99, price_amount_micros is 1990000.
    "introductoryPriceCurrencyCode": "A String", # ISO 4217 currency code for the introductory subscription price. For example, if the price is specified in British pounds sterling, price_currency_code is "GBP".
    "introductoryPriceCycles": 42, # The number of billing period to offer introductory pricing.
    "introductoryPricePeriod": "A String", # Introductory price period, specified in ISO 8601 format. Common values are (but not limited to) "P1W" (one week), "P1M" (one month), "P3M" (three months), "P6M" (six months), and "P1Y" (one year).
  },
  "kind": "A String", # This kind represents a subscriptionPurchase object in the androidpublisher service.
  "linkedPurchaseToken": "A String", # The purchase token of the originating purchase if this subscription is one of the following: 0. Re-signup of a canceled but non-lapsed subscription 1. Upgrade/downgrade from a previous subscription For example, suppose a user originally signs up and you receive purchase token X, then the user cancels and goes through the resignup flow (before their subscription lapses) and you receive purchase token Y, and finally the user upgrades their subscription and you receive purchase token Z. If you call this API with purchase token Z, this field will be set to Y. If you call this API with purchase token Y, this field will be set to X. If you call this API with purchase token X, this field will not be set.
  "obfuscatedExternalAccountId": "A 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": "A 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.
  "orderId": "A String", # The order id of the latest recurring order associated with the purchase of the subscription. If the subscription was canceled because payment was declined, this will be the order id from the payment declined order.
  "paymentState": 42, # The payment state of the subscription. Possible values are: 0. Payment pending 1. Payment received 2. Free trial 3. Pending deferred upgrade/downgrade Not present for canceled, expired subscriptions.
  "priceAmountMicros": "A String", # Price of the subscription, For tax exclusive countries, the price doesn't include tax. For tax inclusive countries, the price includes tax. Price is expressed in micro-units, where 1,000,000 micro-units represents one unit of the currency. For example, if the subscription price is €1.99, price_amount_micros is 1990000.
  "priceChange": { # Contains the price change information for a subscription that can be used to control the user journey for the price change in the app. This can be in the form of seeking confirmation from the user or tailoring the experience for a successful conversion. # The latest price change information available. This is present only when there is an upcoming price change for the subscription yet to be applied. Once the subscription renews with the new price or the subscription is canceled, no price change information will be returned.
    "newPrice": { # Definition of a price, i.e. currency and units. # The new price the subscription will renew with if the price change is accepted by the user.
      "currency": "A String", # 3 letter Currency code, as defined by ISO 4217. See java/com/google/common/money/CurrencyCode.java
      "priceMicros": "A String", # Price in 1/million of the currency base unit, represented as a string.
    },
    "state": 42, # The current state of the price change. Possible values are: 0. Outstanding: State for a pending price change waiting for the user to agree. In this state, you can optionally seek confirmation from the user using the In-App API. 1. Accepted: State for an accepted price change that the subscription will renew with unless it's canceled. The price change takes effect on a future date when the subscription renews. Note that the change might not occur when the subscription is renewed next.
  },
  "priceCurrencyCode": "A String", # ISO 4217 currency code for the subscription price. For example, if the price is specified in British pounds sterling, price_currency_code is "GBP".
  "profileId": "A String", # The Google profile id of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
  "profileName": "A String", # The profile name of the user when the subscription was purchased. Only present for purchases made with 'Subscribe with Google'.
  "promotionCode": "A String", # The promotion code applied on this purchase. This field is only set if a vanity code promotion is applied when the subscription was purchased.
  "promotionType": 42, # The type of promotion applied on this purchase. This field is only set if a promotion is applied when the subscription was purchased. Possible values are: 0. One time code 1. Vanity code
  "purchaseType": 42, # The type of purchase of the subscription. This field is only set if this purchase was not made using the standard in-app billing flow. Possible values are: 0. Test (i.e. purchased from a license testing account) 1. Promo (i.e. purchased using a promo code)
  "startTimeMillis": "A String", # Time at which the subscription was granted, in milliseconds since the Epoch.
  "userCancellationTimeMillis": "A String", # The time at which the subscription was canceled by the user, in milliseconds since the epoch. Only present if cancelReason is 0.
}
refund(packageName, subscriptionId, token, x__xgafv=None)
Refunds a user's subscription purchase, but the subscription remains valid until its expiration time and it will continue to recur.

Args:
  packageName: string, The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). (required)
  subscriptionId: string, "The purchased subscription ID (for example, 'monthly001'). (required)
  token: string, The token provided to the user's device when the subscription was purchased. (required)
  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format
revoke(packageName, subscriptionId, token, x__xgafv=None)
Refunds and immediately revokes a user's subscription purchase. Access to the subscription will be terminated immediately and it will stop recurring.

Args:
  packageName: string, The package name of the application for which this subscription was purchased (for example, 'com.some.thing'). (required)
  subscriptionId: string, The purchased subscription ID (for example, 'monthly001'). (required)
  token: string, The token provided to the user's device when the subscription was purchased. (required)
  x__xgafv: string, V1 error format.
    Allowed values
      1 - v1 error format
      2 - v2 error format