CouponCode gem generates and validates coupon codes. Suitable for e-Commerce sites and businesses who want to issue coupons/vouchers to customers.
It is a Ruby implementation of Grant's Algorithm::CouponCode, so the characteristics and features of this gem is alike. Please read the original documentation of Algorithm::CouponCode for details.
However, please be aware that not all the nice and thoughtful functionality the original CPAN module has are implemented at the moment. Generating codes from a plaintext, auto-correct, and jQuery plugin are not included.
This gem is developed for https://stripes.co.kr
Add this line to your application's Gemfile:
gem 'coupon_code'
And then execute:
$ bundle
Or install it yourself as:
$ gem install coupon_code
>> require 'coupon_code'
>> code = CouponCode.generate
=> "1K7Q-CTFM-LMTC"
>> CouponCode.validate(code)
=> "1K7Q-CTFM-LMTC"
>> CouponCode.validate('1K7Q-CTFM-LMTO') # Invalid code
=> nil
$ bundle exec rake test
- Grant McLean's Algorithm::CouponCode in Perl
- Andrew Chilton's NodeJS implementation in JavaScript
MIT. See LICENSE for more details.
- Fork it ( https://github.com/baxang/coupon-code/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request