Search by

whilesmart / entitlements-revenuecat

whilesmart

RevenueCat adapter for whilesmart/eloquent-entitlements: app store and Play purchases grant the owner's plan, kept in sync from RevenueCat webhooks and its REST API v2.

Package info

github.com/whilesmartphp/entitlements-revenuecat

pkg:composer/whilesmart/entitlements-revenuecat

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

0.1.0 2026-11-29 18:25 UTC

This package is auto-updated.

Last update: 2026-11-29 18:56:18 UTC


README

A RevenueCat adapter for whilesmart/eloquent-entitlements. App Store and Play purchases made through RevenueCat grant the owner's plan, so every entitlement check treats a store subscriber like any other paying owner.

It sits beside other billing providers such as whilesmart/entitlements-cashier. Each provider keeps its own entitlement subscription, and the owner is entitled while any of them is.

Install

composer require whilesmart/entitlements-revenuecat
php artisan migrate
REVENUECAT_PROJECT_ID=your-project-id
REVENUECAT_SECRET_API_KEY=your-v2-secret-key
REVENUECAT_ENVIRONMENT=production
REVENUECAT_WEBHOOK_AUTH="Bearer generate-a-secure-random-string-here"
REVENUECAT_WEBHOOK_SIGNING_SECRET=
REVENUECAT_DEFAULT_PLAN=premium

Point a RevenueCat webhook at /revenuecat/webhook with the same Authorization value, and optionally turn on its HMAC signing with the signing secret. The secret key must be a REST API v2 key; v1 keys are refused.

Run a queue worker: webhooks are answered straight away and the sync runs as a job.

Identity

Each owner gets a random RevenueCat app user id. Give it to your app and have the app log in to RevenueCat with it:

use Whilesmart\EntitlementsRevenueCat\Models\Customer;

Customer::forOwner($user)->app_user_id;

The id cannot be guessed from the owner's key. Each server's database issues its own, so staging and production never share a RevenueCat customer. Webhooks naming any other id, including RevenueCat's anonymous ids, are ignored.

How it works

  • The webhook records each event once by its id and answers 200. Test events and events from the other store environment are recorded without changing anything. A redelivered event that was never processed is processed again.
  • The sync asks the REST API v2 for the customer's subscriptions in the configured environment, following every page. Access comes only from RevenueCat's gives_access flag on a subscription carrying the configured entitlement, never from an event type or status. A cancellation or billing issue keeps access until RevenueCat stops giving it; a grace period past the period end keeps access until a later sync closes it.
  • The result is one entitlement subscription per owner, marked metadata.provider = revenuecat, with the plan mapped from the RevenueCat product. Access is never granted without a plan. When access ends the subscription is cancelled and the owner falls back to whatever else entitles them.
  • SubscriptionSynced is dispatched after every sync with whether the owner has access.

Configuration

Publish with php artisan vendor:publish --tag=entitlements-revenuecat-config.

Key Purpose
project_id, secret_api_key RevenueCat project and REST API v2 secret key
environment sandbox or production: the store environment this server grants access for
webhook_authorization Value the Authorization header must equal
webhook_signing_secret HMAC signing secret; when set, every webhook must be signed
entitlement Entitlement lookup key that grants access (premium)
plans RevenueCat product id (prod...) to plan key
default_plan Plan for products not listed in plans
route_path, route_middleware, register_routes Webhook route
queue Queue for sync jobs

At least one of webhook_authorization or webhook_signing_secret must be set, or the webhook answers 503.

Commands

php artisan revenuecat:sync <app-user-id>   # sync one customer now
php artisan revenuecat:sync --all           # queue a sync for every open RevenueCat subscription

Schedule revenuecat:sync --all daily so access closes even if an expiration webhook is lost.

Tests

make bootstrap
docker compose run --rm app composer install
docker compose run --rm app composer test