Search by

roundly-consulting / coupons-for-laravel

mihaliak

Create, manage, and apply discount coupons in Laravel.

Package info

github.com/roundly-consulting/coupons-for-laravel

pkg:composer/roundly-consulting/coupons-for-laravel

Fund package maintenance!

Patreon

Statistics

Installs: 9

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-10-03 18:11 UTC

This package is auto-updated.

Last update: 2026-10-03 18:32:30 UTC


README

Coupons for Laravel — Roundly open source

Latest release Tests Code style Donate Patreon Crypto

Coupons for Laravel

Create, validate and redeem discount coupons in Laravel: fixed, percentage (optionally capped) and free-shipping discounts with currency locks, minimum spends, activation windows and global or per-customer usage limits. Redemption is atomic, and every amount is an exact money-for-laravel Money.

Installation

Requires PHP 8.4 (ext-bcmath), Laravel 12 or 13, and MySQL/MariaDB, PostgreSQL or SQLite.

composer require roundly-consulting/coupons-for-laravel
php artisan vendor:publish --tag="coupons-migrations"
php artisan migrate

If the models that redeem coupons have UUID/ULID keys, set COUPONS_KEY_TYPE before migrating.

Usage

Create a coupon through the facade. New coupons start inactive, so activate it:

use RoundlyConsulting\Coupons\Enums\DiscountType;
use RoundlyConsulting\Coupons\Facades\Coupons;

$coupon = Coupons::generate(DiscountType::Percentage, value: 2000, code: 'SUMMER', maxUsage: 100); // 20 % off
$coupon->activate()->save();

At checkout, check it, preview the discount and redeem it against the cart total:

use RoundlyConsulting\Money\Money;

$cart = Money::ofMinor(5000, 'EUR');                       // €50.00

Coupons::code('SUMMER')->check($cart, $user);              // null, or why not: Expired, AtMaxUsage, …
Coupons::code('SUMMER')->preview($cart);                   // 10.00 EUR, without redeeming

$result = Coupons::code('SUMMER')->redeem($cart, $user);   // atomic; throws a CouponException if refused

$result->discount;                                         // 10.00 EUR
$result->total;                                            // 40.00 EUR

Documentation

The full documentation — configuration, every feature and its API, and testing — lives on our website: roundly-consulting.com/open-source/docs/coupons-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). See LICENSE.md for details.