payanyway 2.0.1 → 2.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05673b4e12bd38b85b361e9181396ac890c9f735
4
- data.tar.gz: 0ddf0a1ee9a5725e94f6559c3f03cf93b4340bd4
3
+ metadata.gz: 006868d92b32837be741013f78c66cd9416310ea
4
+ data.tar.gz: 817438c74c5995f52735f6b7232854d01802a4e7
5
5
  SHA512:
6
- metadata.gz: e5dd2cc9f7616f943f2305cc5489038eb8376a14a015d55a028d9a1e26587afbb92159c68246e0e946c1762462e49d3e25adf8061437802a2b276ecf3da542ee
7
- data.tar.gz: 692be96d4980db8a9e213e4f4127d68680570733665ce42655e1a88e9a51b90b0ca17d0057012660ed5a3dd4d1623fee23ed87194fccccaf35c4bfabf3bb26f8
6
+ metadata.gz: 7590e871af8f338c308a82760625576233d69526410fac95d8ba8cbd20eb9030d7db39462a87c540435c9436e6963945d8fdc642e35a384a077cb6a12bd9b574
7
+ data.tar.gz: e4e21b77e8e8306b241eef8dd3123b69dcacba812dfc26a3ac13fb46aa147006e5cc797c5e45bd04deb319ed98baaac076c9d7cb58cbbc61da9b29d0c1068757
data/.travis.yml CHANGED
@@ -3,7 +3,21 @@ language: ruby
3
3
  rvm:
4
4
  - 2.0.0
5
5
  - 2.1
6
- - 2.2
6
+ - 2.2.2
7
+ - 2.3.3
8
+
9
+ env:
10
+ - RAILS_VERSION=3.2.22.5
11
+ - RAILS_VERSION=4.2.7.1
12
+ - RAILS_VERSION=5.0.1
13
+
14
+ matrix:
15
+ exclude:
16
+ - rvm: 2.1
17
+ env: RAILS_VERSION=5.0.1
18
+ - rvm: 2.0.0
19
+ env: RAILS_VERSION=5.0.1
7
20
 
8
21
  script:
9
- - CODECLIMATE_REPO_TOKEN=41f20e51bdd84fed15a9717bd19c4aef62c96cd8be6e8fb61c08a69c840deb7a bundle exec rspec
22
+ - bundle exec rspec
23
+ - CODECLIMATE_REPO_TOKEN=41f20e51bdd84fed15a9717bd19c4aef62c96cd8be6e8fb61c08a69c840deb7a bundle exec codeclimate-test-reporter
data/Gemfile CHANGED
@@ -1,4 +1,18 @@
1
1
  source 'https://rubygems.org'
2
2
 
3
- # Specify your gem's dependencies in payanyway.gemspec
4
3
  gemspec
4
+
5
+ rails_version = ENV['RAILS_VERSION'] || 'default'
6
+
7
+ rails = case rails_version
8
+ when 'default'
9
+ '>= 3.2.0'
10
+ else
11
+ "~> #{ rails_version }"
12
+ end
13
+
14
+ gem 'rails', rails
15
+
16
+ if RUBY_VERSION[0] == '2' && RUBY_VERSION[2].to_i >= 2
17
+ gem 'test-unit', '~> 3.0'
18
+ end
data/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/payanyway.svg)](http://badge.fury.io/rb/payanyway)
2
- [![Build Status](https://travis-ci.org/ssnikolay/payanyway.svg?branch=master)](https://travis-ci.org/ssnikolay/payanyway)
2
+ [![Build Status](https://travis-ci.org/RuntimeLLC/payanyway.svg?branch=master)](https://travis-ci.org/RuntimeLLC/payanyway)
3
3
  [![Code Climate](https://codeclimate.com/github/ssnikolay/payanyway.svg)](https://codeclimate.com/github/ssnikolay/payanyway)
4
4
  [![Test Coverage](https://codeclimate.com/github/ssnikolay/payanyway/badges/coverage.svg)](https://codeclimate.com/github/ssnikolay/payanyway)
5
5
 
data/lib/payanyway.rb CHANGED
@@ -1,6 +1,8 @@
1
1
  require 'rails'
2
2
  require 'active_support/core_ext'
3
3
 
4
+ require 'nokogiri'
5
+
4
6
  require 'payanyway/helpers/settings'
5
7
  require 'payanyway/helpers/signature_generator'
6
8
 
@@ -3,44 +3,44 @@ module Payanyway
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- skip_before_filter :verify_authenticity_token
6
+ protect_from_forgery with: :null_session
7
7
  end
8
8
 
9
9
  def pay
10
- request = Payanyway::Request::Pay.new(params)
10
+ request = Payanyway::Request::Pay.new(permitted_params)
11
11
  request.success? ?
12
12
  pay_implementation(request.pretty_params) :
13
13
  Rails.logger.error(request.error_message)
14
14
 
15
- render text: request.response
15
+ render plain: request.response
16
16
  end
17
17
 
18
18
  def success
19
- request = Payanyway::Request::Base.new(params)
19
+ request = Payanyway::Request::Base.new(permitted_params)
20
20
 
21
21
  success_implementation(request.pretty_params)
22
22
  end
23
23
 
24
24
  def fail
25
- request = Payanyway::Request::Base.new(params)
25
+ request = Payanyway::Request::Base.new(permitted_params)
26
26
 
27
27
  fail_implementation(request.pretty_params[:transaction_id])
28
28
  end
29
29
 
30
30
  def return
31
- request = Payanyway::Request::Base.new(params)
31
+ request = Payanyway::Request::Base.new(permitted_params)
32
32
 
33
33
  return_implementation(request.pretty_params[:transaction_id])
34
34
  end
35
35
 
36
36
  def in_progress
37
- request = Payanyway::Request::Base.new(params)
37
+ request = Payanyway::Request::Base.new(permitted_params)
38
38
 
39
39
  in_progress_implementation(request.pretty_params[:transaction_id])
40
40
  end
41
41
 
42
42
  def check
43
- request = Payanyway::Request::Check.new(params)
43
+ request = Payanyway::Request::Check.new(permitted_params)
44
44
  if request.pretty_params.present?
45
45
  raise request.error_message unless request.success?
46
46
 
@@ -48,12 +48,17 @@ module Payanyway
48
48
  else
49
49
  # Не выдавать ошибку, если параметры пустые
50
50
  # Необходимо для проверки со стороны moneta.ru
51
- render nothing: true
51
+ head :ok
52
52
  end
53
53
  end
54
54
 
55
55
  private
56
56
 
57
+ def permitted_params
58
+ params.permit! if params.respond_to?(:permit!)
59
+ params.to_h
60
+ end
61
+
57
62
  def pay_implementation(params)
58
63
  # Вызывается после успешного прохождения
59
64
  # запроса об оплате от payanyway.ru
@@ -63,30 +68,31 @@ module Payanyway
63
68
 
64
69
  def success_implementation(params)
65
70
  # Вызывается после успешной оплаты
71
+ puts Rails.logger.object_id
66
72
 
67
73
  Rails.logger.info("PAYANYWAY: Called success payment url for order '#{ params[:transaction_id] }'")
68
- render nothing: true
74
+ head :ok
69
75
  end
70
76
 
71
77
  def fail_implementation(transaction_id)
72
78
  # Вызывается после ошибки при оплате
73
79
 
74
80
  Rails.logger.error("PAYANYWAY: Fail paid order '#{ transaction_id }'")
75
- render nothing: true
81
+ head :ok
76
82
  end
77
83
 
78
84
  def return_implementation(transaction_id)
79
85
  # Вызывается при добровольном отказе пользователем от оплаты
80
86
 
81
87
  Rails.logger.info("PAYANYWAY: Return from payanyway. Order '#{ transaction_id }'")
82
- render nothing: true
88
+ head :ok
83
89
  end
84
90
 
85
91
  def in_progress_implementation(transaction_id)
86
92
  # Вызывается после успешного запроса на авторизацию средств, до подтверждения списания и зачисления средств
87
93
 
88
94
  Rails.logger.info("PAYANYWAY: Order '#{ transaction_id }' in progress")
89
- render nothing: true
95
+ head :ok
90
96
  end
91
97
 
92
98
  def check_implementation(params)
@@ -26,4 +26,4 @@ module Payanyway
26
26
  end
27
27
  end
28
28
  end
29
- end
29
+ end
@@ -79,7 +79,7 @@ module Payanyway
79
79
  </MNT_RESPONSE>
80
80
  EOXML
81
81
 
82
- Nokogiri::XML(xml, nil, 'UTF-8')
82
+ ::Nokogiri::XML(xml, nil, 'UTF-8')
83
83
  end
84
84
 
85
85
  def signature_node(xml)
@@ -1,3 +1,3 @@
1
1
  module Payanyway
2
- VERSION = '2.0.1'
2
+ VERSION = '2.0.2'
3
3
  end
data/payanyway.gemspec CHANGED
@@ -28,5 +28,5 @@ Gem::Specification.new do |spec|
28
28
  spec.add_development_dependency 'pry'
29
29
  spec.add_development_dependency 'pumper'
30
30
  spec.add_development_dependency 'combustion', '~> 0.5.3'
31
- spec.add_development_dependency 'codeclimate-test-reporter'
31
+ spec.add_development_dependency 'codeclimate-test-reporter', '~> 1.0'
32
32
  end
@@ -2,8 +2,8 @@ describe PayanywayController do
2
2
  routes { Payanyway::Engine.routes }
3
3
 
4
4
  describe 'GET #success' do
5
- it 'should and message to logger' do
6
- expect(Rails.logger).to receive(:info).with("PAYANYWAY: Called success payment url for order '676'")
5
+ it 'should add message to logger' do
6
+ expect(Rails.logger).to receive(:info).with("PAYANYWAY: Called success payment url for order '676'").and_call_original
7
7
 
8
8
  get :success, { 'MNT_TRANSACTION_ID' => 676 }
9
9
  end
@@ -18,7 +18,7 @@ describe PayanywayController do
18
18
  end
19
19
 
20
20
  describe 'GET #return' do
21
- it 'should and message to logger' do
21
+ it 'should add message to logger' do
22
22
  expect(Rails.logger).to receive(:info).with("PAYANYWAY: Return from payanyway. Order '676'")
23
23
 
24
24
  get :return, { 'MNT_TRANSACTION_ID' => 676 }
@@ -26,7 +26,7 @@ describe PayanywayController do
26
26
  end
27
27
 
28
28
  describe 'GET #in_progress' do
29
- it 'should and message to logger' do
29
+ it 'should add message to logger' do
30
30
  expect(Rails.logger).to receive(:info).with("PAYANYWAY: Order '676' in progress")
31
31
 
32
32
  get :in_progress, { 'MNT_TRANSACTION_ID' => 676 }
@@ -47,7 +47,7 @@ describe PayanywayController do
47
47
  end
48
48
 
49
49
  context 'when valid signature' do
50
- it 'should and message to logger' do
50
+ it 'should add message to logger' do
51
51
  expect(Rails.logger).not_to receive(:info).with(/PAYANYWAY: XML response for check/)
52
52
  expect_any_instance_of(Payanyway::Controller).to receive(:check_implementation).and_return(amount: 12, state: :paid)
53
53
 
data/spec/spec_helper.rb CHANGED
@@ -11,10 +11,9 @@ Combustion.initialize! :action_controller, :action_view
11
11
  require 'payanyway'
12
12
  require 'rspec/rails'
13
13
  require 'pry'
14
- require 'codeclimate-test-reporter'
15
-
16
- CodeClimate::TestReporter.start if ENV['CODECLIMATE_REPO_TOKEN']
14
+ require 'simplecov'
17
15
 
16
+ SimpleCov.start
18
17
 
19
18
  RSpec.configure do |config|
20
19
  config.infer_spec_type_from_file_location!
metadata CHANGED
@@ -1,155 +1,155 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: payanyway
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.1
4
+ version: 2.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssnikolay
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: 3.2.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: 3.2.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ">="
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '1.7'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.7'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: '10.0'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: '10.0'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec-rails
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec-its
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: pry
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: pumper
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - '>='
115
+ - - ">="
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - '>='
122
+ - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: combustion
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 0.5.3
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 0.5.3
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: codeclimate-test-reporter
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - "~>"
144
144
  - !ruby/object:Gem::Version
145
- version: '0'
145
+ version: '1.0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - "~>"
151
151
  - !ruby/object:Gem::Version
152
- version: '0'
152
+ version: '1.0'
153
153
  description: simple gem for payanyway payment gateway
154
154
  email:
155
155
  - ssnikolay@gmail.com
@@ -157,9 +157,9 @@ executables: []
157
157
  extensions: []
158
158
  extra_rdoc_files: []
159
159
  files:
160
- - .gitignore
161
- - .rspec
162
- - .travis.yml
160
+ - ".gitignore"
161
+ - ".rspec"
162
+ - ".travis.yml"
163
163
  - Gemfile
164
164
  - LICENSE.txt
165
165
  - README.md
@@ -201,17 +201,17 @@ require_paths:
201
201
  - lib
202
202
  required_ruby_version: !ruby/object:Gem::Requirement
203
203
  requirements:
204
- - - '>='
204
+ - - ">="
205
205
  - !ruby/object:Gem::Version
206
206
  version: '0'
207
207
  required_rubygems_version: !ruby/object:Gem::Requirement
208
208
  requirements:
209
- - - '>='
209
+ - - ">="
210
210
  - !ruby/object:Gem::Version
211
211
  version: '0'
212
212
  requirements: []
213
213
  rubyforge_project:
214
- rubygems_version: 2.4.3
214
+ rubygems_version: 2.5.1
215
215
  signing_key:
216
216
  specification_version: 4
217
217
  summary: simple gem for payanyway payment gateway