Subscription State Diagram logo

Subscription State Diagram

Organization
RevenueCat
subscription-state-diagram

Use this skill as the pull out reference for the full Google Play subscription state machine, showing every state and every RTDN triggered transition in one diagram.

Overview

PublisherRevenueCat
Repositoryplay-billing-skills
Skill namesubscription-state-diagram
Stars
58
Forks
0
Bundled files
Instructions only
LicenseApache-2.0
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by RevenueCat on GitHub. Read the source before you install it.

Installation

Install the Subscription State Diagram AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
    https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/subscription-state-diagram
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/RevenueCat/play-billing-skills.git /tmp/play-billing-skills
mkdir -p .claude/skills
cp -r /tmp/play-billing-skills/google-play/subscription-state-diagram .claude/skills/subscription-state-diagram
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Subscription State Diagram in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Subscription State Diagram on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Subscription State Diagram is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Subscription State Diagram

Phase 0: Intent

Use this skill when you need a single place to look up:

  • What states a Google Play subscription can be in.
  • Which RTDN (Real Time Developer Notification) moves a subscription from one state to the next.
  • Whether a given state grants access to paid content.
  • What token behavior to expect across renewals, pauses, holds, and resubscribes.

This is a reference skill. It does not write code for you. It hands you the map so you can point at a node, point at an edge, and then make a decision about access or acknowledgement.

Phase 1: Locate

Tell the skill which part of the state machine you care about. Pick the shortest path that matches your question.

You want to know...Jump to
What every state means and whether it grants accessStates at a Glance
Which RTDN fires on a specific transitionTransition Table
Whether to grant access right nowAccess Decision Flowchart
What happens to the purchase token across eventsToken Lifecycle
The numeric code for a notification typeRTDN Quick Reference
How long grace period, account hold, or token validity lastsTime Windows

A typical lookup looks like this:

  1. Name the current state (for example IN_GRACE_PERIOD).
  2. Name the event you observed (for example RTDN type 5).
  3. Find the row in the From IN_GRACE_PERIOD table.
  4. Read the target state and the access rule.

Phase 2: Reference Diagram

States at a Glance

StateAccessDescription
PENDINGNoPurchase initiated, payment not yet processed
PENDING_PURCHASE_CANCELEDNoPending transaction canceled; if linkedPurchaseToken is set, the previous subscription is unaffected
ACTIVEYesSubscription is paid and current
IN_GRACE_PERIODYesPayment failed, Google is retrying, user keeps access
ON_HOLDNoGrace period expired, access revoked, awaiting payment fix
PAUSEDNoUser requested pause, access revoked
CANCELEDUntil expiryCanceled but not expired, access until expiryTime
EXPIREDNoSubscription has ended

Transition Table

Every edge in the diagram. Columns: origin state, destination state, trigger, RTDN name and numeric type.

FromToTriggerRTDN
PENDINGACTIVEPayment completesSUBSCRIPTION_PURCHASED (4)
PENDINGPENDING_PURCHASE_CANCELEDPending payment canceled or expiredSUBSCRIPTION_PENDING_PURCHASE_CANCELED (20)
ACTIVEACTIVESuccessful renewalSUBSCRIPTION_RENEWED (2)
ACTIVEIN_GRACE_PERIODRenewal fails, grace period enabledSUBSCRIPTION_IN_GRACE_PERIOD (6)
ACTIVEON_HOLDRenewal fails, no grace, account hold enabledSUBSCRIPTION_ON_HOLD (5)
ACTIVECANCELEDUser or developer cancelsSUBSCRIPTION_CANCELED (3)
ACTIVEEXPIREDRevoked or refundedSUBSCRIPTION_REVOKED (12)
ACTIVEPAUSEDPause takes effect at end of periodSUBSCRIPTION_PAUSED (10)
IN_GRACE_PERIODACTIVEPayment recovered (renewal date unchanged)SUBSCRIPTION_RENEWED (2)
IN_GRACE_PERIODON_HOLDGrace expires without paymentSUBSCRIPTION_ON_HOLD (5)
IN_GRACE_PERIODEXPIREDGrace expires, no account holdSUBSCRIPTION_EXPIRED (13)
ON_HOLDACTIVEUser fixes paymentSUBSCRIPTION_RECOVERED (1)
ON_HOLDEXPIREDAccount hold period expiresSUBSCRIPTION_CANCELED (3), then SUBSCRIPTION_EXPIRED (13)
PAUSEDACTIVEPause ends, payment succeedsSUBSCRIPTION_RECOVERED (1)
PAUSEDON_HOLDPause ends, payment failsSUBSCRIPTION_ON_HOLD (5)
CANCELEDACTIVEUser restores before expirationSUBSCRIPTION_RESTARTED (7)
CANCELEDEXPIREDexpiryTime reachedSUBSCRIPTION_EXPIRED (13)
EXPIREDACTIVEUser resubscribes, new purchase tokenSUBSCRIPTION_PURCHASED (4)

RTDN Quick Reference by Number

#NameCommon Usage
1RECOVEREDRestore access after hold or pause
2RENEWEDExtend access period
3CANCELEDNote cancellation, keep access until expiry
4PURCHASEDNew subscription, grant access
5ON_HOLDRevoke access
6IN_GRACE_PERIODKeep access, warn user
7RESTARTEDRestore access, same token
8PRICE_CHANGE_CONFIRMEDDeprecated
9DEFERREDExtend billing date
10PAUSEDRevoke access at period end
11PAUSE_SCHEDULE_CHANGEDCheck pause status
12REVOKEDImmediately revoke access
13EXPIREDRevoke access, clean up
17ITEMS_CHANGEDCheck updated line items
18CANCELLATION_SCHEDULEDNote scheduled cancellation
19PRICE_CHANGE_UPDATEDCheck price change details
20PENDING_PURCHASE_CANCELEDClean up pending records
22PRICE_STEP_UP_CONSENT_UPDATEDCheck consent status

Time Windows

WindowDurationWhat Happens
Acknowledgement3 daysUnacknowledged purchases auto refund
Grace period0 to 30 days (not longer than the billing period), configurableUser keeps access while Google retries
Silent grace period1 day minimumApplies even when grace is set to 0 days
Account hold0 to 60 days; default 60 minus grace; grace + hold total 30 to 60 daysUser loses access, can recover by fixing payment
Token validity60 days post expirationAPI calls still succeed in this window
Pause duration1 week to 3 monthsDepends on billing period

Phase 3: Handling Guidance Per Transition

Each row tells you what to do when the RTDN lands. Pair this with the access rule in Phase 2.

TransitionYour handler should
PENDING to ACTIVEAcknowledge within 3 days, provision entitlement, store the purchase token
PENDING to PENDING_PURCHASE_CANCELEDClean up the pending record, do not provision; for a pending plan change or top up keep the old token's entitlement
ACTIVE to ACTIVE (renewal)Extend the entitlement to the new expiryTime, keep the same token
ACTIVE to IN_GRACE_PERIODKeep access on, surface a payment warning, trigger In App Messaging
ACTIVE to ON_HOLDRevoke access, tell the user to fix payment in Play
ACTIVE to CANCELEDKeep access until expiryTime, show an expiry countdown, log the cancel reason
ACTIVE to EXPIRED (revoke)Revoke access immediately, note the refund or revocation
ACTIVE to PAUSEDAccess ends at period end, show resume date on next open
IN_GRACE_PERIOD to ACTIVEClear the warning banner, confirm expiryTime moved forward
IN_GRACE_PERIOD to ON_HOLDRevoke access, swap the warning for a fix payment prompt
IN_GRACE_PERIOD to EXPIREDRevoke access, offer resubscribe
ON_HOLD to ACTIVERestore the entitlement, keep the existing token
ON_HOLD to EXPIREDRevoke, offer resubscribe, stop polling the token after 60 days
PAUSED to ACTIVERestore access, same token
PAUSED to ON_HOLDKeep access revoked, switch message to fix payment
CANCELED to ACTIVERestore, same token, remove the expiry countdown
CANCELED to EXPIREDRevoke, offer resubscribe
EXPIRED to ACTIVETreat as a new purchase, new token, link it to the prior user identity

Access Decision

Use the same rule across every handler.

kotlin
fun shouldGrantAccess(
    state: String,
    expiryTimeMillis: Long
): Boolean = when (state) {
    "SUBSCRIPTION_STATE_ACTIVE",
    "SUBSCRIPTION_STATE_IN_GRACE_PERIOD" -> true
    "SUBSCRIPTION_STATE_CANCELED" ->
        System.currentTimeMillis() < expiryTimeMillis
    else -> false
}

Token Lifecycle

EventToken Behavior
New purchaseNew token
RenewalSame token, new Order ID
Upgrade or downgradeNew token, old token linked via linkedPurchaseToken
Restore before expirySame token
Resubscribe after expiryNew token
Pause and resumeSame token
Grace period recoverySame token
Account hold recoverySame token

References

Frequently asked questions

What does the Subscription State Diagram AI skill do?

Use this skill as the pull out reference for the full Google Play subscription state machine, showing every state and every RTDN triggered transition in one diagram.

Why use Subscription State Diagram on TypingMind?

Because you install it once and use it with any model. Subscription State Diagram is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Subscription State Diagram in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/subscription-state-diagram. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Subscription State Diagram?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Subscription State Diagram?

As many as you like. As long as a model supports skills, you can use Subscription State Diagram with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Subscription State Diagram AI skill free?

Yes. It is published on GitHub by RevenueCat under the Apache-2.0 license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇