payr 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -194,6 +194,16 @@ To finish, you need to add this to the application.js
194
194
  //= require payr/bills
195
195
  ```
196
196
 
197
+ ### Tests
198
+
199
+ If you wanna test your own callbacks, you can mock up the filters like this :
200
+ ```ruby
201
+ before { Payr::Client.any_instance.should_receive(:check_response).and_return(true) }
202
+ before { Payr::Client.any_instance.should_receive(:check_response_ipn).and_return(true) }
203
+
204
+ ```
205
+
206
+
197
207
  # I Don't Care about your super CallbacksController and your Super Bill Model
198
208
 
199
209
  ## YEAH, I just want the backbone : form helpers, signature checker
data/lib/payr/client.rb CHANGED
@@ -43,9 +43,10 @@ module Payr
43
43
  signed? params, signature
44
44
  end
45
45
 
46
+ # QQQ Improve to use re_build_ipn_query
46
47
  def check_response_ipn params
47
- signature = params[:signature]
48
- query_params = re_build_ipn_query params
48
+ signature = get_signature params
49
+ query_params = re_build_query params
49
50
  signed? query_params, signature
50
51
  end
51
52
 
@@ -55,7 +56,6 @@ module Payr
55
56
  end
56
57
  end
57
58
 
58
-
59
59
  protected
60
60
  def check_server_availability server_url
61
61
  uri = URI.parse(server_url)
@@ -75,8 +75,8 @@ module Payr
75
75
  end
76
76
  def re_build_ipn_query params
77
77
  Payr.callback_values.keys.collect do |key|
78
- "#{key}=#{params[key]}" unless key == :signature
79
- end.compact.join("&")
78
+ "#{key}=#{params[key]}" unless key == :signature
79
+ end.compact.join("&")
80
80
  end
81
81
  def re_build_query params
82
82
  params[params.index("?")+1..params.index("&signature")-1]
@@ -91,9 +91,9 @@ module Payr
91
91
  OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new(Payr.hash.to_s), binary_key, base_params).upcase
92
92
  end
93
93
 
94
- def to_base_params params={}
94
+ def to_base_params params={}
95
95
  params.to_a.collect do |pair|
96
- "#{pair[0].upcase}=#{pair[1]}"
96
+ "#{pair[0].upcase}=#{pair[1]}"
97
97
  end.join("&")
98
98
  end
99
99
 
@@ -8,9 +8,9 @@ module Payr
8
8
  return
9
9
  end
10
10
  end
11
-
12
11
  def check_ipn_response
13
- unless Payr::Client.new.check_response_ipn(params)
12
+ # TODO use : unless Payr::Client.new.check_response_ipn(params)
13
+ unless Payr::Client.new.check_response_ipn(request.url)
14
14
  redirect_to payr_bills_failure_path
15
15
  return
16
16
  end
@@ -8,7 +8,7 @@ module ActionDispatch::Routing
8
8
  get "payr/bills/pay", as: "payr_bills_pay"
9
9
  post "payr/bills/pay", as: "payr_bills_pay"
10
10
  end
11
- ["paid", "refused", "cancelled", "ipn", "failure"].each do |action|
11
+ %w(paid refused cancelled ipn failure).each do |action|
12
12
  if options && options[:callback_controller]
13
13
  get "#{options[:callback_controller]}/#{action}", as: "payr_bills_#{action}"
14
14
  else
data/lib/payr/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Payr
2
- VERSION = "1.0.1"
2
+ VERSION = "1.0.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payr
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.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: 2012-10-24 00:00:00.000000000 Z
12
+ date: 2012-11-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -138,7 +138,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
138
138
  version: '0'
139
139
  segments:
140
140
  - 0
141
- hash: 2281109692306427172
141
+ hash: 3263532857104243643
142
142
  required_rubygems_version: !ruby/object:Gem::Requirement
143
143
  none: false
144
144
  requirements:
@@ -147,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
147
147
  version: '0'
148
148
  segments:
149
149
  - 0
150
- hash: 2281109692306427172
150
+ hash: 3263532857104243643
151
151
  requirements: []
152
152
  rubyforge_project:
153
153
  rubygems_version: 1.8.24