Logotipo de Payment Recovery

Payment Recovery

Organización
RevenueCat
payment-recovery

Use this skill when handling failed subscription renewals on Google Play. Covers Grace Period (user keeps access), Account Hold (access revoked), the RTDN signals that move between stages, and the in app messaging required to drive recovery.

Add to TypingMind

Descripción general

EditorRevenueCat
Repositorioplay-billing-skills
Nombre de la habilidadpayment-recovery
Estrellas
58
Forks
0
Archivos incluidos
Solo instrucciones
LicenciaApache-2.0
Enlaces
  • Instrucciones en Markdown

    Un archivo SKILL.md que el modelo carga cuando lo necesita, de modo que solo consume tokens cuando la petición encaja con la habilidad.

  • Funciona con cualquier LLM

    Las habilidades de IA están en Markdown, no en código específico de un proveedor, por lo que funcionan con GPT, Claude, Gemini, Grok o un modelo local.

  • Todo en las instrucciones

    Todo lo que necesita el modelo está en las instrucciones: no hay archivos adicionales que sincronizar.

  • Código abierto

    Publicada por RevenueCat en GitHub. Revisa el contenido original antes de instalarla.

Instalación

Instala la habilidad de IA Payment Recovery en TypingMind para usarla con cualquier LLM, o añádela a otro agente que lea SKILL.md.

1

Instalar en TypingMind

TypingMind instala una habilidad directamente desde su carpeta de GitHub: lee SKILL.md, empaqueta los archivos de recursos y guarda el resultado localmente.

  1. Abre la aplicación y ve a Plugins → Habilidades.
  2. Elige «Instalar desde GitHub».
  3. Pega la URL de la carpeta de la habilidad que se muestra a continuación y confirma.
    https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/payment-recovery
  4. Activa la habilidad en cada chat en el que quieras tenerla disponible.
Plugins → Habilidades → Añadir habilidad → URL de GitHub; después, pega la URL de la carpeta y pulsa Continuar.
2

Instalar en otro agente

Cualquier agente que lea el formato Agent Skills puede usar esta habilidad: copia la carpeta en el directorio de habilidades de ese 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/payment-recovery .claude/skills/payment-recovery
Reinicia Claude Code después de copiarla para que detecte la nueva habilidad.

Úsala en TypingMind

Activa Payment Recovery en cualquier chat de TypingMind y el modelo se encargará del resto. Su nombre y descripción se incluyen en el prompt del sistema y, en cuanto una petición encaja con la habilidad, el modelo carga las instrucciones completas por sí solo. No tienes que invocarla manualmente y no consume tokens hasta que se utiliza.

El modelo carga Payment Recovery automáticamente en cuanto una petición es relevante para esa habilidad.

Funciona con cualquier modelo de IA

Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que Payment Recovery no está vinculada al modelo para el que se creó. Instálala una sola vez en TypingMind y úsala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modelo local que ejecutes tú, todo con tus propias claves API.

  • Se carga solo cuando se necesita

    El prompt del sistema solo incluye el nombre y la descripción. Las instrucciones se cargan con la primera petición que encaja con la habilidad, por lo que una habilidad que no se usa no supone ningún coste.

  • Cambia de modelo durante el chat

    Como la habilidad contiene instrucciones y no código, cambiar de modelo no impide que funcione: el nuevo modelo lee el mismo archivo SKILL.md.

Instrucciones de la habilidad

Este es el contenido de SKILL.md que carga el modelo. Léelo antes de instalar la habilidad: contiene instrucciones que tu modelo seguirá.

Payment Recovery: Grace Period and Account Hold

Google Play does not cancel a subscription the moment a renewal charge fails. It runs a two stage recovery process: grace period (user keeps access while Google retries) then account hold (access revoked while Google keeps retrying). Your job is to react to the right RTDNs, toggle entitlements at the right moments, and prompt the user to fix payment without forcing them to leave your app.

Phase 1: Understand

Map the stages, the RTDN for each transition, and the entitlement you should hold.

StageEntry RTDNDurationUser accessSubscriptionPurchaseV2 state
Silent grace periodnone (always applies)~1 dayActiveSUBSCRIPTION_STATE_ACTIVE
Configured grace periodSUBSCRIPTION_IN_GRACE_PERIOD0 to 30 days (per base plan)Keep full accessSUBSCRIPTION_STATE_IN_GRACE_PERIOD
Account holdSUBSCRIPTION_ON_HOLD0 to 60 days (default 60 minus grace; grace + hold total 30 to 60)RevokeSUBSCRIPTION_STATE_ON_HOLD
Recovered from graceSUBSCRIPTION_RENEWEDn/aKeep, clear warningSUBSCRIPTION_STATE_ACTIVE (renewal date unchanged)
Recovered from holdSUBSCRIPTION_RECOVEREDn/aRestore immediatelySUBSCRIPTION_STATE_ACTIVE (billing date moves to recovery date)
Terminal failureSUBSCRIPTION_CANCELED (3), then SUBSCRIPTION_EXPIRED (13)n/aGonecanceled/expired

Key facts to internalize before writing any code:

  • The silent grace period of about 1 day always applies, even with a 0 day configuration. It is folded into any longer grace period you set (a 7 day window means 7 total days, not 7 + 1).
  • Client side Purchase objects look identical in grace period and in a healthy renewal: isAutoRenewing = true, purchaseState == PURCHASED. You cannot detect grace period from queryPurchasesAsync(). Source of truth is the server side RTDN plus SubscriptionPurchaseV2.subscriptionState.
  • Grace period expiryTime points to the end of the grace window, not the original renewal date.
  • On recovery from account hold, Google moves the billing date to the recovery date; recovery during grace period keeps the original renewal date. Persist the new expiryTime from SubscriptionPurchaseV2 either way; cached pre failure dates will be wrong.
  • If you disable account hold, the subscription cancels immediately after grace period ends. Google's default enables both, with account hold = 60 days minus the grace period.

Phase 2: Plan the dunning policy

Decide these rules before you touch code. The rest of the skill is mechanical once this is set.

Stage to action mapping

StageEntitlementPrimary UISecondary channelsUrgency
Silent grace periodKeepnone (you do not see the RTDN)nonen/a
Grace periodKeepDismissible banner on main screenPush on day 0, email by day 3, optional showInAppMessages(TRANSACTIONAL) at natural launch pointsSoft, informational
Account holdRevokeFull screen account hold screen with single CTAPush on transition, email midway through holdHigh, blocking
RecoveredRestoreOptional toast or inline confirmationOptional confirmation emailn/a
Canceled after holdGoneResubscribe screenFinal email with resubscribe linkn/a

Messaging cadence during recovery

  • Day 0 of grace period: push notification immediately on SUBSCRIPTION_IN_GRACE_PERIOD plus banner in app.
  • Day 3 of grace period: email reminder with deep link to payment update.
  • Transition to account hold: push notification plus switch app UI to full screen hold screen. Revoke entitlement in the same transaction that flips the flag.
  • Midway through account hold: second email. Increase urgency wording.
  • On SUBSCRIPTION_RENEWED (grace) or SUBSCRIPTION_RECOVERED (hold): clear the relevant flag, restore entitlement if it was revoked, persist the new expiryTime, optional confirmation message.

Rules you should codify

  1. Never revoke during grace period. That is Google's guideline and the main retention lever.
  2. Always revoke on SUBSCRIPTION_ON_HOLD. Do not wait for the user to open the app.
  3. Treat the server flag, not Purchase.isAutoRenewing, as the source of truth for recovery state.
  4. On SUBSCRIPTION_RENEWED (grace) or SUBSCRIPTION_RECOVERED (hold), overwrite the cached renewal date with the new expiryTime.
  5. When changing grace or account hold durations, extend rather than shorten. Shortening does not affect subscribers already in grace, but it lowers recovery for every later payment failure. If you must shorten, monitor SUBSCRIPTION_ON_HOLD and SUBSCRIPTION_CANCELED volume after the change.

Phase 3: Execute

3.1 Backend: handle the four transition RTDNs

For each RTDN, look up the purchase token, fetch SubscriptionPurchaseV2 from the Google Play Developer API, confirm the state, then flip flags.

SUBSCRIPTION_IN_GRACE_PERIOD:

  1. Confirm subscriptionState == SUBSCRIPTION_STATE_IN_GRACE_PERIOD.
  2. Set gracePeriod = true on the user record. Keep entitlement active.
  3. Trigger push notification and queue the day 3 email.

SUBSCRIPTION_ON_HOLD:

  1. Confirm subscriptionState == SUBSCRIPTION_STATE_ON_HOLD.
  2. Set onHold = true. Revoke the entitlement now.
  3. Trigger push notification. Queue the midway hold email.

SUBSCRIPTION_RENEWED while gracePeriod == true (recovery during grace period; renewal date unchanged):

  1. Confirm subscriptionState == SUBSCRIPTION_STATE_ACTIVE.
  2. Clear gracePeriod on the user record. Entitlement was never revoked.
  3. Persist the new expiryTime. Optional confirmation message.

SUBSCRIPTION_RECOVERED (recovery from account hold, or resume from pause):

kotlin
// Server side handler
fun handleSubscriptionRecovered(token: String, pkg: String) {
    val sub = playApi.getSubscriptionV2(pkg, token)
    if (sub.subscriptionState != "SUBSCRIPTION_STATE_ACTIVE") return
    val rec = db.findByPurchaseToken(token) ?: return
    rec.status = "ACTIVE"
    rec.gracePeriod = false
    rec.onHold = false
    rec.renewalDate = sub.lineItems.firstOrNull()?.expiryTime
    db.update(rec)
}

After account hold expires without recovery, you get SUBSCRIPTION_CANCELED (3), then SUBSCRIPTION_EXPIRED (13). Treat it like any cancellation: revoke, update, optional resubscribe email.

3.2 Client: drive UI from server flags

Let a single function branch on the server reported status. Do not try to derive this from queryPurchasesAsync(): by default it omits subscriptions in account hold. On PBL 8.1+ you can query with QueryPurchasesParams.newBuilder().setProductType(ProductType.SUBS).includeSuspendedSubscriptions(true).build(); a purchase with isSuspended == true is on hold or paused, so do not grant access and deep link to the subscriptions center instead.

kotlin
// PBL 9.x
fun handleSubscriptionState(status: SubscriptionStatus) {
    when {
        status.isOnHold -> {
            revokeEntitlement()
            showAccountHoldScreen()
        }
        status.isInGracePeriod -> {
            // keep access, show dismissible banner
            showGracePeriodBanner()
        }
        status.isActive -> grantEntitlement()
    }
}

3.3 Client: showInAppMessages() for payment issues

Call at natural moments (app launch, entering a subscription gated feature, or when server flags indicate grace or hold). The TRANSACTIONAL category covers both grace period and account hold. If there is nothing to show, the call returns NO_ACTION_NEEDED.

kotlin
// PBL 9.x
fun showPaymentRecovery(activity: Activity) {
    val params = InAppMessageParams.newBuilder()
        .addInAppMessageCategoryToShow(
            InAppMessageParams
                .InAppMessageCategoryId.TRANSACTIONAL
        ).build()
    billingClient.showInAppMessages(activity, params) { r ->
        if (r.responseCode ==
            InAppMessageResult.InAppMessageResponseCode
                .SUBSCRIPTION_STATUS_UPDATED
        ) refreshSubscriptionStatus()
    }
}

On SUBSCRIPTION_STATUS_UPDATED, re sync with your backend. Google has confirmed the payment was fixed inside the dialog, but your server flag is still stale until the SUBSCRIPTION_RENEWED (grace) or SUBSCRIPTION_RECOVERED (hold) RTDN lands; send r.purchaseToken to your backend to re fetch now.

3.4 Deep link to Play Store subscription management

Use this as the CTA target from banners, the hold screen, and notifications.

kotlin
// PBL 9.x
fun openSubscriptionManagement(ctx: Context, pkg: String, productId: String?) {
    val base = "https://play.google.com/store/account/subscriptions"
    val uri = Uri.parse(
        if (productId != null) "$base?sku=$productId&package=$pkg" else base
    )
    ctx.startActivity(Intent(Intent.ACTION_VIEW, uri))
}

3.5 Verification checklist

  • Grace period path: trigger a test renewal failure, confirm SUBSCRIPTION_IN_GRACE_PERIOD arrives, verify entitlement stays on and the banner renders.
  • Hold path: wait for grace to expire, confirm SUBSCRIPTION_ON_HOLD arrives, verify entitlement is revoked and the hold screen blocks premium features.
  • Recovery path: fix the payment method, confirm SUBSCRIPTION_RENEWED arrives if recovering from grace or SUBSCRIPTION_RECOVERED if recovering from hold, verify flags clear, entitlement restores, and renewalDate equals the new expiryTime from SubscriptionPurchaseV2.
  • Terminal path: let account hold expire, confirm SUBSCRIPTION_CANCELED (3), then SUBSCRIPTION_EXPIRED (13) arrive, verify the resubscribe UI appears.
  • Silent window: confirm a fresh renewal failure does not fire SUBSCRIPTION_IN_GRACE_PERIOD immediately; the silent ~1 day must pass first.

References

Preguntas frecuentes

¿Qué hace la habilidad de IA Payment Recovery?

Use this skill when handling failed subscription renewals on Google Play. Covers Grace Period (user keeps access), Account Hold (access revoked), the RTDN signals that move between stages, and the in app messaging required to drive recovery.

¿Por qué usar Payment Recovery en TypingMind?

Porque la instalas una vez y la usas con cualquier modelo. Payment Recovery está escrita en Markdown, no en código específico de un proveedor, por lo que la misma habilidad funciona con GPT-5, Claude, Gemini, Grok o un modelo local, y puedes cambiar de modelo en mitad del chat sin que deje de funcionar. TypingMind utiliza tus propias claves API, de modo que pagas directamente a los proveedores en lugar de pagar una suscripción por puesto, y tus habilidades y chats permanecen en tu propio almacenamiento.

¿Cómo instalo Payment Recovery en TypingMind?

Abre Plugins → Habilidades → Instalar desde GitHub en TypingMind y pega https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/payment-recovery. TypingMind lee el archivo SKILL.md de esa carpeta e instala su contenido como una habilidad que puedes activar en cada chat.

¿Qué modelos de IA pueden usar Payment Recovery?

Cualquier modelo que conectes en TypingMind. Las habilidades de IA son instrucciones en Markdown, no código específico de un proveedor, por lo que GPT, Claude, Gemini, Grok y los modelos locales pueden cargar esta habilidad cuando una solicitud se corresponda con ella.

¿Con cuántos modelos de IA puedo usar Payment Recovery?

Con tantos como quieras. Siempre que un modelo admita habilidades, puedes usar Payment Recovery con él: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama y muchos más, todos en TypingMind con tus propias claves API.

¿Es gratuita la habilidad de IA Payment Recovery?

Sí. RevenueCat la ha publicado en GitHub bajo la licencia Apache-2.0. Solo pagas a tu proveedor de IA por los tokens que utilizas.

¿Qué son las habilidades de IA?

Una habilidad de IA es un conjunto de instrucciones reutilizables que enseña a un modelo de IA a realizar una tarea concreta. Sigue el formato abierto Agent Skills: un archivo SKILL.md con un nombre y una descripción, además de los scripts, plantillas o archivos de referencia que pueda necesitar el modelo. El modelo solo lee las instrucciones cuando tu solicitud se corresponde con la habilidad, por lo que una habilidad instalada no supone ningún coste hasta que se utiliza.

¿En qué se diferencian las habilidades de IA de los plugins o los servidores MCP?

Un plugin o un servidor MCP proporciona al modelo nuevas herramientas que puede invocar: código que se ejecuta en algún lugar y devuelve un resultado. En cambio, una habilidad de IA aporta conocimientos y procedimientos al modelo: cómo abordar una tarea, qué pasos seguir y qué se considera un buen resultado. Las habilidades son instrucciones en Markdown, por lo que no necesitan servidor, clave API ni entorno de ejecución, y funcionan con cualquier modelo.

Ver el directorio

Crea ya tu propio espacio de trabajo con IA

Suscríbete a nuestro boletín para recibir avisos sobre nuevas funciones y próximos sorteos 👇