liberty_reserve_payments 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -8,7 +8,7 @@ after it was made.
8
8
 
9
9
  Add this line to your application's Gemfile:
10
10
 
11
- gem 'liberty_reserve_payments'
11
+ gem 'liberty_reserve_payments', '>=0.1.1'
12
12
 
13
13
  And then execute:
14
14
 
@@ -50,11 +50,11 @@ def pay_item_with_lr
50
50
  handler = LibertyReservePayments::Handler.new LIBERTY_CONFIG
51
51
  @item = Item.find(params[:id])
52
52
  # The payment_request_uri takes the following arguments:
53
- # amount, currency = 'LRUSD', comments = '', order_id = '', item_name = ''
53
+ # amount, currency, order_id, item_name
54
54
  # item_name and order_id are baggage fields that should aid you on the validation of the transaction
55
55
  # The method will generate a URL containing the parameters for the payment and redirect to the
56
56
  # Liberty Reserve website
57
- redirect_to handler.payment_request_uri(amount: @item.amount, order_id: '1', comment: 'Test Liberty')
57
+ redirect_to handler.payment_request_uri(@item.amount, 'LRUSD', '1', 'Test Item')
58
58
  end
59
59
  ```
60
60
  You should also add a route for Liberty Reserve to send the status of the transactions. It can point to a method
@@ -20,7 +20,7 @@ module LibertyReservePayments
20
20
 
21
21
  def valid?(params)
22
22
  sha256 = Digest::SHA256.new
23
- str = "#{params[:lr_paidto]}:#{params[:lr_paidby]}:#{params[:lr_store].gsub(/\\\//, '')}:#{params[:lr_amnt]}:#{params[:lr_transfer]}:#{params[:lr_currency]}:#{self.security_word}"
23
+ str = "#{self.account_number}:#{params[:lr_paidby]}:#{self.store_name.gsub(/\\\//, '')}:#{params[:lr_amnt]}:#{params[:lr_transfer]}:#{params[:lr_currency]}:#{self.security_word}"
24
24
  first_hash = sha256.digest(str)
25
25
  second_hash = first_hash.unpack('H*').first.upcase
26
26
  if params[:lr_encrypted] == second_hash and params[:lr_paidto] == self.account_number
@@ -1,3 +1,3 @@
1
1
  module LibertyReservePayments
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,7 +1,27 @@
1
- require '../spec_helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe LibertyReservePayments::Handler do
4
- describe '.payment_request_uri' do
4
+ let :attributes do
5
+ {account_number: 'U123456', store_name: 'MyStore', security_word: 'MySecWord123'}
6
+ end
5
7
 
8
+ let :instance do
9
+ LibertyReservePayments::Handler.new attributes
10
+ end
11
+ describe '.valid?' do
12
+ let :params do
13
+ {
14
+ lr_paidto: 'U123456',
15
+ lr_paidby: 'U789',
16
+ lr_store: 'MyStore',
17
+ lr_amnt: '12.34',
18
+ lr_transfer: '4456778335534',
19
+ lr_currency: 'LRUSD',
20
+ lr_encrypted: 'E71A1EE0A1396EDB03FD24BE88C129CFE3DFFC8A05188084FB853305978080FB'
21
+ }
22
+ end
23
+ it 'should be a valid response' do
24
+ instance.valid?(params).should be_true
25
+ end
6
26
  end
7
27
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: liberty_reserve_payments
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-19 00:00:00.000000000 Z
12
+ date: 2013-02-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec-rails