payanyway 2.2.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/routes.rb +2 -2
- data/lib/payanyway/controller.rb +5 -0
- data/lib/payanyway/version.rb +1 -1
- data/spec/controllers/payanyway_controller_spec.rb +47 -22
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4e33b66444fe5d3e523b35f0c073aa7aea22980f
|
4
|
+
data.tar.gz: 332ff3a34247a16adb5e56cd2db721475c05e394
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e1a4978bbc46b43539635e57124547da095d1341bb78edc3c11ea6ab78da1fe394c5a8865ec63fd59d9624468ae9927a0717d99467a03751d384668f2017e55c
|
7
|
+
data.tar.gz: 8591c4065a4096d72f12f6e8eec6b5388446006b978cc73c291f90c397b77fa2e636a6d610ae4b6f159a37485539d83f60807513f7a81732beb92085c9bf8086
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
Payanyway::Engine.routes.draw do
|
2
2
|
get 'success' => 'payanyway#success', as: :payanyway_on_success
|
3
|
-
|
3
|
+
match 'pay' => 'payanyway#pay', as: :payanyway_pay, via: [:get, :post]
|
4
4
|
get 'fail' => 'payanyway#fail', as: :payanyway_on_fail
|
5
5
|
get 'return' => 'payanyway#return', as: :payanyway_on_return
|
6
6
|
get 'in_progress' => 'payanyway#in_progress', as: :payanyway_in_progress
|
7
|
-
|
7
|
+
match 'check' => 'payanyway#check', as: :payanyway_on_check, via: [:get, :post]
|
8
8
|
end
|
data/lib/payanyway/controller.rb
CHANGED
data/lib/payanyway/version.rb
CHANGED
@@ -10,6 +10,15 @@ describe PayanywayController do
|
|
10
10
|
|
11
11
|
end
|
12
12
|
|
13
|
+
describe 'POST #pay' do
|
14
|
+
|
15
|
+
it 'should render "FAIL" text' do
|
16
|
+
post :pay
|
17
|
+
expect(response.body).to eq('FAIL')
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
13
22
|
describe 'GET #success' do
|
14
23
|
it 'should add message to logger' do
|
15
24
|
expect(Rails.logger).to receive(:info).with("PAYANYWAY: Called success payment url for order '676'").and_call_original
|
@@ -42,37 +51,53 @@ describe PayanywayController do
|
|
42
51
|
end
|
43
52
|
end
|
44
53
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
54
|
+
[:get, :post].each do |method|
|
55
|
+
|
56
|
+
describe "#{method.upcase} #check" do
|
57
|
+
context 'when empty params' do
|
58
|
+
it 'should raise error' do
|
59
|
+
expect{
|
60
|
+
public_send(method, :check)
|
61
|
+
}.not_to raise_error
|
62
|
+
end
|
49
63
|
end
|
50
|
-
end
|
51
64
|
|
52
|
-
|
53
|
-
|
54
|
-
|
65
|
+
context 'when invalid signature' do
|
66
|
+
it 'should raise error' do
|
67
|
+
expect{ public_send(method, :check, { 'MNT_TRANSACTION_ID' => 676 }) }.to raise_error
|
68
|
+
end
|
55
69
|
end
|
56
|
-
end
|
57
70
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
71
|
+
context 'when valid signature' do
|
72
|
+
it 'should add message to logger' do
|
73
|
+
expect(Rails.logger).not_to receive(:info).with(/PAYANYWAY: XML response for check/)
|
74
|
+
expect_any_instance_of(Payanyway::Controller).
|
75
|
+
to receive(:check_implementation).and_return(amount: 12, state: :paid)
|
62
76
|
|
63
|
-
|
77
|
+
public_send method, :check, {
|
78
|
+
'MNT_ID' => Payanyway::Gateway.config['moneta_id'].to_s,
|
79
|
+
'MNT_TRANSACTION_ID' => 676,
|
80
|
+
'MNT_SIGNATURE' => '79c1c4f41a0a70bb107c976ebba25811'
|
81
|
+
}
|
64
82
|
|
65
|
-
|
83
|
+
expect(Nokogiri::XML(response.body).at_css('MNT_RESPONSE')).to be_present
|
84
|
+
end
|
66
85
|
end
|
67
|
-
end
|
68
|
-
|
69
|
-
context 'when logger flag is true' do
|
70
|
-
it 'should add message to logger' do
|
71
|
-
expect(Rails.logger).to receive(:info).with(/PAYANYWAY: XML response for check/)
|
72
86
|
|
73
|
-
|
74
|
-
|
87
|
+
context 'when logger flag is true' do
|
88
|
+
it 'should add message to logger' do
|
89
|
+
expect(Rails.logger).to receive(:info).with(/PAYANYWAY: XML response for check/)
|
90
|
+
|
91
|
+
expect_any_instance_of(Payanyway::Controller).
|
92
|
+
to receive(:check_implementation).and_return(amount: 12, state: :paid, logger: true)
|
93
|
+
public_send method, :check, {
|
94
|
+
'MNT_ID' => Payanyway::Gateway.config['moneta_id'].to_s,
|
95
|
+
'MNT_TRANSACTION_ID' => 676,
|
96
|
+
'MNT_SIGNATURE' => '79c1c4f41a0a70bb107c976ebba25811'
|
97
|
+
}
|
98
|
+
end
|
75
99
|
end
|
76
100
|
end
|
101
|
+
|
77
102
|
end
|
78
103
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: payanyway
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ssnikolay
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06-
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|