solidus_culqi 0.1.1 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +14 -29
  3. data/.travis.yml +6 -17
  4. data/Gemfile +2 -0
  5. data/app/models/concerns/solidus_culqi/inject_installments_concern.rb +1 -1
  6. data/app/models/payment_decorator.rb +3 -1
  7. data/app/models/permitted_attributes_decorator.rb +3 -1
  8. data/app/models/solidus/gateway/culqi_gateway.rb +11 -8
  9. data/bin/geckodriver +28 -0
  10. data/lib/solidus_culqi.rb +0 -1
  11. data/lib/solidus_culqi/version.rb +1 -1
  12. data/solidus_culqi.gemspec +0 -4
  13. data/spec/models/culqi_gateway.rb +3 -10
  14. data/spec/spec_helper.rb +0 -34
  15. metadata +4 -72
  16. data/app/views/spree/checkout/existing_payment/_culqi.html.erb +0 -3
  17. data/app/views/spree/checkout/payment/_culqi.html.erb +0 -79
  18. data/lib/solidus_culqi/gateway.rb +0 -31
  19. data/spec/cassettes/Culqi_checkout/with_logged_user/store_card_in_wallet.yml +0 -206
  20. data/spec/cassettes/Culqi_checkout/with_unlogged_user/with_process_checkout/capture_payment.yml +0 -207
  21. data/spec/cassettes/Culqi_checkout/with_unlogged_user/with_process_checkout/process_order.yml +0 -156
  22. data/spec/cassettes/Culqi_checkout/with_unlogged_user/with_process_checkout/voids_a_payment.yml +0 -207
  23. data/spec/cassettes/Culqi_checkout_autocapture/with_valid_credit_card/can_process_a_valid_payment.yml +0 -156
  24. data/spec/cassettes/Culqi_checkout_autocapture/with_valid_credit_card/refunds_a_payment.yml +0 -207
  25. data/spec/features/culqi_checkout_autocapture_spec.rb +0 -103
  26. data/spec/features/culqi_checkout_spec.rb +0 -96
  27. data/spec/support/culqi_helper.rb +0 -53
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d548bbd540c064028e3c35e7cef61e174088cc2484f26d92e385a022305693df
4
- data.tar.gz: fb7b737217c4543a5054cf760e6866cea920965aba47c25d557fdb2c251250fe
3
+ metadata.gz: f3cd59cbb6af2ed7440da329d4d1e3469b52713ae5571efd8d3faa195755a16e
4
+ data.tar.gz: a917bb5cc087316f47b063e7b9c01bb5e8a7527145e86fae8e35453ee0bd63bb
5
5
  SHA512:
6
- metadata.gz: a379ae5e7851734368a64ae042e9c377bd9e664eec5775e61e52260439c38e2418e3fd7e3d2c03926614de7363cd760c97d59d5f3c1081913218187897ef4efd
7
- data.tar.gz: 0fcb39175df45feebdabbef1657cdf47666b3a791384d85f57c02d40f21bdf20e17c2e57f96fcf1758658ddbc84673c812908d9e0e7da18d3b289259d0ea03c7
6
+ metadata.gz: a1a37781d7f842659712e65b849447ac1fc82fbf73d7a2858c500886ff6990ebc0b57da9a4fa61e0dd391aea8c29c8c449b85502e97e75554166859d78f1f383
7
+ data.tar.gz: e91564cc019279601db13b752f13a9253882c106482c4846bc544463d4ffcc3f801bf33e1adcab3f9c370759cd5f7fccf1ee70dcaa36083c07e4a43aff839426
@@ -15,11 +15,7 @@ Style/BracesAroundHashParameters:
15
15
  Style/ClassVars:
16
16
  Enabled: false
17
17
 
18
- # We need these names for backwards compatability
19
- Style/PredicateName:
20
- Enabled: false
21
-
22
- Style/AccessorMethodName:
18
+ Naming/AccessorMethodName:
23
19
  Enabled: false
24
20
 
25
21
  # This has been used for customization
@@ -38,15 +34,16 @@ Style/WordArray:
38
34
  Style/ConditionalAssignment:
39
35
  Enabled: false
40
36
 
41
- Performance/Count:
42
- Enabled: false
43
-
44
37
  Style/RaiseArgs:
45
38
  Enabled: false
46
39
 
47
40
  Naming/BinaryOperatorParameterName:
48
41
  Enabled: false
49
42
 
43
+ # We need these names for backwards compatability
44
+ Naming/PredicateName:
45
+ Enabled: false
46
+
50
47
  # We can use good judgement here
51
48
  Style/RegexpLiteral:
52
49
  Enabled: false
@@ -55,31 +52,19 @@ Style/RegexpLiteral:
55
52
  Style/AsciiComments:
56
53
  Enabled: false
57
54
 
58
- Lint/EndAlignment:
59
- Enabled: false
60
-
61
- Style/ElseAlignment:
62
- Enabled: false
63
-
64
- Style/IndentationWidth:
65
- Enabled: false
66
-
67
- Style/AlignParameters:
68
- Enabled: false
69
-
70
- Style/ClosingParenthesisIndentation:
55
+ Layout/EndAlignment:
71
56
  Enabled: false
72
57
 
73
- Style/MultilineMethodCallIndentation:
58
+ Layout/ElseAlignment:
74
59
  Enabled: false
75
60
 
76
- Style/IndentArray:
61
+ Layout/IndentationWidth:
77
62
  Enabled: false
78
63
 
79
- Style/IndentHash:
64
+ Layout/ClosingParenthesisIndentation:
80
65
  Enabled: false
81
66
 
82
- Style/AlignHash:
67
+ Layout/MultilineMethodCallIndentation:
83
68
  Enabled: false
84
69
 
85
70
  # From http://relaxed.ruby.style/
@@ -100,7 +85,7 @@ Style/Documentation:
100
85
  Enabled: false
101
86
  StyleGuide: http://relaxed.ruby.style/#styledocumentation
102
87
 
103
- Style/DotPosition:
88
+ Layout/DotPosition:
104
89
  Enabled: false
105
90
  StyleGuide: http://relaxed.ruby.style/#styledotposition
106
91
 
@@ -168,11 +153,11 @@ Style/SingleLineMethods:
168
153
  Enabled: false
169
154
  StyleGuide: http://relaxed.ruby.style/#stylesinglelinemethods
170
155
 
171
- Style/SpaceBeforeBlockBraces:
156
+ Layout/SpaceBeforeBlockBraces:
172
157
  Enabled: false
173
158
  StyleGuide: http://relaxed.ruby.style/#stylespacebeforeblockbraces
174
159
 
175
- Style/SpaceInsideParens:
160
+ Layout/SpaceInsideParens:
176
161
  Enabled: false
177
162
  StyleGuide: http://relaxed.ruby.style/#stylespaceinsideparens
178
163
 
@@ -199,7 +184,7 @@ Lint/AssignmentInCondition:
199
184
  Enabled: false
200
185
  StyleGuide: http://relaxed.ruby.style/#lintassignmentincondition
201
186
 
202
- Lint/HandleExceptions:
187
+ Lint/SuppressedException:
203
188
  Exclude:
204
189
  - 'Rakefile'
205
190
 
@@ -5,30 +5,19 @@ bundler_args: --quiet
5
5
  script:
6
6
  - bundle exec rake
7
7
  rvm:
8
- - 2.4.2
8
+ - 2.6.5
9
+ services:
10
+ - postgresql
11
+ - mysql
9
12
  env:
10
13
  matrix:
11
- - SOLIDUS_BRANCH=v1.2 DB=postgres
12
- - SOLIDUS_BRANCH=v1.3 DB=postgres
13
- - SOLIDUS_BRANCH=v1.4 DB=postgres
14
- - SOLIDUS_BRANCH=v2.0 DB=postgres
15
- - SOLIDUS_BRANCH=v2.1 DB=postgres
16
- - SOLIDUS_BRANCH=v2.2 DB=postgres
17
- - SOLIDUS_BRANCH=v2.3 DB=postgres
18
- - SOLIDUS_BRANCH=v2.4 DB=postgres
19
14
  - SOLIDUS_BRANCH=v2.5 DB=postgres
20
15
  - SOLIDUS_BRANCH=v2.6 DB=postgres
21
16
  - SOLIDUS_BRANCH=v2.7 DB=postgres
17
+ - SOLIDUS_BRANCH=v2.8 DB=postgres
22
18
  - SOLIDUS_BRANCH=master DB=postgres
23
- - SOLIDUS_BRANCH=v1.2 DB=mysql
24
- - SOLIDUS_BRANCH=v1.3 DB=mysql
25
- - SOLIDUS_BRANCH=v1.4 DB=mysql
26
- - SOLIDUS_BRANCH=v2.0 DB=mysql
27
- - SOLIDUS_BRANCH=v2.1 DB=mysql
28
- - SOLIDUS_BRANCH=v2.2 DB=mysql
29
- - SOLIDUS_BRANCH=v2.3 DB=mysql
30
- - SOLIDUS_BRANCH=v2.4 DB=mysql
31
19
  - SOLIDUS_BRANCH=v2.5 DB=mysql
32
20
  - SOLIDUS_BRANCH=v2.6 DB=mysql
33
21
  - SOLIDUS_BRANCH=v2.7 DB=mysql
22
+ - SOLIDUS_BRANCH=v2.8 DB=mysql
34
23
  - SOLIDUS_BRANCH=master DB=mysql
data/Gemfile CHANGED
@@ -16,3 +16,5 @@ gem 'solidus_auth_devise'
16
16
  gem 'sqlite3'
17
17
 
18
18
  gemspec
19
+
20
+ gem 'culqi-ruby', github: 'culqi/culqi-ruby'
@@ -10,7 +10,7 @@ module SolidusCulqi
10
10
  module InstanceMethods
11
11
  def gateway_options
12
12
  options = super
13
- installments = order.installments
13
+ installments = order.try(:installments)
14
14
  options[:installments] = installments if installments
15
15
  options
16
16
  end
@@ -1,3 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Spree::Payment.include SolidusCulqi::InjectInstallmentsConcern
3
+ module PaymentDecorator
4
+ Spree::Payment.include SolidusCulqi::InjectInstallmentsConcern
5
+ end
@@ -1,3 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Spree::PermittedAttributes.singleton_class.prepend SolidusCulqi::PermittedAttributesConcern
3
+ module PermittedAttributesDecorator
4
+ Spree::PermittedAttributes.singleton_class.prepend SolidusCulqi::PermittedAttributesConcern
5
+ end
@@ -1,14 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Solidus
4
- class Gateway::CulqiGateway < SolidusCulqi::Gateway.parent_class
5
- extend SolidusCulqi::Gateway
6
-
4
+ class Gateway::CulqiGateway < Spree::PaymentMethod::CreditCard
7
5
  preference :public_key, :string
8
6
  preference :secret_key, :string
9
7
 
10
- partial_method 'culqi'
11
- provider_method self.class
8
+ def partial_name
9
+ 'culqi'
10
+ end
11
+
12
+ def gateway_class
13
+ self.class
14
+ end
12
15
 
13
16
  def default_currency
14
17
  "PEN"
@@ -59,10 +62,10 @@ module Solidus
59
62
  token = payment.source.gateway_payment_profile_id
60
63
  card_token = generate_card(customer, token)
61
64
  unless customer.nil? || card_token.nil?
62
- payment.source.update({
65
+ payment.source.update(
63
66
  gateway_customer_profile_id: customer,
64
67
  gateway_payment_profile_id: card_token
65
- })
68
+ )
66
69
  end
67
70
  end
68
71
 
@@ -74,7 +77,7 @@ module Solidus
74
77
  end
75
78
 
76
79
  def commit(amount, creditcard, gateway_options, capture)
77
- installments = gateway_options[:installments]
80
+ installments = gateway_options.try(:installments)
78
81
  authorization = creditcard[:gateway_payment_profile_id]
79
82
  charge = Culqi::Charge.create(
80
83
  amount: amount,
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+ require 'net/http'
3
+ require 'fileutils'
4
+ require 'open-uri'
5
+ require 'archive/zip'
6
+
7
+ path = 'https://api.github.com/repos/mozilla/geckodriver/releases/latest'
8
+
9
+ res = Net::HTTP.get_response(URI(path))
10
+ json = JSON.parse(res.body)
11
+ download_url = json['url']
12
+
13
+ filename = 'geckodriver'
14
+
15
+ Dir.chdir platform_install_dir do
16
+ FileUtils.rm_f filename
17
+ File.open(filename, "wb") do |saved_file|
18
+ URI.parse(download_url).open("rb") do |read_file|
19
+ saved_file.write(read_file.read)
20
+ end
21
+ end
22
+
23
+ raise "Could not download #{download_url}" unless File.exists? filename
24
+ Archive::Zip.extract(filename, '.', :overwrite => :all)
25
+ end
26
+ raise "Could not unzip #{filename} to get #{binary_path}" unless File.exists? binary_path
27
+ FileUtils.chmod "ugo+rx", binary_path
28
+ File.open(version_path, 'w') { |file| file.write(download_version) }
@@ -4,5 +4,4 @@ require 'solidus_core'
4
4
  require 'solidus_support'
5
5
  require 'culqi-ruby'
6
6
  require 'solidus_culqi/support'
7
- require 'solidus_culqi/gateway'
8
7
  require 'solidus_culqi/engine'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusCulqi
4
- VERSION = '0.1.1'
4
+ VERSION = '1.0.0'
5
5
  end
@@ -22,15 +22,11 @@ Gem::Specification.new do |s|
22
22
  s.add_dependency 'solidus_core'
23
23
  s.add_dependency 'solidus_support'
24
24
 
25
- s.add_development_dependency 'capybara'
26
25
  s.add_development_dependency 'database_cleaner'
27
26
  s.add_development_dependency 'factory_bot'
28
27
  s.add_development_dependency 'pry'
29
28
  s.add_development_dependency 'rspec-rails'
30
29
  s.add_development_dependency 'rubocop'
31
30
  s.add_development_dependency 'rubocop-rspec'
32
- s.add_development_dependency 'selenium-webdriver'
33
31
  s.add_development_dependency 'simplecov'
34
- s.add_development_dependency 'vcr'
35
- s.add_development_dependency 'webmock'
36
32
  end
@@ -5,14 +5,7 @@ require 'spec_helper'
5
5
  describe Solidus::Gateway::CulqiGateway, type: :model do
6
6
  let!(:gateway) { described_class.new }
7
7
 
8
- context new_gateway: true do
9
- it { gateway.respond_to?(:partial_name) }
10
- it { expect(gateway.partial_name).to eq('culqi') }
11
- it { expect(gateway.gateway_class).to eq(Solidus::Gateway::CulqiGateway) }
12
- end
13
-
14
- context old_gateway: true do
15
- it { expect(gateway.method_type).to eq('culqi') }
16
- it { expect(gateway.provider_class).to eq(Solidus::Gateway::CulqiGateway) }
17
- end
8
+ it { gateway.respond_to?(:partial_name) }
9
+ it { expect(gateway.partial_name).to eq('culqi') }
10
+ it { expect(gateway.gateway_class).to eq(Solidus::Gateway::CulqiGateway) }
18
11
  end
@@ -20,25 +20,8 @@ require File.expand_path('dummy/config/environment.rb', __dir__)
20
20
  require 'rspec/rails'
21
21
  require 'database_cleaner'
22
22
  require 'ffaker'
23
- require 'vcr'
24
- require 'webmock'
25
- require 'capybara/rspec'
26
- require 'selenium-webdriver'
27
23
  require 'pry'
28
24
 
29
- Capybara.register_driver :geckodriver do |app|
30
- ::Selenium::WebDriver::Firefox.driver_path = ENV['DRIVER_PATH']
31
- options = ::Selenium::WebDriver::Firefox::Options.new
32
- options.args << '--headless'
33
-
34
- Capybara::Selenium::Driver.new(app,
35
- browser: :firefox,
36
- options: options)
37
- end
38
-
39
- Capybara.javascript_driver = :geckodriver
40
- Capybara.default_max_wait_time = 30
41
-
42
25
  # Requires supporting ruby files with custom matchers and macros, etc,
43
26
  # in spec/support/ and its subdirectories.
44
27
  Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require f }
@@ -56,8 +39,6 @@ require 'solidus_culqi/factories'
56
39
 
57
40
  RSpec.configure do |config|
58
41
  config.include FactoryBot::Syntax::Methods
59
- config.include CulqiHelper
60
- config.include Spree::TestingSupport::UrlHelpers
61
42
  config.include Spree::TestingSupport::Preferences
62
43
 
63
44
  # Infer an example group's spec type from the file location.
@@ -91,7 +72,6 @@ RSpec.configure do |config|
91
72
  config.before :each do
92
73
  DatabaseCleaner.strategy = RSpec.current_example.metadata[:js] ? :truncation : :transaction
93
74
  DatabaseCleaner.start
94
- reset_spree_preferences
95
75
  end
96
76
 
97
77
  # After each spec clean the database.
@@ -101,18 +81,4 @@ RSpec.configure do |config|
101
81
 
102
82
  config.fail_fast = ENV['FAIL_FAST'] || false
103
83
  config.order = 'random'
104
-
105
- if SolidusCulqi::Support.solidus_earlier('2.3.x')
106
- config.filter_run_excluding new_gateway: true
107
- else
108
- config.filter_run_excluding old_gateway: true
109
- end
110
- end
111
-
112
- VCR.configure do |c|
113
- c.cassette_library_dir = "spec/cassettes"
114
- c.hook_into :webmock
115
- c.ignore_localhost = true
116
- c.configure_rspec_metadata!
117
- c.default_cassette_options = { re_record_interval: 7.days }
118
84
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_culqi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - César Carruitero
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-26 00:00:00.000000000 Z
11
+ date: 2019-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: culqi-ruby
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: capybara
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  - !ruby/object:Gem::Dependency
70
56
  name: database_cleaner
71
57
  requirement: !ruby/object:Gem::Requirement
@@ -150,20 +136,6 @@ dependencies:
150
136
  - - ">="
151
137
  - !ruby/object:Gem::Version
152
138
  version: '0'
153
- - !ruby/object:Gem::Dependency
154
- name: selenium-webdriver
155
- requirement: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- version: '0'
160
- type: :development
161
- prerelease: false
162
- version_requirements: !ruby/object:Gem::Requirement
163
- requirements:
164
- - - ">="
165
- - !ruby/object:Gem::Version
166
- version: '0'
167
139
  - !ruby/object:Gem::Dependency
168
140
  name: simplecov
169
141
  requirement: !ruby/object:Gem::Requirement
@@ -178,34 +150,6 @@ dependencies:
178
150
  - - ">="
179
151
  - !ruby/object:Gem::Version
180
152
  version: '0'
181
- - !ruby/object:Gem::Dependency
182
- name: vcr
183
- requirement: !ruby/object:Gem::Requirement
184
- requirements:
185
- - - ">="
186
- - !ruby/object:Gem::Version
187
- version: '0'
188
- type: :development
189
- prerelease: false
190
- version_requirements: !ruby/object:Gem::Requirement
191
- requirements:
192
- - - ">="
193
- - !ruby/object:Gem::Version
194
- version: '0'
195
- - !ruby/object:Gem::Dependency
196
- name: webmock
197
- requirement: !ruby/object:Gem::Requirement
198
- requirements:
199
- - - ">="
200
- - !ruby/object:Gem::Version
201
- version: '0'
202
- type: :development
203
- prerelease: false
204
- version_requirements: !ruby/object:Gem::Requirement
205
- requirements:
206
- - - ">="
207
- - !ruby/object:Gem::Version
208
- version: '0'
209
153
  description: Adds solidus support for Culqi Gateway
210
154
  email: ccarruitero@protonmail.com
211
155
  executables: []
@@ -225,8 +169,7 @@ files:
225
169
  - app/models/payment_decorator.rb
226
170
  - app/models/permitted_attributes_decorator.rb
227
171
  - app/models/solidus/gateway/culqi_gateway.rb
228
- - app/views/spree/checkout/existing_payment/_culqi.html.erb
229
- - app/views/spree/checkout/payment/_culqi.html.erb
172
+ - bin/geckodriver
230
173
  - bin/rails
231
174
  - config/locales/en.yml
232
175
  - config/routes.rb
@@ -235,21 +178,11 @@ files:
235
178
  - lib/solidus_culqi.rb
236
179
  - lib/solidus_culqi/engine.rb
237
180
  - lib/solidus_culqi/factories.rb
238
- - lib/solidus_culqi/gateway.rb
239
181
  - lib/solidus_culqi/support.rb
240
182
  - lib/solidus_culqi/version.rb
241
183
  - solidus_culqi.gemspec
242
- - spec/cassettes/Culqi_checkout/with_logged_user/store_card_in_wallet.yml
243
- - spec/cassettes/Culqi_checkout/with_unlogged_user/with_process_checkout/capture_payment.yml
244
- - spec/cassettes/Culqi_checkout/with_unlogged_user/with_process_checkout/process_order.yml
245
- - spec/cassettes/Culqi_checkout/with_unlogged_user/with_process_checkout/voids_a_payment.yml
246
- - spec/cassettes/Culqi_checkout_autocapture/with_valid_credit_card/can_process_a_valid_payment.yml
247
- - spec/cassettes/Culqi_checkout_autocapture/with_valid_credit_card/refunds_a_payment.yml
248
- - spec/features/culqi_checkout_autocapture_spec.rb
249
- - spec/features/culqi_checkout_spec.rb
250
184
  - spec/models/culqi_gateway.rb
251
185
  - spec/spec_helper.rb
252
- - spec/support/culqi_helper.rb
253
186
  homepage: https://github.com/ccarruitero/solidus_culqi
254
187
  licenses:
255
188
  - MIT
@@ -269,8 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
269
202
  - !ruby/object:Gem::Version
270
203
  version: '0'
271
204
  requirements: []
272
- rubyforge_project:
273
- rubygems_version: 2.7.6
205
+ rubygems_version: 3.0.6
274
206
  signing_key:
275
207
  specification_version: 4
276
208
  summary: Adds solidus support for Culqi Gateway