Looking to hire Laravel developers? Try LaraJobs

purchases-for-laravel maintained by roundly-consulting

Description
Handle payments and subscriptions from Payment Gateways and In-App Purchases.
Last update
2026/10/05 18:47 (dev-main)
License
Downloads
2

Comments
comments powered by Disqus

Purchases for Laravel

One API for Apple App Store, Google Play and Stripe purchases and subscriptions. It verifies every store's webhooks natively, records purchases, subscriptions and refunds as Eloquent models, and fires lifecycle events, with no third-party SDKs.

Installation

Requires PHP 8.4 (ext-bcmath) and Laravel 12 or 13.

composer require roundly-consulting/purchases-for-laravel
php artisan purchases:install --providers   # publishes config + migrations, appends the providers' .env keys
php artisan migrate

If your owner models have UUID/ULID keys, set PURCHASES_KEY_TYPE before migrating. Fill in each provider's credentials (for Stripe, PURCHASES_STRIPE_WEBHOOK_SECRET) and set PURCHASES_ROUTES_ENABLED=true to receive webhooks at POST /purchases/webhooks/{provider}.

Usage

The bundled route verifies, records and fires events for you. From your own controller it is one call:

use RoundlyConsulting\Purchases\Facades\Purchases;

$model = Purchases::handle('stripe', $request);   // verify the signature, record, fire events

A store never says which of your users paid, so link the owner in a listener:

use App\Models\User;
use Illuminate\Support\Facades\Event;
use RoundlyConsulting\Purchases\Events\SubscriptionStarted;

Event::listen(function (SubscriptionStarted $event): void {
    $customer = $event->result->raw()['customer'];          // the Stripe customer id

    $event->subscription->owner()->associate(User::firstWhere('stripe_id', $customer));
    $event->subscription->name = 'pro';                      // Stripe names no plan
    $event->subscription->save();
});

Then gate features on it:

Purchases::for($user)->subscribedTo('pro');          // true
Purchases::for($user)->activeSubscription('pro');    // ?Subscription

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/purchases-for-laravel

Release notes are in CHANGELOG.md. To contribute, see the contributing guide.

Support our work

This package is free and open source, built and maintained by Roundly Consulting. If it saves you time, please consider supporting our open-source work — a one-time donation, a monthly pledge on Patreon or a crypto donation helps fund maintenance, new features and new packages.

License

The MIT License (MIT). Please see License File for more information.