Expand description
§revenuecat-rs
RevenueCat SDK for Rust, implemented as an independent direct port of behavior in the official purchases-ios, purchases-android, and purchases-js SDKs (all MIT). Compatibility is tracked per feature across the backend wire contract and native purchase lifecycle; this crate does not link those SDKs or claim parity with their UI surfaces.
use revenuecat::{CacheFetchPolicy, Configuration, Purchases};
let purchases = Purchases::configure(
Configuration::builder("test_your_api_key")
.app_user_id("my-user")
.build()?,
)?;
let offerings = purchases.get_offerings().await?;
if let Some(package) = offerings.current().and_then(|o| o.monthly()) {
let result = purchases.purchase_package(package).await?;
assert!(result.customer_info.entitlements.is_active("pro"));
}
let info = purchases.get_customer_info(CacheFetchPolicy::default()).await?;
println!("active: {:?}", info.active_subscriptions());With a test_ (Test Store) API key the built-in SimulatedStoreBilling
is used and no native store is required — purchases are simulated
end-to-end against the backend, which is how the Tauri demo and the
integration tests run on desktop. For real stores, implement
StoreBilling over StoreKit / Play Billing (e.g. from a Tauri mobile
plugin) and pass it via ConfigurationBuilder::store_billing.
Structs§
- Configuration
- Configuration
Builder - Customer
Info - Mirrors
CustomerInfo: the server-computed subscription state for one app user. Entitlement activeness is evaluated against the server’srequest_date(not the device clock), like the official SDKs. - Entitlement
Info - Mirrors
EntitlementInfofrom the official SDKs. - Entitlement
Infos - Mirrors
EntitlementInfos. - Error
- Mirrors
PurchasesError: a stable code plus human-readable context. - NonSubscription
Transaction - A non-subscription (one-time) purchase.
- Offering
- Mirrors
Offering. - Offering
Response - Offerings
- Mirrors
Offerings. - Offerings
Response - Package
- Mirrors
Package: a product wrapped in offering context. - Package
Response - Paywall
- A dashboard-configured paywall (v1 templates). Copy is resolved per locale
from
Paywall::localized_strings, falling back to the config defaults. - Paywall
Colors - Paywall
Colors ByMode - Light/dark color sets. Colors are hex strings (
#RRGGBB/#RRGGBBAA). - Paywall
Components - A v2 component-based paywall. The component tree is large and evolving, so it is exposed as raw JSON for the frontend to interpret; the envelope fields a renderer needs are typed.
- Paywall
Config - Paywall
Feature - Paywall
Images - Paywall
Localized Strings - The subset of copy that can be localized.
strings_forreturns this with config defaults filled in. - Placements
Response - Platform
Product Id - Store-specific product identity posted as
platform_product_idsin the current RevenueCat receipt payload. - Presented
Offering Context - Where a purchase was initiated from; posted (flattened) with the receipt so charts/experiments attribute revenue to the right offering.
- Price
- Price in micro-units, exactly as the backend sends it
(
{"amount_micros": 3000000, "currency": "USD"}). - Pricing
Phase - Products
Response - Purchase
Result - Result of a successful purchase.
- Purchases
- Cheaply cloneable handle to a configured SDK instance.
- Receipt
Request - Body for
POST /v1/receipts. Field names match purchases-android’sBackend.postReceiptData; the endpoint rejects unknown top-level keys, so only documented fields are ever emitted and nulls are filtered out. - Simulated
Store Billing - Store
Product - Store-agnostic product, mirroring
StoreProductin the official SDKs. - Store
Product Query - A store product lookup from an Offering package.
- Store
Product Result - A localized store product matched to an optional Offering base plan.
- Store
Purchase - A transaction plus the exact store product options used for its receipt.
- Store
Purchase Option - Store selection requested by an Offering package.
- Store
Receipt Context - Receipt attribution captured before an SDK-originated store purchase.
- Store
Transaction - Subscription
Info - One subscription entry from
subscriber.subscriptions, keyed by product id. - Targeting
Response - Virtual
Currencies - Virtual
Currency - WebBilling
Product - WebPurchase
Redemption - An opaque redemption token parsed from a RevenueCat deep link.
Enums§
- ApiKey
Kind - Store kind encoded in the API key prefix, mirroring
APIKeyValidator(Android) andConfiguration.validate(apiKey:)(iOS). - Cache
Fetch Policy - Mirrors
CacheFetchPolicyfrom purchases-android. - Entitlement
Verification Mode - Trusted Entitlements response-signature verification mode, mirroring
EntitlementVerificationModein the official SDKs. - Error
Code - Mirrors the cross-platform
PurchasesErrorCodeenum shared by purchases-ios / purchases-android / purchases-js. - Ownership
Type - Package
Type - Mirrors
PackageType: well-known$rc_*identifiers get a type. - Period
Type - Platform
- Value sent in the
X-Platformheader. The RevenueCat backend uses this to interpretfetch_tokeninPOST /v1/receipts. - Product
Type - Redeem
Result - Mirrors the
RedeemWebPurchaseListener.Resultsealed class. - Store
- Store that processed a purchase. String values follow the cross-platform
Storeenum (12 stores) in purchases-iosEntitlementInfo. - Verification
Result - Trusted Entitlements verification state stamped by the configured
response verifier.
NotRequestedis used only when verification is disabled; informational/enforced modes can produce the other states.
Constants§
- ANONYMOUS_
ID_ PREFIX - DEFAULT_
API_ BASE - MAX_
APP_ USER_ ID_ BYTES - Maximum UTF-8 byte length accepted for a non-anonymous App User ID.
- ROOT_
PUBLIC_ KEY_ B64 - RevenueCat’s production root Ed25519 public key
(
DefaultSignatureVerifier.DEFAULT_PUBLIC_KEY/Signing.publicKey).