Logo di Billing Response Codes

Billing Response Codes

Organizzazione
RevenueCat
billing-response-codes

Use this skill as a reference lookup for every Play Billing Library BillingResponseCode and sub response code, with description, category, and handling guidance. Grounded in PBL 9.x.

Panoramica

Pubblicato daRevenueCat
Repositoryplay-billing-skills
Nome della skillbilling-response-codes
Stelle
58
Fork
0
File inclusi
Solo istruzioni
LicenzaApache-2.0
Link
  • Istruzioni in Markdown

    Un file SKILL.md che il modello carica quando serve, consumando token solo quando una richiesta è effettivamente pertinente.

  • Funziona con qualsiasi LLM

    Le skill IA sono in semplice Markdown, non in codice specifico di un fornitore, quindi funzionano con GPT, Claude, Gemini, Grok o un modello locale.

  • Tutto nelle istruzioni

    Tutto ciò che serve al modello è nelle istruzioni: nessun file aggiuntivo da sincronizzare.

  • Open source

    Pubblicata da RevenueCat su GitHub. Leggi i sorgenti prima di installarla.

Installazione

Installa la skill IA Billing Response Codes in TypingMind per usarla con qualsiasi LLM, oppure copiala in un altro agente in grado di leggere SKILL.md.

1

Installa in TypingMind

TypingMind installa una skill direttamente dalla sua cartella GitHub: legge SKILL.md, raccoglie i file delle risorse e salva il risultato in locale.

  1. Apri l'app e vai su Plugin → Skill.
  2. Scegli "Installa da GitHub".
  3. Incolla l'URL della cartella della skill riportato qui sotto e conferma.
    https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/billing-response-codes
  4. Attiva la skill in ogni chat in cui vuoi averla a disposizione.
Plugin → Skill → Aggiungi skill → Da URL GitHub, poi incolla l'URL della cartella e premi Continua.
2

Installa in un altro agente

Qualsiasi agente che legge il formato Agent Skills può usare questa skill: copia la cartella della skill nella directory delle skill di quell'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/billing-response-codes .claude/skills/billing-response-codes
Dopo la copia, riavvia Claude Code per caricare la nuova skill.

Usala in TypingMind

Attiva Billing Response Codes in qualsiasi chat di TypingMind e al resto pensa il modello. Il nome e la descrizione della skill sono nel prompt di sistema e, non appena arriva una richiesta pertinente, il modello carica da solo le istruzioni complete: non devi mai richiamarla manualmente e non consuma token finché non viene effettivamente usata.

Il modello carica automaticamente Billing Response Codes non appena riceve una richiesta pertinente.

Funziona con qualsiasi modello IA

Le skill IA sono semplici istruzioni in Markdown, non codice specifico di un fornitore, quindi Billing Response Codes non è vincolata al modello per cui è stata scritta. Installala una sola volta in TypingMind e usala con GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama o un modello locale che esegui tu, sempre con le tue chiavi API.

  • Caricata solo quando serve

    Il prompt di sistema contiene solo il nome e la descrizione. Le istruzioni vengono recuperate alla prima richiesta pertinente, quindi una skill inutilizzata non costa nulla.

  • Cambia modello durante la chat

    Poiché la skill è composta da istruzioni e non da codice, continua a funzionare anche se cambi modello: il nuovo modello legge lo stesso file SKILL.md.

Istruzioni della skill

Questo è il contenuto di SKILL.md che il modello carica. Leggilo prima dell'installazione: una skill è un insieme di istruzioni che il tuo modello seguirà.

Billing Response Codes

Phase 0: Intent

Use this skill when you need to look up the meaning, category, or handling strategy for a value returned by BillingResult.getResponseCode() or BillingResult.getOnPurchasesUpdatedSubResponseCode() in the Play Billing Library. This reference covers:

  • All BillingResponseCode constants defined in PBL 9.x (the constant set is unchanged from PBL 8.x; v9 added no codes and removed none).
  • All OnPurchasesUpdatedSubResponseCode constants added in PBL 8.0.
  • Retry eligibility for each code.
  • The recommended response strategy per code.
  • A decision tree that maps any received code to an action.

Use this skill to answer questions like "what does response code 7 mean", "should I retry on SERVICE_UNAVAILABLE", or "how do I handle ITEM_ALREADY_OWNED".

Do not use this skill to author new integration code from scratch. Use the launch or purchase flow skills for that. This skill is a lookup table.

Phase 1: Locate

The authoritative copy of the tables and decision tree lives in the full appendix on revenuecat.com. When a question asks for:

  • The literal integer value of a code, see "Response Codes".
  • Sub response codes introduced in PBL 8.0, see "Sub Response Codes (PBL 8.0+)".
  • The retry strategy for a code, see "Retry Implementation Summary".
  • A full flow from received code to action, see "Error Handling Decision Tree".

The tables reproduced below in Phase 2 mirror the appendix verbatim so you can answer most lookups without opening the chapter.

Phase 2: Reference Tables

BillingResponseCode values

CodeValueRetriableDescriptionRecommended Strategy
OK0N/AOperation succeededProcess the result normally.
USER_CANCELED1NoUser dismissed the purchase dialog. Since PBL 8.3 also returned when the user left to pay in an external app (e-wallet) and did not return (debug message BILLING_ACTIVITY_PAUSED; ERROR before 8.3).No action needed. Do not show an error message.
SERVICE_UNAVAILABLE2YesGoogle Play service is temporarily unavailableRetry with exponential backoff (2s base, 2x factor, max 3 attempts).
BILLING_UNAVAILABLE3No (auto)Billing is unavailable on this device or for this userDo not auto retry. Check Play Store version and user account. Let the user try again manually. PBL 9 (with androidx.core 1.9+) also routes a system blocked Play Store here with a "Play Store is blocked" debugMessage, where PBL 8 returned ERROR.
ITEM_UNAVAILABLE4NoThe requested product is not available for purchaseRefresh product details with queryProductDetailsAsync(). The product may have been deactivated.
DEVELOPER_ERROR5NoInvalid arguments passed to the APIFix your code. Check product IDs, offer tokens, and parameter construction. This is a programming error.
ERROR6YesAn internal Google Play error occurredRetry with exponential backoff. If persistent, report to Google.
ITEM_ALREADY_OWNED7NoThe user already owns this item (a subscription, a non consumable, or a consumable that has not been consumed yet)Call queryPurchasesAsync() to refresh your local purchase cache. The user may have purchased on another device.
ITEM_NOT_OWNED8NoAttempted to consume or acknowledge an item the user does not ownCall queryPurchasesAsync() to refresh your local purchase cache. The purchase may have been refunded.
NETWORK_ERROR12YesA network error occurred during the operationRetry with a short delay (1-2 seconds). Check device connectivity.
SERVICE_DISCONNECTED-1YesThe BillingClient is not connected to the Play Store billing serviceWith enableAutoServiceReconnection() (opt in, PBL 8+) the library reconnects before the next call; if you still get this code, retry the call (simple retry in session, exponential backoff in the background). Without it, call startConnection() and retry.
FEATURE_NOT_SUPPORTED-2NoThe requested feature is not supported on this device or Play Store versionCheck isFeatureSupported() before calling feature specific APIs. Provide fallback behavior.
SERVICE_TIMEOUT-3Yes (Deprecated)The request timed outDeprecated in recent PBL versions. Treat as SERVICE_UNAVAILABLE and retry with backoff.

Sub Response Codes (PBL 8.0+)

Sub response codes provide more granular information about why a purchase failed. They are only available in the PurchasesUpdatedListener.onPurchasesUpdated() callback, retrieved via BillingResult.getOnPurchasesUpdatedSubResponseCode().

Sub Response CodeDescriptionWhen It AppearsRecommended Action
NO_APPLICABLE_SUB_RESPONSE_CODENo specific sub response appliesDefault value for most responsesHandle based on the main response code only.
PAYMENT_DECLINED_DUE_TO_INSUFFICIENT_FUNDSUser's available funds are less than the purchase priceWhen the main response indicates a payment failureShow a message suggesting the user check their payment method balance.
USER_INELIGIBLEUser does not meet eligibility requirements for an offerWhen the user attempts to use an offer they are not eligible forShow standard pricing without the offer. Check your offer eligibility logic.

Accessing sub response codes

kotlin
val listener = PurchasesUpdatedListener { billingResult, purchases ->
    if (billingResult.responseCode != BillingResponseCode.OK) {
        val subCode = billingResult.onPurchasesUpdatedSubResponseCode
        when (subCode) {
            OnPurchasesUpdatedSubResponseCode.PAYMENT_DECLINED_DUE_TO_INSUFFICIENT_FUNDS ->
                showInsufficientFundsMessage()
            OnPurchasesUpdatedSubResponseCode.USER_INELIGIBLE ->
                showStandardPricing()
            else -> handleGeneralError(billingResult)
        }
    }
}

Retry strategy summary

StrategyBase DelayFactorMax AttemptsUse For
Simple retry1-2 seconds1x (fixed)3NETWORK_ERROR
Exponential backoff2 seconds2x3SERVICE_UNAVAILABLE, ERROR, SERVICE_TIMEOUT
Reconnect, then retryLibrary (auto reconnection) or startConnection()Simple in session, backoff in background3SERVICE_DISCONNECTED
User initiatedN/AN/AN/ABILLING_UNAVAILABLE
No retryN/AN/AN/AUSER_CANCELED, DEVELOPER_ERROR, FEATURE_NOT_SUPPORTED

Phase 3: Handling Guidance

When you receive a BillingResult, walk it through this decision tree:

  1. Is responseCode equal to OK?

    • Yes: process the result. Done.
    • No: continue.
  2. Is responseCode equal to USER_CANCELED?

    • Yes: do nothing. The user chose to cancel. Done.
    • No: continue.
  3. Is the error retriable? (SERVICE_UNAVAILABLE, ERROR, NETWORK_ERROR, SERVICE_DISCONNECTED, SERVICE_TIMEOUT)

    • Yes: retry with the matching strategy from the retry summary table. Simple retry for NETWORK_ERROR, exponential backoff for service errors. If all retries fail, show an error message.
    • No: continue.
  4. Is it a cache sync issue? (ITEM_ALREADY_OWNED, ITEM_NOT_OWNED)

    • Yes: call queryPurchasesAsync() to refresh your purchase cache. Update UI accordingly.
    • No: continue.
  5. Is it a product issue? (ITEM_UNAVAILABLE)

    • Yes: refresh product details. The product may no longer be available.
    • No: continue.
  6. Is it a device or environment issue? (BILLING_UNAVAILABLE, FEATURE_NOT_SUPPORTED)

    • Yes: show a user facing message. Do not retry automatically. Let the user initiate a retry.
    • No: continue.
  7. Is it a developer error? (DEVELOPER_ERROR)

    • Yes: log the error with full details. Fix the API usage in your code. This should not happen in production.

Category quick reference

Group each code into one of six buckets so you can route it to the right handler:

  • Success: OK.
  • User intent: USER_CANCELED.
  • Transient service or network: SERVICE_UNAVAILABLE, ERROR, NETWORK_ERROR, SERVICE_DISCONNECTED, SERVICE_TIMEOUT.
  • Cache sync: ITEM_ALREADY_OWNED, ITEM_NOT_OWNED.
  • Catalog or product: ITEM_UNAVAILABLE.
  • Environment or configuration: BILLING_UNAVAILABLE, FEATURE_NOT_SUPPORTED.
  • Programming error: DEVELOPER_ERROR.

Checking a code with when

kotlin
fun classify(code: Int): Category = when (code) {
    BillingResponseCode.OK -> Category.SUCCESS
    BillingResponseCode.USER_CANCELED -> Category.USER_INTENT
    BillingResponseCode.SERVICE_UNAVAILABLE,
    BillingResponseCode.ERROR,
    BillingResponseCode.NETWORK_ERROR,
    BillingResponseCode.SERVICE_DISCONNECTED,
    BillingResponseCode.SERVICE_TIMEOUT -> Category.TRANSIENT
    BillingResponseCode.ITEM_ALREADY_OWNED,
    BillingResponseCode.ITEM_NOT_OWNED -> Category.CACHE_SYNC
    BillingResponseCode.ITEM_UNAVAILABLE -> Category.CATALOG
    BillingResponseCode.BILLING_UNAVAILABLE,
    BillingResponseCode.FEATURE_NOT_SUPPORTED -> Category.ENVIRONMENT
    BillingResponseCode.DEVELOPER_ERROR -> Category.PROGRAMMING
    else -> Category.UNKNOWN
}

References

Domande frequenti

Cosa fa la skill IA Billing Response Codes?

Use this skill as a reference lookup for every Play Billing Library BillingResponseCode and sub response code, with description, category, and handling guidance. Grounded in PBL 9.x.

Perché usare Billing Response Codes su TypingMind?

Perché la installi una volta e la usi con qualsiasi modello. Billing Response Codes è scritta in semplice Markdown anziché in codice specifico di un fornitore, quindi la stessa skill funziona con GPT-5, Claude, Gemini, Grok o un modello locale, e puoi cambiare modello durante la chat senza che la skill smetta di funzionare. TypingMind usa le tue chiavi API, quindi paghi direttamente i fornitori anziché un abbonamento per posto utente, e le tue skill e chat restano nel tuo spazio di archiviazione.

Come installo Billing Response Codes in TypingMind?

Apri Plugin → Skill → Installa da GitHub in TypingMind e incolla https://github.com/RevenueCat/play-billing-skills/tree/main/google-play/billing-response-codes. TypingMind legge il file SKILL.md e installa la skill, che puoi abilitare per ogni singola chat.

Quali modelli IA possono usare Billing Response Codes?

Qualsiasi modello che colleghi a TypingMind. Le skill IA sono semplici istruzioni in Markdown anziché codice specifico di un fornitore, quindi GPT, Claude, Gemini, Grok e i modelli locali possono tutti caricare questa skill quando una richiesta corrisponde al suo scopo.

Quanti modelli IA posso usare con Billing Response Codes?

Quanti ne vuoi. Se un modello supporta le skill, puoi usarlo con Billing Response Codes: GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama e molti altri, tutti su TypingMind con le tue chiavi API.

La skill IA Billing Response Codes è gratuita?

Sì. È pubblicata su GitHub da RevenueCat con licenza Apache-2.0. Paghi solo il tuo fornitore IA per i token che usi.

Cosa sono le skill IA?

Una skill IA è un pacchetto di istruzioni riutilizzabili che insegna a un modello IA come svolgere un'attività specifica. Segue il formato aperto Agent Skills: un file SKILL.md con un nome e una descrizione, più eventuali script, template o file di riferimento di cui il modello potrebbe aver bisogno. Il modello legge le istruzioni solo quando la tua richiesta corrisponde alla skill, quindi una skill installata non comporta costi finché non viene usata.

In cosa si differenziano le skill IA dai plugin o dai server MCP?

Un plugin o un server MCP fornisce a un modello nuovi strumenti da richiamare: codice che viene eseguito da qualche parte e restituisce un risultato. Una skill IA, invece, fornisce al modello conoscenze e procedure: come affrontare un'attività, quali passaggi seguire e quali caratteristiche deve avere un buon output. Le skill sono semplici istruzioni in Markdown, quindi non richiedono server, chiavi API né ambienti di esecuzione e funzionano con qualsiasi modello.

Elenco completo

Crea subito il tuo spazio di lavoro AI

Iscriviti alla nostra newsletter per ricevere aggiornamenti sulle nuove funzionalità e sulle prossime iniziative a premi 👇