LaravelPackages.net
Acme Inc.
Toggle sidebar
roundly-consulting/purchases-for-laravel

Handle payments and subscriptions from Payment Gateways and In-App Purchases.

71
6
2.3.0
About roundly-consulting/purchases-for-laravel

roundly-consulting/purchases-for-laravel is a Laravel package for handle payments and subscriptions from payment gateways and in-app purchases.. It currently has 6 GitHub stars and 71 downloads on Packagist (latest version 2.3.0). Install it with composer require roundly-consulting/purchases-for-laravel. Discover more Laravel packages by roundly-consulting or browse all Laravel packages to compare alternatives.

Last updated

Purchases for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

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, fires lifecycle events, and bills through Stripe (customers, per-seat and metered subscriptions, invoice previews, the customer portal), all with no third-party SDKs.

Installation

Requires PHP 8.4 (ext-bcmath) and Laravel 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 (Stripe needs both PURCHASES_STRIPE_SECRET and 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

Bill a company through Stripe. The subscription is recorded for it right away, and every webhook that follows keeps it in sync:

use RoundlyConsulting\Purchases\DataTransferObjects\Stripe\{CreateSubscriptionData, CustomerData, SubscriptionPrice, TaxIdData};

Purchases::stripe()->customers()->sync($company, new CustomerData(
    name: 'Acme s.r.o.',
    email: '[email protected]',
    taxIds: [new TaxIdData('eu_vat', 'SK2020123456')],
));

$subscription = Purchases::stripe()->subscriptions()->create($company, new CreateSubscriptionData(
    prices: [SubscriptionPrice::licensed('price_seats', 10), SubscriptionPrice::metered('price_storage')],
    name: 'team',
    trialDays: 7,
));

Purchases::stripe()->subscriptions()->updateQuantity($subscription->itemFor('price_seats'), 11);
Purchases::stripe()->meters()->report($company, 'storage_gb_days', 12.5);

Then gate features on it:

Purchases::for($company)->subscribedTo('team');          // true
Purchases::for($company)->activeSubscription('team');    // ?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.

Donate to Roundly open source Become a patron on Patreon Donate crypto: BTC, ETH, BNB or SOL

License

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

Comments
Affiliate link

Get paid by clients abroad

Wise gives you local bank details in several currencies and converts at the mid-market rate. Useful when your invoices are not in your own currency.

Try Wise

Star History Chart

Get the next ones by email

New Laravel packages worth a look, once a month. No spam, one-click unsubscribe.