Skip to main content

Crate revenuecat

Crate revenuecat 

Source
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
ConfigurationBuilder
CustomerInfo
Mirrors CustomerInfo: the server-computed subscription state for one app user. Entitlement activeness is evaluated against the server’s request_date (not the device clock), like the official SDKs.
EntitlementInfo
Mirrors EntitlementInfo from the official SDKs.
EntitlementInfos
Mirrors EntitlementInfos.
Error
Mirrors PurchasesError: a stable code plus human-readable context.
NonSubscriptionTransaction
A non-subscription (one-time) purchase.
Offering
Mirrors Offering.
OfferingResponse
Offerings
Mirrors Offerings.
OfferingsResponse
Package
Mirrors Package: a product wrapped in offering context.
PackageResponse
Paywall
A dashboard-configured paywall (v1 templates). Copy is resolved per locale from Paywall::localized_strings, falling back to the config defaults.
PaywallColors
PaywallColorsByMode
Light/dark color sets. Colors are hex strings (#RRGGBB / #RRGGBBAA).
PaywallComponents
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.
PaywallConfig
PaywallFeature
PaywallImages
PaywallLocalizedStrings
The subset of copy that can be localized. strings_for returns this with config defaults filled in.
PlacementsResponse
PlatformProductId
Store-specific product identity posted as platform_product_ids in the current RevenueCat receipt payload.
PresentedOfferingContext
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"}).
PricingPhase
ProductsResponse
PurchaseResult
Result of a successful purchase.
Purchases
Cheaply cloneable handle to a configured SDK instance.
ReceiptRequest
Body for POST /v1/receipts. Field names match purchases-android’s Backend.postReceiptData; the endpoint rejects unknown top-level keys, so only documented fields are ever emitted and nulls are filtered out.
SimulatedStoreBilling
StoreProduct
Store-agnostic product, mirroring StoreProduct in the official SDKs.
StoreProductQuery
A store product lookup from an Offering package.
StoreProductResult
A localized store product matched to an optional Offering base plan.
StorePurchase
A transaction plus the exact store product options used for its receipt.
StorePurchaseOption
Store selection requested by an Offering package.
StoreReceiptContext
Receipt attribution captured before an SDK-originated store purchase.
StoreTransaction
SubscriptionInfo
One subscription entry from subscriber.subscriptions, keyed by product id.
TargetingResponse
VirtualCurrencies
VirtualCurrency
WebBillingProduct
WebPurchaseRedemption
An opaque redemption token parsed from a RevenueCat deep link.

Enums§

ApiKeyKind
Store kind encoded in the API key prefix, mirroring APIKeyValidator (Android) and Configuration.validate(apiKey:) (iOS).
CacheFetchPolicy
Mirrors CacheFetchPolicy from purchases-android.
EntitlementVerificationMode
Trusted Entitlements response-signature verification mode, mirroring EntitlementVerificationMode in the official SDKs.
ErrorCode
Mirrors the cross-platform PurchasesErrorCode enum shared by purchases-ios / purchases-android / purchases-js.
OwnershipType
PackageType
Mirrors PackageType: well-known $rc_* identifiers get a type.
PeriodType
Platform
Value sent in the X-Platform header. The RevenueCat backend uses this to interpret fetch_token in POST /v1/receipts.
ProductType
RedeemResult
Mirrors the RedeemWebPurchaseListener.Result sealed class.
Store
Store that processed a purchase. String values follow the cross-platform Store enum (12 stores) in purchases-ios EntitlementInfo.
VerificationResult
Trusted Entitlements verification state stamped by the configured response verifier. NotRequested is 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).

Traits§

StoreBilling

Functions§

generate_anonymous_id
is_anonymous_id

Type Aliases§

Result