Rc Payment Recovery

RevenueCat/ai-toolkit/revenuecat-play-billing/skills/rc-payment-recovery

作者 RevenueCatccfc038185ec457b2ac9077f3bbf1ba947a44dbbApache-2.0; see LICENSE收錄於 2026年10月9日更新於 2026年10月9日

Use this skill when handling failed renewals on Android with RevenueCat. Covers how Grace Period and Account Hold are reflected in CustomerInfo automatically, when to prompt the user, and how to trigger Google's in app messaging via showInAppMessages.

AI 產生的概覽

指導 Android 開發者處理 RevenueCat 訂閱續訂失敗,涵蓋寬限期、帳戶凍結與復原狀態。

功能
說明 Google Play 續訂失敗如何在 RevenueCat CustomerInfo 中呈現,涵蓋寬限期、帳戶凍結與復原三種狀態。介紹 billingIssueDetectedAt 與 isActive 兩個訊號、何時提示使用者,以及如何透過 showInAppMessagesIfNeeded 觸發 Google 應用程式內訊息。提供 Kotlin 程式碼片段,包括預設行為、手動觸發、自訂寬限期介面與開啟管理連結,並附上驗證步驟。
適用情境
適用於使用 RevenueCat 建置或偵錯 Android 訂閱流程、需要處理續訂失敗的情境。也適合在決定採用 Google 預設應用程式內訊息或自行建置帳務問題介面時參考。
執行需求
需要在 Android 應用程式中使用 RevenueCat Android SDK 與 Google Play Billing。此技能未附帶指令碼,僅包含說明與程式碼片段。後端 webhook 處理需要伺服器端點接收 BILLING_ISSUE 事件。

Payment Recovery

Failed renewals on Google Play move a subscription through two states: grace period (user keeps access while Google retries the card) and account hold (access revoked until the user fixes the payment method). With RevenueCat, both states land in CustomerInfo automatically, and Google's in app message shows by default.

Phase 1: Understand

Three things happen when a renewal fails:

StateAccessHow RevenueCat surfaces itUser sees
Grace periodRetainedentitlement.isActive == true and billingIssueDetectedAt != nullGoogle in app snackbar by default
Account holdRevokedentitlement.isActive == false and billingIssueDetectedAt != nullGoogle in app snackbar by default
RecoveredRetainedbillingIssueDetectedAt == nullNothing

Two signals matter in the SDK:

  • EntitlementInfo.billingIssueDetectedAt is non null from the moment Google reports a billing problem until the user resolves it.
  • EntitlementInfo.isActive tells you whether they still have access.

On the backend, a BILLING_ISSUE webhook fires once per transition. You do not decode RTDNs.

Phase 2: Plan

Before you write app code, decide what you actually need. Most apps need none.

Ask:

  1. Do you want the default Google in app message? If yes, do nothing. The SDK calls showInAppMessagesIfNeeded on BillingClient connect.
  2. Do you want your own banner or dialog? If yes, read billingIssueDetectedAt from CustomerInfo and branch on isActive.
  3. Do you want to gate the message to specific screens? If yes, disable the automatic call and invoke showInAppMessagesIfNeeded(activity) yourself.
  4. Do you need a server side flag (for example, to send a recovery email)? If yes, handle the BILLING_ISSUE webhook. No app code required.

If you only want the default behavior, stop here.

Phase 3: Execute

Default (recommended)

Leave automatic in app messages on. This is the default:

kotlin
PurchasesConfiguration.Builder(context, apiKey)    .showInAppMessagesAutomatically(true)    .build()

Manual trigger

Disable the automatic call and show the message from your chosen activity:

kotlin
PurchasesConfiguration.Builder(context, apiKey)    .showInAppMessagesAutomatically(false)    .build()
Purchases.sharedInstance.showInAppMessagesIfNeeded(activity)

Your own UI during grace period

Read the entitlement and branch on both flags:

kotlin
val entitlement = customerInfo.entitlements["pro_access"]when {    entitlement == null || !entitlement.isActive ->        showSubscribeScreen()    entitlement.billingIssueDetectedAt != null && entitlement.isActive ->        showGracePeriodWarning()    entitlement.billingIssueDetectedAt != null && !entitlement.isActive ->        showAccountHoldScreen()    else ->        showPremiumContent()}

Send the user to fix payment

CustomerInfo.managementURL points to the Google Play subscription page:

kotlin
customerInfo.managementURL?.let { url ->    startActivity(Intent(Intent.ACTION_VIEW, url))}

Phase 4: Verify

Test each transition:

  • Use a Google Play test card that declines renewals to push a subscription into grace period.
  • Confirm entitlement.billingIssueDetectedAt becomes non null and isActive stays true.
  • Wait for account hold and confirm isActive flips to false while billingIssueDetectedAt remains non null.
  • Update the payment method and confirm billingIssueDetectedAt returns to null.
  • On backend, confirm a BILLING_ISSUE webhook fires on the first transition.

References

來源與署名

來源:RevenueCat/ai-toolkit位於revenuecat-play-billing/skills/rc-payment-recovery提交ccfc038

授權條款: Apache-2.0; see LICENSE

內容歸原作者所有。SourceWeft 從公開儲存庫中收錄這些內容。

檢舉或申請下架