payments-pl 0.4.3 → 0.4.5

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -19,3 +19,4 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+ *.gemspec
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.3
1
+ 0.4.5
data/lib/payments/pos.rb CHANGED
@@ -16,6 +16,8 @@ module Payments
16
16
  @key2 = options[:key2]
17
17
  @type = options[:type] || 'default'
18
18
  @encoding = options[:encoding] || 'UTF'
19
+ @test_payment = !!options[:test_payment] || false
20
+ @add_sig = !!options[:add_sig] || false
19
21
 
20
22
  raise PosInvalid.new('Missing pos_id parameter') if @pos_id.blank?
21
23
  raise PosInvalid.new('Missing pos_auth_key parameter') if @pos_auth_key.blank?
@@ -29,11 +31,18 @@ module Payments
29
31
  # @param [Hash] options options hash for new transaction
30
32
  # @return [Object] Transaction object
31
33
  def new_transaction(options = {})
32
- options.stringify_keys!
34
+ options = options.dup.symbolize_keys!
33
35
 
34
36
  options[:pos_id] = @pos_id
35
37
  options[:pos_auth_key] = @pos_auth_key
36
38
  options[:session_id] ||= (Time.now.to_f * 100).to_i
39
+ options[:pay_type] = 't' if @test_payment && @type == 'default'
40
+
41
+ if @add_sig
42
+ ts, sig = generate_sig(options)
43
+ options[:ts] = ts
44
+ options[:sig] = sig
45
+ end
37
46
 
38
47
  Transaction.new(options)
39
48
  end
@@ -62,6 +71,24 @@ module Payments
62
71
 
63
72
  protected
64
73
 
74
+ def generate_sig(options)
75
+ ts = (Time.now.to_f * 1000).to_i
76
+ sig = encrypt(options[:pos_id], options[:pay_type], options[:session_id],
77
+ options[:pos_auth_key], options[:amount], options[:desc], options[:desc2],
78
+ options[:order_id], options[:first_name], options[:last_name],
79
+ options[:payback_login], options[:street], options[:street_hn],
80
+ options[:street_an], options[:city], options[:post_code],
81
+ options[:country], options[:email], options[:phone], options[:language],
82
+ options[:client_ip], ts, @key1)
83
+
84
+ [ts, sig]
85
+ end
86
+
87
+ def encrypt(*params)
88
+ puts params.join
89
+ Digest::MD5.hexdigest(params.join)
90
+ end
91
+
65
92
  def path_for(method)
66
93
  case method
67
94
  when :get then "/paygw/#{@encoding}/Payment/get/txt"
@@ -71,10 +98,6 @@ module Payments
71
98
  end
72
99
  end
73
100
 
74
- def encrypt(*params)
75
- Digest::MD5.hexdigest(params.join)
76
- end
77
-
78
101
  def verify(t)
79
102
  sig = nil
80
103
  if t.trans_status
data/payments-pl.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{payments-pl}
8
- s.version = "0.4.3"
8
+ s.version = "0.4.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Micha\305\202 M\305\202o\305\272niak"]
12
- s.date = %q{2010-08-18}
12
+ s.date = %q{2010-08-19}
13
13
  s.description = %q{Simple library for payments via platnosci.pl}
14
14
  s.email = %q{m.mlozniak@gmail.com}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payments-pl
3
3
  version: !ruby/object:Gem::Version
4
- hash: 9
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
- - 3
10
- version: 0.4.3
9
+ - 5
10
+ version: 0.4.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - !binary |
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-08-18 00:00:00 +02:00
20
+ date: 2010-08-19 00:00:00 +02:00
21
21
  default_executable:
22
22
  dependencies: []
23
23