Skip to content

Redeem code generator and redeemer, for compensations and event rewards for users.

License

Notifications You must be signed in to change notification settings

furic/laravel-redeem-codes

Repository files navigation

laravel-redeem-codes

Packagist Packagist License Scrutinizer Code Quality Build Status

Redeem code generator and redeemer for Laravel 5.*. I developed this package while working for a redeem code solution in Sweaty Chair Studio catering for compensations and event rewards for players. This contains API for redeem code validation and a simple web console to create and edit the redeem codes. This package is aimed to be a plug-n-play solution, I would also recommend Laravel Promocodes and Laravel Vouchers that gives you more freedom and being able to build from scratch.

Table of Contents

Installation

Install this package via Composer:

$ composer require furic/redeem-codes

If you are using Laravel 5.5 or later, then installation is done. Otherwise follow the next steps.

Open config/app.php and follow steps below:

Find the providers array and add our service provider.

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

Configuration

Publish config & migration file using Artisan command:

$ php artisan vendor:publish

To create table for redeem codes in database run:

$ php artisan migrate

Usage

Web Console

After installation, you can simply browse to <server url>/redeem-codes to open the web console:

Laravel Redeem Codes web console

Here you can browse, create and edit the redeem codes.

Redeem Code Parameters

  • Code Prefix: Set the prefix of the redeem code(s), used for being easier to distingush or with event name. Note that all redeem codes has fixed 12 characters length.
  • Reusable: Set if the redeem code(s) is reusable for different players. Note that the server doesn't check if the same user redeeming multiple times, you should add a check to prevent this in your client app.
  • Count: Number of redeem code(s) to create.
  • Description: The description of the redeem code(s).
  • Rewards: The reward type and count, you can add multiple rewards here. The reward type simply is a tiny int and should be convert to Enum in your client app. To add change/add reward type, simply edit the index.blade.php file.

Redeem Validator API

GET <server url>/api/redeem/{code} Posts the redeem code (12 characters length) and returns the redeem code data. For valid redeem codes, 200 status code is returned with the redeem code JSON data. Otherwise, 400 is returned with the error.

API Document can be found here.

Unity Client Repo

You can simply import this repo in Unity to communicate with your Laravel server with this package.

TODO

  • Add item types configurable in config file.
  • Add admin login for web console.
  • Add tests and factories.
  • Add redeem history page (already in database).
  • Add reusable server check (low priority).

License

laravel-redeem-codes is licensed under a MIT License.