glebtv-robokassa 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +10 -0
- data/config.ru +9 -0
- data/glebtv-robokassa.gemspec +3 -3
- data/lib/robokassa/controller.rb +6 -4
- data/lib/robokassa/interface.rb +6 -2
- data/lib/robokassa/version.rb +1 -1
- data/spec/internal/app/controllers/robokassa_controller.rb +9 -0
- data/spec/internal/config/database.yml +9 -0
- data/spec/internal/config/routes.rb +6 -0
- data/spec/internal/db/schema.rb +6 -0
- data/spec/internal/log/.gitignore +1 -0
- data/spec/internal/public/favicon.ico +0 -0
- data/spec/lib/interface_spec.rb +13 -7
- data/spec/routing/routes_spec.rb +20 -17
- data/spec/spec_helper.rb +3 -2
- metadata +19 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9789611e089b962f3ea1f3afd11508557cf27416c5f8dde57463bbd8f26e39f
|
4
|
+
data.tar.gz: f9fbf2ba3d5f2d5e1154764d80ad4cc51d6420bd7c85f40ddb27e9406b92ad3f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 07ce56e2beaff6179bc0bdb320d950da81286a41ee22f659cfd5896c4a542a99e122b1c539e66090ce4cdf1d31f1a35814d66f259d4feb0f53f62f1e42c295ef
|
7
|
+
data.tar.gz: c94a54eddc0060adc874bb41c7a43bcaea23e2f41e5aafcfcf05409fab148e72f09ed99b27d7f9d4c63cceca42fa8af00ddc3f1cfb55567dd4553155bab3514f
|
data/Gemfile
CHANGED
data/config.ru
ADDED
data/glebtv-robokassa.gemspec
CHANGED
@@ -17,9 +17,9 @@ Gem::Specification.new do |spec|
|
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
|
-
|
20
|
+
|
21
21
|
spec.add_dependency "rails", ">= 3.2.0"
|
22
|
-
|
23
|
-
spec.add_development_dependency "bundler"
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler"
|
24
24
|
spec.add_development_dependency "rake"
|
25
25
|
end
|
data/lib/robokassa/controller.rb
CHANGED
@@ -1,14 +1,16 @@
|
|
1
1
|
module Robokassa::Controller
|
2
2
|
extend ActiveSupport::Concern
|
3
|
-
included do
|
4
|
-
|
5
|
-
|
3
|
+
# included do
|
4
|
+
# if protect_against_forgery?
|
5
|
+
# skip_before_action :verify_authenticity_token, only: [:notify]
|
6
|
+
# end
|
7
|
+
# end
|
6
8
|
|
7
9
|
def notify
|
8
10
|
if params[:token] != Robokassa.interface.token
|
9
11
|
raise Robokassa::InvalidToken.new
|
10
12
|
end
|
11
|
-
render :
|
13
|
+
render plain: Robokassa.interface.notify(params, self)
|
12
14
|
end
|
13
15
|
|
14
16
|
def success
|
data/lib/robokassa/interface.rb
CHANGED
@@ -135,6 +135,7 @@ module Robokassa
|
|
135
135
|
|
136
136
|
# Maps gem parameter names, to robokassa names
|
137
137
|
def map_params(params, map)
|
138
|
+
params = params.is_a?(Hash) ? params : params.permit!.to_hash
|
138
139
|
parsed_params = Hash[params.map do|key, value| [(map[key] || map[key.to_sym] || key), value] end]
|
139
140
|
parsed_params[:custom_options] = Hash[params.select{ |k,v| k.respond_to?(:starts_with?) && k.starts_with?('shp') }.sort.map{|k, v| [k[3, k.size].to_sym, v]}]
|
140
141
|
parsed_params
|
@@ -152,6 +153,9 @@ module Robokassa
|
|
152
153
|
:email => email,
|
153
154
|
:language => language
|
154
155
|
}.merge(Hash[custom_options.sort.map{|x| ["shp#{x[0]}", x[1]]}])
|
156
|
+
if @options[:test_mode]
|
157
|
+
options[:isTest] = 1
|
158
|
+
end
|
155
159
|
map_params(options, @@params_map)
|
156
160
|
end
|
157
161
|
|
@@ -166,9 +170,9 @@ module Robokassa
|
|
166
170
|
"#{@options[:login]}:#{amount}:#{invoice_id}:#{@options[:password1]}#{custom_options_fmt.blank? ? "" : ":" + custom_options_fmt}"
|
167
171
|
end
|
168
172
|
|
169
|
-
# returns http://
|
173
|
+
# returns http://auth.robokassa.ru or https://merchant.roboxchange.com in order to current mode
|
170
174
|
def base_url
|
171
|
-
test_mode? ? 'http://
|
175
|
+
test_mode? ? 'http://auth.robokassa.ru/Merchant' : 'https://merchant.roboxchange.com'
|
172
176
|
end
|
173
177
|
|
174
178
|
# returns url to redirect user to payment page
|
data/lib/robokassa/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
*.log
|
File without changes
|
data/spec/lib/interface_spec.rb
CHANGED
@@ -5,11 +5,11 @@ require 'robokassa/interface'
|
|
5
5
|
describe "Interface should work correct" do
|
6
6
|
before :each do
|
7
7
|
end
|
8
|
-
|
8
|
+
|
9
9
|
it "Should correctly use test server" do
|
10
10
|
i = Robokassa::Interface.new :test_mode => true
|
11
11
|
i.should be_test_mode
|
12
|
-
i.base_url.should == "http://
|
12
|
+
i.base_url.should == "http://auth.robokassa.ru/Merchant"
|
13
13
|
end
|
14
14
|
|
15
15
|
it "should compute correct signature string" do
|
@@ -18,13 +18,20 @@ describe "Interface should work correct" do
|
|
18
18
|
i.init_payment_signature_string(15, 185.0, "Order #125", {:a => 15, :c => 30, :b => 20}).should == "demo:185.0:15:12345:shpa=15:shpb=20:shpc=30"
|
19
19
|
end
|
20
20
|
|
21
|
-
it "should create correct init payment url" do
|
21
|
+
it "should create correct init payment url for test_mode" do
|
22
22
|
i = Robokassa::Interface.new :test_mode => true, :login => 'demo', :password1 => '12345'
|
23
|
-
|
23
|
+
expected_url = "http://auth.robokassa.ru/Merchant/Index.aspx?MrchLogin=demo&OutSum=185.11&InvId=15&Desc=Order+125&SignatureValue=8e32c6ad194a540fe14fb97367360170&IncCurrLabel=&Email=demo%40robokassa.ru&Culture=ru&isTest=1&custom_options=%7B%7D"
|
24
|
+
generated_url = i.init_payment_url(15, 185.11, "Order 125", '', 'ru', 'demo@robokassa.ru', {})
|
25
|
+
puts generated_url
|
26
|
+
generated_url.should == expected_url
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should create correct init payment url for production" do
|
30
|
+
i = Robokassa::Interface.new :login => 'shaggyone239', :password1 => '12345asdf'
|
24
31
|
i.init_payment_signature_string(15, 185.11, "Order #125").should == "shaggyone239:185.11:15:12345asdf"
|
25
32
|
i.init_payment_signature(15, 185.11, "Order #125").should == "55f2aee20767cde28e7fc49919cec969"
|
26
|
-
i.init_payment_url(15, 185.11, "Order 125", '', 'ru', 'demo@robokassa.ru', {}).should ==
|
27
|
-
"
|
33
|
+
i.init_payment_url(15, 185.11, "Order 125", '', 'ru', 'demo@robokassa.ru', {}).should ==
|
34
|
+
"ttps://merchant.roboxchange.com/Index.aspx?MrchLogin=shaggyone239&OutSum=185.11&InvId=15&Desc=Order+125&SignatureValue=55f2aee20767cde28e7fc49919cec969&IncCurrLabel=&Email=demo%40robokassa.ru&Culture=ru&isTest=1"
|
28
35
|
i.init_payment_signature(196, 2180.0, "R602412577").should == "adeedf2afbac5eca09b44898da3ef51a"
|
29
36
|
end
|
30
37
|
|
@@ -52,4 +59,3 @@ describe "Interface should work correct" do
|
|
52
59
|
expect { i.success_validate_signature( params ) }.not_to raise_error
|
53
60
|
end
|
54
61
|
end
|
55
|
-
|
data/spec/routing/routes_spec.rb
CHANGED
@@ -1,23 +1,26 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
|
4
|
-
describe 'routes' do
|
4
|
+
describe 'routes', type: :routing do
|
5
5
|
context "robokassa" do
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
it "routes robokassa notify" do
|
7
|
+
expect(:get => '/robokassa/notify/some-secure-notification-key').to route_to(
|
8
|
+
controller: 'robokassa',
|
9
|
+
action: 'notify',
|
10
|
+
token: 'some-secure-notification-key'
|
11
|
+
)
|
12
|
+
end
|
13
|
+
it "routes robokassa success" do
|
14
|
+
expect(:get => '/robokassa/success').to route_to(
|
15
|
+
controller: 'robokassa',
|
16
|
+
action: 'success'
|
17
|
+
)
|
18
|
+
end
|
19
|
+
it "routes robokassa fail" do
|
20
|
+
expect(:get => '/robokassa/fail').to route_to(
|
21
|
+
controller: 'robokassa',
|
22
|
+
action: 'fail'
|
23
|
+
)
|
24
|
+
end
|
21
25
|
end
|
22
26
|
end
|
23
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -1,11 +1,12 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'bundler'
|
3
|
-
|
3
|
+
require 'combustion'
|
4
4
|
require 'rails'
|
5
5
|
|
6
6
|
Bundler.require :default, :development
|
7
7
|
|
8
|
-
|
8
|
+
# :active_record,
|
9
|
+
Combustion.initialize! :action_controller
|
9
10
|
|
10
11
|
require 'rspec/rails'
|
11
12
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: glebtv-robokassa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebtv
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-03-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -28,16 +28,16 @@ dependencies:
|
|
28
28
|
name: bundler
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- README.md
|
66
66
|
- Rakefile
|
67
67
|
- app/controllers/robokassa_controller.rb
|
68
|
+
- config.ru
|
68
69
|
- config/locales/en.yml
|
69
70
|
- config/locales/ru.yml
|
70
71
|
- config/routes.rb
|
@@ -75,6 +76,12 @@ files:
|
|
75
76
|
- lib/robokassa/engine.rb
|
76
77
|
- lib/robokassa/interface.rb
|
77
78
|
- lib/robokassa/version.rb
|
79
|
+
- spec/internal/app/controllers/robokassa_controller.rb
|
80
|
+
- spec/internal/config/database.yml
|
81
|
+
- spec/internal/config/routes.rb
|
82
|
+
- spec/internal/db/schema.rb
|
83
|
+
- spec/internal/log/.gitignore
|
84
|
+
- spec/internal/public/favicon.ico
|
78
85
|
- spec/lib/interface_spec.rb
|
79
86
|
- spec/routing/routes_spec.rb
|
80
87
|
- spec/spec_helper.rb
|
@@ -102,6 +109,12 @@ signing_key:
|
|
102
109
|
specification_version: 4
|
103
110
|
summary: This gem adds robokassa support to your app.
|
104
111
|
test_files:
|
112
|
+
- spec/internal/app/controllers/robokassa_controller.rb
|
113
|
+
- spec/internal/config/database.yml
|
114
|
+
- spec/internal/config/routes.rb
|
115
|
+
- spec/internal/db/schema.rb
|
116
|
+
- spec/internal/log/.gitignore
|
117
|
+
- spec/internal/public/favicon.ico
|
105
118
|
- spec/lib/interface_spec.rb
|
106
119
|
- spec/routing/routes_spec.rb
|
107
120
|
- spec/spec_helper.rb
|