No commit activity in last 3 years
No release in over 3 years
Accept payments from Liberty Reserve
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

>= 3.2.12
 Project Readme

LibertyReservePayments

Build Status

Receive payments via Liberty Reserve. With this gem the user of your shop can pay for a digital item (or any type of item) and you can validate the transaction after it was made.

Installation

Add this line to your application's Gemfile:

gem 'liberty_reserve_payments', '>=0.1.1'

And then execute:

$ bundle

Or install it yourself as:

$ gem install liberty_reserve_payments

Usage

After the installation, you still need two files for the gem to work. A Yaml config file and an initializer.

config/liberty.yml

development:
  account_number: U1234567
  store_name: SampleStore
  security_word: test1234

production:
  account_number: U1234567
  store_name: SampleStore
  security_word: test1234

config/initializers/liberty.rb

require 'liberty_reserve_payments/handler'

LIBERTY_CONFIG = YAML.load_file("#{Rails.root}/config/liberty.yml")[Rails.env].symbolize_keys

After creating these files you still need to add the methods provided by this gem to your PaymentsController. To do this you can add the following template methods to you file:

def pay_item_with_lr
    handler = LibertyReservePayments::Handler.new LIBERTY_CONFIG
    @item = Item.find(params[:id])
    # The payment_request_uri takes the following arguments:
    # amount, currency, order_id, item_name
    # item_name and order_id are baggage fields that should aid you on the validation of the transaction
    # The method will generate a URL containing the parameters for the payment and redirect to the
    # Liberty Reserve website
    redirect_to handler.payment_request_uri(@item.amount, 'LRUSD', '1', 'Test Item')
end

You should also add a route for Liberty Reserve to send the status of the transactions. It can point to a method looking like this:

def validate_payment
    handler = LibertyReservePayments::Handler.new LIBERTY_CONFIG
    if handler.valid?(params)
        order = Order.find(params[:order_id]
        # The transaction has been validated. You can perform your own
        # validations now. You should specifically validate the amount that was paid.
        if order.amount == params[:lr_amnt]
            # Amount matches, you can proceed
        else
            # Log the transaction and inspect it later
        end
    else
        # The transaction has been tampered with, you should log it for
        # later verification.
    end
end

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request