furic/redeem-codes

The redeem code system used for creating redeem codes to compensate users, or giving rewards in events.

1.0.9 2020-12-23 23:47 UTC

This package is auto-updated.

Last update: 2025-04-29 05:28:53 UTC


README

Packagist Packagist License Scrutinizer Code Quality Build Status

A plug-and-play redeem code management system for Laravel applications.

laravel-redeem-codes is a lightweight package for managing and redeeming codes in Laravel projects. Originally developed for player compensation and event reward systems at Sweaty Chair Studio, this package offers both a clean API and a simple web-based console for managing redeem codes.

If you're looking for more flexible implementations, also consider:

Table of Contents

Installation

Install the package via Composer:

composer require furic/redeem-codes

Laravel 5.5+ will auto-discover the service provider. For earlier versions, register it manually.

Manual Setup (for Laravel < 5.5)

Add the service provider to your config/app.php:

'providers' => [
    // ...
    Furic\RedeemCodes\RedeemCodesServiceProvider::class,
],

Configuration

Publish the package's configuration and migration files:

php artisan vendor:publish

Then run the migration to create the redeem codes table:

php artisan migrate

Usage

Web Console

Visit your application at /redeem-codes to access the web-based admin console.

Laravel Redeem Codes web console

Use this interface to browse, create, and manage redeem codes visually.

Redeem Code Parameters

When creating a redeem code, the following fields are available:

  • Code Prefix: Optional prefix for the redeem code(s), useful for organizing events (e.g., EASTER23_). All codes are 12 characters in total.
  • Reusable: If enabled, the same code can be used by multiple users. Note: the package does not enforce per-user usage restrictions—you must handle this on the client side.
  • Count: Number of codes to generate.
  • Description: Internal notes about the purpose of the code batch.
  • Rewards: Define one or more reward types with a quantity. Rewards are stored as numeric types and should be interpreted using an Enum or similar mapping on the client side.

To modify reward types or customize the form, edit the index.blade.php file.

Redeem Validator API

The API endpoint:

GET /api/redeem/{code}

This will return the reward data in JSON format for valid codes (HTTP 200) or an error response (HTTP 400) if invalid, already used, or expired.

Explore the API in the Postman documentation.

Unity Client Integration

If you're using Unity, you can connect easily using this open source client: 👉 Unity-Redeem-Codes Repo

TODO

  • ✅ Add configurable reward item types via config file.
  • 🔒 Add authentication for web console (currently open).
  • 🧪 Add tests and model factories.
  • 📜 Add history log page (already logged in DB).
  • ⚠ Add server-side check for reusable codes (low priority).

License

This package is open-sourced software licensed under the MIT license.