Logo de Cancellations Pauses Winback

Cancellations Pauses Winback

Organização
RevenueCat
cancellations-pauses-winback

Use this skill when implementing cancellations, developer initiated revocations, subscription pauses, and winback offers on Google Play. Covers user initiated cancellation, system cancellation, developer revoke/refund, pause resume flow, and winback API tools.

Visão geral

Publicado porRevenueCat
Repositórioplay-billing-skills
Nome da habilidadecancellations-pauses-winback
Estrelas
58
Forks
0
Arquivos incluídos
Somente instruções
LicençaApache-2.0
Links
  • Instruções em Markdown

    Um arquivo SKILL.md que o modelo carrega sob demanda, consumindo tokens apenas quando uma solicitação é realmente relevante para a habilidade.

  • Funciona com qualquer LLM

    As habilidades de IA são escritas em Markdown simples, não em código específico de um provedor. Por isso, funcionam com GPT, Claude, Gemini, Grok ou um modelo local.

  • Sem arquivos extras

    Tudo de que o modelo precisa está nas instruções — sem arquivos extras para sincronizar.

  • Código aberto

    Publicada por RevenueCat no GitHub. Leia os arquivos da habilidade antes de instalá-la.

Instalação

Instale a habilidade de IA Cancellations Pauses Winback no TypingMind para usá-la com qualquer LLM ou adicione-a a outro agente que leia SKILL.md.

1

Instalar no TypingMind

O TypingMind instala uma habilidade diretamente da pasta dela no GitHub — lê o arquivo SKILL.md, reúne os arquivos de recursos em um pacote e armazena o resultado localmente.

  1. Abra o app e vá para Plugins → Habilidades.
  2. Escolha "Instalar do GitHub".
  3. Cole a URL abaixo, que aponta para a pasta da habilidade, e confirme.
    https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/cancellations-pauses-winback
  4. Ative a habilidade em cada chat em que quiser disponibilizá-la.
Plugins → Habilidades → Adicionar habilidade → Via URL do GitHub. Depois, cole a URL da pasta e pressione Continuar.
2

Instalar em outro agente

Qualquer agente que leia o formato Agent Skills pode usar esta habilidade — copie a pasta para o diretório de habilidades desse agente.

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/cancellations-pauses-winback .claude/skills/cancellations-pauses-winback
Reinicie Claude Code após copiar para que a nova habilidade seja reconhecida.

Use no TypingMind

Ative Cancellations Pauses Winback em qualquer chat do TypingMind e o modelo cuida do resto. O nome e a descrição da habilidade ficam no prompt do sistema e, assim que uma solicitação relevante aparece, o modelo carrega as instruções completas automaticamente — sem precisar de acionamento manual e sem consumir tokens até que ela seja realmente usada.

O modelo carrega Cancellations Pauses Winback automaticamente assim que uma solicitação é relevante para essa habilidade.

Funciona com qualquer modelo de IA

Habilidades de IA são instruções em Markdown simples, não código específico de um provedor. Por isso, Cancellations Pauses Winback não fica vinculada ao modelo para o qual foi criada. Instale-a uma vez no TypingMind e use-a com GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama ou um modelo local executado por conta própria — tudo com suas próprias chaves de API.

  • Carregada apenas quando necessário

    O prompt do sistema contém apenas o nome e a descrição. As instruções são buscadas na primeira solicitação relevante, então uma habilidade sem uso não gera custo.

  • Troque de modelo durante a conversa

    Como a habilidade é composta de instruções, não de código, trocar de modelo não afeta seu funcionamento — o próximo modelo lê o mesmo arquivo SKILL.md.

Instruções da habilidade

Este é o conteúdo de SKILL.md que o modelo carrega. Leia antes de instalar — uma habilidade é um conjunto de instruções que seu modelo seguirá.

Cancellations, Pauses, and Winback

A subscription can end in several ways, and each one has a different effect on user access, entitlement records, and recovery options. Use this skill when you are wiring up any end of life or pause flow for a Google Play subscription: user cancellation, developer cancellation, system cancellation after payment failure, pause, resume, restore, resubscribe, deferral, or revocation.

Phase 1: Identify the Scenario

Before writing any code, identify which of the following you are handling. The later phases branch on this choice.

  • The user is canceling through Play (silent to your app, signaled by RTDN).
  • You are canceling from your backend on the user's behalf or for your own reasons.
  • Google canceled after exhausting grace period and account hold.
  • The user is pausing, resuming, or a pause is scheduled.
  • The user is restoring a cancellation before expiry, or resubscribing after expiry.
  • You are deferring billing as goodwill or compensation.
  • You are revoking immediately due to fraud or a terms violation.

Phase 2: Plan by Cancellation Type

Each cancellation type behaves differently with respect to access, refunds, RTDN signals, and recovery. Plan the entitlement logic using the matrix below before you touch the API.

Cancellation type matrix

TypeAPI or TriggerAccess AfterRefundPrimary RTDNcanceledStateContext member
User initiatedPlay Subscriptions CenterUntil expiryTimeNone (prorated not issued)SUBSCRIPTION_CANCELEDuserInitiatedCancellation
Developer, user requestedpurchases.subscriptionsv2.cancel with USER_REQUESTED_STOP_RENEWALSUntil expiryTimeNoneSUBSCRIPTION_CANCELEDNot documented for this cancellationType; read whichever member is set
Developer, your reasonpurchases.subscriptionsv2.cancel with DEVELOPER_REQUESTED_STOP_PAYMENTSUntil expiryTimeNoneSUBSCRIPTION_CANCELEDdeveloperInitiatedCancellation
System, payment failureAutomatic after grace + account holdNone from the moment account hold expiresNoneSUBSCRIPTION_CANCELEDsystemInitiatedCancellation
Replacement (plan change)Plan change flowHandled by new tokenN/ASUBSCRIPTION_PURCHASED on the new token (linkedPurchaseToken = old token); old token may report SUBSCRIPTION_EXPIRED (DEFERRED)replacementCancellation
Revokepurchases.subscriptionsv2.revokeImmediately terminatedThe refund type you pass (fullRefund or proratedRefund)SUBSCRIPTION_REVOKEDn/a (terminated)

Pause versus cancel

SignalWhat it meansAccess
SUBSCRIPTION_PAUSE_SCHEDULE_CHANGEDPause scheduled, starts at end of current billing periodStill active, full access
SUBSCRIPTION_PAUSEDPause has begunRevoke access
SUBSCRIPTION_RECOVEREDPause ended, payment collectedRestore access
SUBSCRIPTION_RESTARTEDUser restored a cancellation before expiryTimeAccess uninterrupted, same token

Installment subscription caveat

During the commitment period of an installment plan, a user cancellation is either blocked outright or scheduled for after the commitment. A scheduled cancellation arrives as SUBSCRIPTION_CANCELLATION_SCHEDULED, not SUBSCRIPTION_CANCELED. Treat scheduled cancellation as "user intends to leave, still paying". Do not revoke access. The final SUBSCRIPTION_CANCELED arrives later when the commitment completes.

Entitlement rule that applies to every type

A canceled subscription with a future expiryTime is still an active subscription from the user's perspective. The only exceptions are revocation (immediate) and SUBSCRIPTION_PAUSED (immediate).

Phase 3: Execute

Use the snippets below as starting points. Each one matches a specific API call or RTDN handler from Phase 2.

Entitlement check that survives cancellation

kotlin
fun hasActiveSubscription(
    subscription: SubscriptionPurchaseV2
): Boolean {
    val now = System.currentTimeMillis()
    val expiry = subscription.lineItems
        .firstOrNull()
        ?.expiryTime
        ?.let { Instant.parse(it).toEpochMilli() } ?: return false
    return now < expiry
}

Inspect canceledStateContext to segment churn

kotlin
fun logCancellationReason(
    subscription: SubscriptionPurchaseV2
) {
    val context = subscription.canceledStateContext ?: return
    when {
        context.userInitiatedCancellation != null -> analytics.trackChurn(
            reason = "user",
            surveyResponse = context.userInitiatedCancellation.cancelSurveyResult?.reason
        )
        context.systemInitiatedCancellation != null -> analytics.trackChurn(reason = "payment_failure")
        context.developerInitiatedCancellation != null -> analytics.trackChurn(reason = "developer")
        context.replacementCancellation != null -> Unit // plan change, not churn
    }
}

This mapping is what drives later winback decisions. A "too expensive" survey answer is a discount candidate. A payment failure is a payment update prompt. A fraud cancellation is not a winback candidate.

Developer initiated cancellation

Call purchases.subscriptionsv2.cancel with the package name, purchase token, and body {"cancellationContext": {"cancellationType": ...}}:

  • USER_REQUESTED_STOP_RENEWALS when the user asked you to cancel (the user can restore it).
  • DEVELOPER_REQUESTED_STOP_PAYMENTS when you are canceling for your own reasons (cannot be restored; for installments it stops the next payment).

Both leave access intact until expiryTime. Store the cancellationType you sent and your own reason at cancel time: developerInitiatedCancellation has no fields, so canceledStateContext alone cannot tell the two apart.

Pause RTDN handler

kotlin
fun handlePauseNotification(
    notificationType: Int,
    purchaseToken: String
) {
    when (notificationType) {
        11 -> markPauseScheduled(purchaseToken) // PAUSE_SCHEDULE_CHANGED
        10 -> revokeAccess(purchaseToken)       // PAUSED
        1  -> grantAccess(purchaseToken)        // RECOVERED
    }
}

Surface paused subscriptions on the client (PBL 8.1+)

kotlin
val params = QueryPurchasesParams.newBuilder()
    .setProductType(ProductType.SUBS)
    .includeSuspendedSubscriptions(true)
    .build()

val result = billingClient.queryPurchasesAsync(params)

Check purchase.isSuspended: when true, do not grant access. It covers both paused and account hold, so use a neutral "resume or fix payment" call to action to the subscriptions center, or ask your backend which state it is.

Restore before expiry

kotlin
fun handleSubscriptionRestarted(purchaseToken: String) {
    val record = database.findByPurchaseToken(purchaseToken) ?: return
    record.canceledAt = null
    record.status = "ACTIVE"
    database.update(record)
}

The purchase token does not change on restore.

Link a resubscribe to the original account

kotlin
fun handleResubscribe(new: SubscriptionPurchaseV2, newToken: String) {
    // Read before acknowledging: outOfAppPurchaseContext is removed after acknowledgement.
    val ctx = new.outOfAppPurchaseContext
    val user = ctx?.expiredExternalAccountIdentifiers?.obfuscatedExternalAccountId
        ?.let { database.findByObfuscatedAccountId(it) }
        ?: ctx?.expiredPurchaseToken?.let { database.findUserByPurchaseToken(it) }
    if (user != null) {
        database.addSubscription(user.id, newToken, "ACTIVE")
    } else {
        handleNewSubscription(new)
    }
}

Prerequisite: set BillingFlowParams.Builder.setObfuscatedAccountId(hashedUserId) on the original purchase. Without it, expiredExternalAccountIdentifiers carries no account ID; fall back to expiredPurchaseToken.

Defer billing

kotlin
fun deferSubscription(packageName: String, purchaseToken: String) {
    val sub = playApi.purchases().subscriptionsv2().get(packageName, purchaseToken).execute()
    val request = DeferSubscriptionPurchaseRequest().setDeferralContext(
        DeferralContext()
            .setEtag(sub.etag)                       // required, from subscriptionsv2.get
            .setDeferDuration("${14 * 24 * 3600}s")  // relative, 1 day to 1 year per call
    )
    playApi.purchases().subscriptionsv2()
        .defer(packageName, purchaseToken, request)
        .execute() // returns itemExpiryTimeDetails[] with each item's new expiryTime
}

Constraints: deferDuration from 1 day to 1 year per call; all items in a subscription with add ons move by the same duration. Deferral keeps the same token and can be applied multiple times. It does not work on canceled subscriptions.

Revoke immediately

kotlin
fun revokeSubscription(
    packageName: String,
    purchaseToken: String,
    reason: String
) {
    val request = RevokeSubscriptionPurchaseRequest().setRevocationContext(
        RevocationContext().setProratedRefund(RevocationContextProratedRefund())
    )
    playApi.purchases().subscriptionsv2()
        .revoke(packageName, purchaseToken, request)
        .execute()
    database.findByPurchaseToken(purchaseToken)?.let {
        it.status = "REVOKED"
        it.revokeReason = reason // local analytics only; the API call itself carries no reason
        database.update(it)
    }
}

Revocation is appropriate for confirmed fraud, serious terms of service violations, or proactive chargeback response. It is not a substitute for a standard cancel plus refund. Google issues the refund type you chose (fullRefund or proratedRefund) and sends SUBSCRIPTION_REVOKED so your backend can reconcile even if the local write failed. itemBasedRefund {productId} is different: it revokes and fully refunds one item of a subscription with add ons, and the subscription stays active while other items remain.

Winback Eligibility Checks

Use the canceledStateContext member from Phase 3 to decide who is eligible for a winback offer:

  • userInitiatedCancellation with a price related survey answer: discount offer.
  • systemInitiatedCancellation: payment method update prompt, not a discount.
  • developerInitiatedCancellation where your own records show you canceled for fraud or TOS: exclude from winback.
  • replacementCancellation: not a churn event, exclude.

A paused subscriber is not a winback candidate either. They have already signaled intent to return, so the right surface is a resume prompt, not a discount.

References

Perguntas frequentes

O que a habilidade de IA Cancellations Pauses Winback faz?

Use this skill when implementing cancellations, developer initiated revocations, subscription pauses, and winback offers on Google Play. Covers user initiated cancellation, system cancellation, developer revoke/refund, pause resume flow, and winback API tools.

Por que usar Cancellations Pauses Winback no TypingMind?

Porque basta instalar uma vez para usar com qualquer modelo. A habilidade Cancellations Pauses Winback é escrita em Markdown simples, e não em código específico de um provedor, então a mesma habilidade funciona com GPT-5, Claude, Gemini, Grok ou um modelo local — e é possível trocar de modelo no meio do chat sem que ela deixe de funcionar. No TypingMind, você usa suas próprias chaves de API e paga diretamente aos provedores, em vez de pagar uma assinatura por licença de usuário. Suas habilidades e chats permanecem no seu próprio armazenamento.

Como instalar Cancellations Pauses Winback no TypingMind?

Abra Plugins → Habilidades → Instalar do GitHub no TypingMind e cole https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/cancellations-pauses-winback. O TypingMind lê o arquivo SKILL.md e instala a habilidade para que possa ser ativada em cada chat.

Quais modelos de IA podem usar Cancellations Pauses Winback?

Qualquer modelo conectado no TypingMind. As habilidades de IA são instruções em Markdown simples, e não código específico de um provedor. Assim, GPT, Claude, Gemini, Grok e modelos locais podem carregar esta habilidade quando uma solicitação corresponder a ela.

Quantos modelos de IA posso usar com Cancellations Pauses Winback?

Quantos quiser. Desde que o modelo ofereça suporte a habilidades, é possível usar Cancellations Pauses Winback com ele — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e outros — tudo no TypingMind com suas próprias chaves de API.

A habilidade de IA Cancellations Pauses Winback é gratuita?

Sim. A habilidade é publicada no GitHub por RevenueCat sob a licença Apache-2.0. O pagamento é feito apenas ao seu provedor de IA pelos tokens usados.

O que são habilidades de IA?

Uma habilidade de IA é um conjunto reutilizável de instruções que ensina um modelo de IA a realizar uma tarefa específica. Ela segue o formato aberto Agent Skills: um arquivo SKILL.md com nome e descrição, além de scripts, templates ou arquivos de referência de que o modelo possa precisar. O modelo lê as instruções apenas quando sua solicitação corresponde à habilidade, então uma habilidade instalada não gera custos até ser usada.

Qual é a diferença entre habilidades de IA e plugins ou servidores MCP?

Um plugin ou servidor MCP oferece ao modelo novas ferramentas que ele pode acionar — código que é executado em algum lugar e retorna um resultado. Já uma habilidade de IA dá ao modelo o conhecimento e as orientações de que ele precisa: como abordar uma tarefa, quais etapas seguir e como deve ser um bom resultado. As habilidades são escritas em Markdown simples, por isso não precisam de servidor, chave de API nem ambiente de execução, e funcionam com qualquer modelo.

Ver lista completa

Crie seu próprio espaço de trabalho com IA agora

Inscreva-se na nossa newsletter para receber avisos sobre novos recursos e futuros sorteios 👇