Rc One Time Products

RevenueCat/ai-toolkit/revenuecat-play-billing/skills/rc-one-time-products

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

Use this skill when selling one time products on Android with RevenueCat. Covers fetching offerings, running awaitPurchase on a non subscription package, and relying on the SDK to acknowledge or consume automatically.

AI 產生的概覽

指導 Android 開發者使用 RevenueCat SDK 銷售一次性產品,涵蓋從取得產品清單到處理購買結果的完整流程。

功能
此技能提供一套分階段的指南,用於在 Android 上使用 RevenueCat 實作一次性(非訂閱)產品購買。內容涵蓋:界定可消耗與不可消耗產品、在 Google Play Console 和 RevenueCat 後台設定產品、取得產品清單、透過 awaitPurchase 發起購買,以及透過權益或非訂閱交易記錄讀取存取權限。此外也說明如何處理取消、待處理付款和錯誤,以及如何透過 CustomerInfo 和 webhook 驗證購買。
適用情境
當需要在已使用或準備採用 RevenueCat SDK 的 Android 應用程式中整合一次性產品購買時,可使用此技能。它適合需要了解購買流程、權益檢查和邊界情況處理,而不想直接撰寫 BillingClient 程式的開發者。
執行需求
需要一個使用 RevenueCat SDK 的 Android 應用程式專案、一個設定了一次性產品的 Google Play Console 帳號,以及一個擁有 API 金鑰和已設定產品/套件的 RevenueCat 後台帳號。不包含指令碼,僅為說明文件。

One Time Products with RevenueCat

Sell one time products on Android without writing BillingClient glue. The RevenueCat SDK fetches products, launches the purchase, verifies the receipt, and acknowledges or consumes the token for you.

Phase 1: Scope

Answer these before touching code.

QuestionDecision
Is the product consumable or non consumable?Mark consumables in the RevenueCat dashboard so the SDK calls consumeAsync for you.
Do you read access through entitlements or transactions?Prefer entitlements so access logic stays decoupled from product IDs.
Do you need server notification of the purchase?Use RevenueCat webhooks. The INITIAL_PURCHASE event fires for every new non subscription purchase.

Do not call BillingClient.queryProductDetailsAsync, acknowledgePurchase, or consumeAsync yourself once RevenueCat is integrated. The SDK owns the BillingClient instance.

Phase 2: Prepare

  • Configure the product in Google Play Console as a one time product.
  • In the RevenueCat dashboard, attach the product to an offering and package, and flag it as consumable if it should be consumed on purchase.
  • Confirm Purchases.configure runs once on app start with your Android API key and the current App User ID.

Phase 3: Execute

Fetch offerings, launch the purchase, then read the result off CustomerInfo.

kotlin
val offerings = Purchases.sharedInstance.awaitOfferings()val pkg = offerings.current?.availablePackages?.first() ?: return

Launch the purchase with awaitPurchase. It suspends until the RevenueCat backend verifies the token.

kotlin
val result = Purchases.sharedInstance.awaitPurchase(    PurchaseParams.Builder(activity, pkg).build())val info = result.customerInfo

Read access through entitlements, or fall back to the non subscription transactions list.

kotlin
val hasAccess = info.entitlements["lifetime_access"]?.isActive == trueval owned = info.nonSubscriptionTransactions    .any { it.productIdentifier == "lifetime_product_id" }

The SDK acknowledges non consumables and consumes consumables automatically once the backend verifies the purchase. You do not call acknowledgePurchase or consumeAsync.

Phase 4: Handle Edge Cases

Wrap awaitPurchase to separate cancellation, pending payments, and real errors.

kotlin
try { /* awaitPurchase */ } catch (e: PurchasesTransactionException) {    when {        e.error.code == PurchasesErrorCode.PaymentPendingError -> showPending()        e.userCancelled -> Unit        else -> showError(e.error.message)    }}
OutcomeSDK signalAction
SuccessawaitPurchase returns with updated CustomerInfoGrant access from entitlements or nonSubscriptionTransactions.
User cancelPurchasesTransactionException, userCancelled == trueSwallow silently.
Pending paymentPurchasesTransactionException, PaymentPendingErrorShow a pending message. The SDK updates the entitlement later through UpdatedCustomerInfoListener.
Other errorPurchasesTransactionException, other codesSurface e.error.message to you.

Phase 5: Verify

  • Trust result.customerInfo from awaitPurchase. Do not grant access from optimistic local state.
  • Pending purchases do not grant entitlements. Register an UpdatedCustomerInfoListener so you react when the payment completes.
  • For server side provisioning, subscribe to the RevenueCat INITIAL_PURCHASE webhook. Do not reimplement Google Play Developer API verification.

References

來源與署名

來源:RevenueCat/ai-toolkit位於revenuecat-play-billing/skills/rc-one-time-products提交ccfc038

授權條款: Apache-2.0; see LICENSE

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

檢舉或申請下架