solidus_bolt 0.5.0 → 0.7.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 85a81224dbf00b809093c50581fa790f56f6389a85753a002eff55ed149ddbff
4
- data.tar.gz: 84ee9afd0a6dd580df9d3ffcbe2550a3e957d5c43fafc209e42cd79965caf9c2
3
+ metadata.gz: 89aae31a58ea5e33c4ec759f8f3ccca8c9cde9c397986074ca0d980b701b6281
4
+ data.tar.gz: 1f02b9e4d932af604eabb21bc3fe5af3cb2e7e9c6991d431a6715ced090890e1
5
5
  SHA512:
6
- metadata.gz: ed702363808663ef10223d943f670c2bc90b248be1f4953b9288b631b36ec9a40908d1c7d3b295bb6f5cbf27b92820845dbe49e8f51a3336a1da68372c247f18
7
- data.tar.gz: 2398a99717a2d8f76b1b20c790062b5543d0f7323d90dc55637814bbeadac6d55c3078008a0213f2c6461630dd51362316d5d1b2a2c987fe37acac41cd4e34e8
6
+ metadata.gz: 6ca7162deec70cf4296d2a14ff3bc234c7ddb8a97619cb9a26e33092cc21621283bf36a0d866f000ba6ed2358afbfee9c728cc8255aed272184c66d1d9f853e1
7
+ data.tar.gz: d216520effb6569e31f6685e7472047523453ff68e0b15bed56b5a22a64aa712f5e888ff791a25c75a04de73b656d3a640f54e3850238534ec902c7bbbdf2261
data/Gemfile CHANGED
@@ -4,7 +4,13 @@ source 'https://rubygems.org'
4
4
  git_source(:github) { |repo| "https://github.com/#{repo}.git" }
5
5
 
6
6
  branch = ENV.fetch('SOLIDUS_BRANCH', 'master')
7
- gem 'solidus', github: 'solidusio/solidus', branch: branch
7
+ solidus_git, solidus_frontend_git = if (branch == 'master') || (branch >= 'v3.2')
8
+ %w[solidusio/solidus solidusio/solidus_frontend]
9
+ else
10
+ %w[solidusio/solidus] * 2
11
+ end
12
+ gem 'solidus', github: solidus_git, branch: branch
13
+ gem 'solidus_frontend', github: solidus_frontend_git, branch: branch
8
14
 
9
15
  # Needed to help Bundler figure out how to resolve dependencies,
10
16
  # otherwise it takes forever to resolve them.
@@ -3,21 +3,23 @@
3
3
  module Spree
4
4
  module Admin
5
5
  class BoltCallbackUrlsController < Spree::Admin::BaseController
6
- def new
6
+ def edit
7
7
  callback_urls = SolidusBolt::MerchantConfiguration::GetCallbackUrlsService.call
8
8
 
9
- @oauth_logout = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_logout' }['url']
10
- @oauth_redirect = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_redirect' }['url']
9
+ @oauth_logout = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_logout' }&.dig('url')
10
+ @oauth_redirect = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_redirect' }&.dig('url')
11
+ @get_account = callback_urls['callback_urls'].find { |c| c['type'] == 'get_account' }&.dig('url')
11
12
  end
12
13
 
13
14
  def update
14
15
  SolidusBolt::MerchantConfiguration::SetCallbackUrlsService.call(
15
16
  oauth_logout: params[:bolt_callback_urls][:oauth_logout],
16
- oauth_redirect: params[:bolt_callback_urls][:oauth_redirect]
17
+ oauth_redirect: params[:bolt_callback_urls][:oauth_redirect],
18
+ get_account: params[:bolt_callback_urls][:get_account]
17
19
  )
18
20
  flash[:success] = "Successfully updated callback urls."
19
21
 
20
- redirect_to new_admin_bolt_callback_urls_path
22
+ redirect_to edit_admin_bolt_callback_urls_path
21
23
  rescue SolidusBolt::ServerError => e
22
24
  flash[:error] = e.message
23
25
 
@@ -10,8 +10,8 @@ module SolidusBolt
10
10
  raise NotImplementedError
11
11
  end
12
12
 
13
- def self.call(*args)
14
- new(*args).call
13
+ def self.call(*args, **kwargs, &block)
14
+ new(*args, **kwargs, &block).call
15
15
  end
16
16
 
17
17
  private
@@ -7,11 +7,15 @@
7
7
  <div class="row">
8
8
  <div class="col-12">
9
9
  <%= f.label :oauth_redirect %>
10
- <%= f.text_field :oauth_redirect, class: 'fullwidth', value: @oauth_redirect || 'https://domain.com/webhooks/bolt' %>
10
+ <%= f.text_field :oauth_redirect, class: 'fullwidth', value: @oauth_redirect || 'https://domain.com/users/auth/bolt' %>
11
11
  </div>
12
12
  <div class="col-12">
13
13
  <%= f.label :oauth_logout %>
14
- <%= f.text_field :oauth_logout, class: 'fullwidth', value: @oauth_logout || 'https://domain.com/webhooks/bolt' %>
14
+ <%= f.text_field :oauth_logout, class: 'fullwidth', value: @oauth_logout || 'https://domain.com/bolt_logout' %>
15
+ </div>
16
+ <div class="col-12">
17
+ <%= f.label :get_account %>
18
+ <%= f.text_field :get_account, class: 'fullwidth', value: @get_account || 'https://domain.com/api/accounts/bolt' %>
15
19
  </div>
16
20
  </div>
17
21
  <div class="row p-2 justify-content-center">
@@ -12,7 +12,7 @@
12
12
  </li>
13
13
  <% else %>
14
14
  <li>
15
- <%= link_to 'Configure Callbacks URLs', new_admin_bolt_callback_urls_path, class: 'btn btn-primary' %>
15
+ <%= link_to 'Configure Callbacks URLs', edit_admin_bolt_callback_urls_path, class: 'btn btn-primary' %>
16
16
  </li>
17
17
  <li>
18
18
  <%= link_to 'Configure Webhooks', new_admin_bolt_webhook_path, class: 'btn btn-primary' %>
data/bin/sandbox CHANGED
@@ -49,11 +49,18 @@ fi
49
49
 
50
50
  cd ./sandbox
51
51
  cat <<RUBY >> Gemfile
52
- gem 'solidus', github: 'solidusio/solidus', branch: '$BRANCH'
52
+ gem "solidus_core", git: "https://github.com/solidusio/solidus.git", ref: '$BRANCH'
53
+ gem "solidus_backend", git: "https://github.com/solidusio/solidus.git", ref: "$BRANCH"
54
+ gem "solidus_api", git: "https://github.com/solidusio/solidus.git", ref: "$BRANCH"
55
+ gem "solidus_sample", git: "https://github.com/solidusio/solidus.git", ref: "$BRANCH"
56
+ gem "solidus_frontend", git: "https://github.com/solidusio/solidus_frontend.git", ref: "$BRANCH"
57
+
53
58
  gem 'solidus_auth_devise', '>= 2.1.0'
54
59
  gem 'rails-i18n'
55
60
  gem 'solidus_i18n'
56
61
 
62
+ gem 'net-smtp', require: false
63
+
57
64
  gem '$extension_name', path: '..'
58
65
 
59
66
  group :test, :development do
data/config/routes.rb CHANGED
@@ -4,7 +4,7 @@ Spree::Core::Engine.routes.draw do
4
4
  namespace :admin do
5
5
  resource :bolt, only: [:show, :edit, :update]
6
6
  resource :bolt_webhook, only: [:new, :create]
7
- resource :bolt_callback_urls, only: [:new, :update]
7
+ resource :bolt_callback_urls, only: [:edit, :update]
8
8
  end
9
9
 
10
10
  post '/webhooks/bolt', to: '/solidus_bolt/webhooks#update'
@@ -40,26 +40,46 @@ module SolidusBolt
40
40
  solidus_social_initializer_file = 'config/initializers/solidus_social.rb'
41
41
  return if File.readlines(solidus_social_initializer_file).grep(/bolt/).any?
42
42
 
43
- matcher = /amazon: {\n\s*api_key:\sENV\['AMAZON_API_KEY'\],\n\s*api_secret:\sENV\['AMAZON_API_SECRET'\],\n\s*}\n\s*}/m # rubocop:disable Layout/LineLength
43
+ matcher = /(Spree::SocialConfig\.configure\sdo\s\|config\|.*progname\s=\s'omniauth')/m
44
+ # rubocop:disable Layout/HeredocIndentation
44
45
  a = <<~BOLT_PROVIDER
45
- amazon: {
46
- api_key: ENV['AMAZON_API_KEY'],
47
- api_secret: ENV['AMAZON_API_SECRET'],
48
- }
49
- }
46
+ Rails.application.config.to_prepare do
47
+ Spree::SocialConfig.configure do |c|
48
+ c.use_static_preferences!
49
+
50
+ c.providers = {}
50
51
 
51
52
  begin
52
- config.providers[:bolt] = {
53
+ c.providers[:bolt] = {
53
54
  api_key: SolidusBolt::BoltConfiguration.fetch.publishable_key,
54
55
  api_secret: SolidusBolt::BoltConfiguration.fetch.api_key,
55
56
  }
56
57
  rescue StandardError
57
58
  end
59
+ end
60
+
61
+ SolidusSocial.init_providers
62
+ end
63
+
64
+ OmniAuth.config.logger = Logger.new(STDOUT)
65
+ OmniAuth.logger.progname = 'omniauth'
66
+ OmniAuth.config.allowed_request_methods = [:get]
58
67
  BOLT_PROVIDER
68
+ # rubocop:enable Layout/HeredocIndentation
59
69
 
60
70
  gsub_file solidus_social_initializer_file, matcher, a
61
71
  end
62
72
 
73
+ def add_omniauth_middleware
74
+ bolt_middleware_initializer = <<~BOLT_PROVIDER
75
+ Rails.application.config.middleware.use OmniAuth::Builder do
76
+ provider :bolt, publishable_key: SolidusBolt::BoltConfiguration.fetch.publishable_key,
77
+ api_key: SolidusBolt::BoltConfiguration.fetch.api_key
78
+ end
79
+ BOLT_PROVIDER
80
+ append_file 'config/initializers/solidus_social.rb', bolt_middleware_initializer
81
+ end
82
+
63
83
  def run_migrations
64
84
  run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask('Would you like to run the migrations now? [Y/n]')) # rubocop:disable Layout/LineLength
65
85
  if run_migrations
@@ -12,17 +12,19 @@ module SolidusBolt
12
12
  engine_name 'solidus_bolt'
13
13
 
14
14
  initializer "solidus_bolt.add_static_preference", after: "spree.register.payment_methods" do |app|
15
- app.config.spree.payment_methods << SolidusBolt::PaymentMethod
16
- Spree::Config.static_model_preferences.add(
17
- SolidusBolt::PaymentMethod,
18
- 'bolt_credentials',
19
- bolt_credentials_hash
20
- )
21
- Spree::Config.static_model_preferences.add(
22
- SolidusBolt::PaymentMethod,
23
- 'bolt_config_credentials',
24
- bolt_config_credentials_hash
25
- )
15
+ app.config.spree.payment_methods << 'SolidusBolt::PaymentMethod'
16
+ app.config.to_prepare do
17
+ Spree::Config.static_model_preferences.add(
18
+ SolidusBolt::PaymentMethod,
19
+ 'bolt_credentials',
20
+ ::SolidusBolt::Engine.bolt_credentials_hash
21
+ )
22
+ Spree::Config.static_model_preferences.add(
23
+ SolidusBolt::PaymentMethod,
24
+ 'bolt_config_credentials',
25
+ ::SolidusBolt::Engine.bolt_config_credentials_hash
26
+ )
27
+ end
26
28
 
27
29
  Spree::PermittedAttributes.source_attributes.concat(%i[
28
30
  card_token card_last4 card_bin card_number card_expiration card_postal_code create_bolt_account
@@ -34,29 +36,29 @@ module SolidusBolt
34
36
  g.test_framework :rspec
35
37
  end
36
38
 
37
- private
38
-
39
- def bolt_credentials_hash
40
- {
41
- bolt_api_key: ENV['BOLT_API_KEY'],
42
- bolt_signing_secret: ENV['BOLT_SIGNING_SECRET'],
43
- bolt_publishable_key: ENV['BOLT_PUBLISHABLE_KEY'],
44
- }
45
- end
46
-
47
- def bolt_config_credentials_hash
48
- begin
49
- bolt_config = SolidusBolt::BoltConfiguration.fetch
50
- rescue ActiveRecord::StatementInvalid
51
- bolt_config = nil
52
- ensure
53
- bolt_config_hash = {
54
- bolt_api_key: bolt_config&.api_key,
55
- bolt_signing_secret: bolt_config&.signing_secret,
56
- bolt_publishable_key: bolt_config&.publishable_key,
39
+ class << self
40
+ def bolt_credentials_hash
41
+ {
42
+ bolt_api_key: ENV['BOLT_API_KEY'],
43
+ bolt_signing_secret: ENV['BOLT_SIGNING_SECRET'],
44
+ bolt_publishable_key: ENV['BOLT_PUBLISHABLE_KEY'],
57
45
  }
58
46
  end
59
- bolt_config_hash
47
+
48
+ def bolt_config_credentials_hash
49
+ begin
50
+ bolt_config = SolidusBolt::BoltConfiguration.fetch
51
+ rescue ActiveRecord::StatementInvalid
52
+ bolt_config = nil
53
+ ensure
54
+ bolt_config_hash = {
55
+ bolt_api_key: bolt_config&.api_key,
56
+ bolt_signing_secret: bolt_config&.signing_secret,
57
+ bolt_publishable_key: bolt_config&.publishable_key,
58
+ }
59
+ end
60
+ bolt_config_hash
61
+ end
60
62
  end
61
63
  end
62
64
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBolt
4
- VERSION = '0.5.0'
4
+ VERSION = '0.7.1'
5
5
  end
data/solidus_bolt.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |spec|
16
16
  spec.metadata['source_code_uri'] = 'https://github.com/nebulab/solidus_bolt'
17
17
  spec.metadata['changelog_uri'] = 'https://github.com/nebulab/solidus_bolt/blob/master/CHANGELOG.md'
18
18
 
19
- spec.required_ruby_version = Gem::Requirement.new('~> 2.5')
19
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.5')
20
20
 
21
21
  # Specify which files should be added to the gem when it is released.
22
22
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -39,6 +39,7 @@ Gem::Specification.new do |spec|
39
39
  spec.add_dependency 'solidus_support', '~> 0.5'
40
40
  spec.add_dependency 'tweetnacl'
41
41
 
42
+ spec.add_development_dependency 'net-smtp'
42
43
  spec.add_development_dependency 'pry'
43
44
  spec.add_development_dependency 'solidus_dev_support', '~> 2.5'
44
45
  spec.add_development_dependency 'vcr'
@@ -5,7 +5,7 @@ http_interactions:
5
5
  uri: https://api-sandbox.bolt.com/v1/merchant/callbacks
6
6
  body:
7
7
  encoding: UTF-8
8
- string: '{"division_id":"Rq4qB1QajYLn","callback_urls":[{"type":"oauth_redirect","url":"http://localhost:3000/users/auth/bolt"},{"type":"oauth_logout","url":"http://localhost:3000//user/spree_user/logout"}]}'
8
+ string: '{"division_id":"<DIVISION_PUBLIC_ID>","callback_urls":[{"type":"oauth_redirect","url":"http://localhost:3000/users/auth/bolt"},{"type":"oauth_logout","url":"http://localhost:3000/user/spree_user/logout"},{"type":"get_account","url":"http://localhost:3000/api/accounts/bolt"}]}'
9
9
  headers:
10
10
  Content-Type:
11
11
  - application/json
@@ -23,7 +23,7 @@ http_interactions:
23
23
  message: OK
24
24
  headers:
25
25
  Date:
26
- - Tue, 26 Jul 2022 21:17:15 GMT
26
+ - Wed, 17 Aug 2022 15:39:28 GMT
27
27
  Content-Type:
28
28
  - application/json; charset=UTF-8
29
29
  Content-Length:
@@ -33,22 +33,22 @@ http_interactions:
33
33
  Public-Key-Pins-Report-Only:
34
34
  - max-age=2592000;pin-sha256="OGAVOYhLZd3ADKYGFZOED1c5m1ObMlRv9PyIWrO4Nd0=";pin-sha256="RRM1dGqnDFsCJXBTHky16vi1obOlCgFFn/yOhI/y+ho=";pin-sha256="IXHYSIdST+XY22J5ivybYkntMIfjA5P6pMKX2hWG1BE=";report-uri="https://77aa1bd121ef22d50247a23390ce6cff.report-uri.io/r/default/hpkp/reportOnly"
35
35
  Set-Cookie:
36
- - trk=ea8f518e-f41d-4b8c-9615-161bff916a0f; Path=/; Max-Age=31536000; HttpOnly;
36
+ - trk=4702ac8b-e387-4557-a2d2-eecc98fb0b81; Path=/; Max-Age=31536000; HttpOnly;
37
37
  Secure; SameSite=None
38
38
  Strict-Transport-Security:
39
39
  - max-age=31536000; includeSubDomains; preload
40
40
  X-Bolt-Api-Version:
41
41
  - '2022-01-01'
42
42
  X-Bolt-Trace-Id:
43
- - Root=1-62e059db-307d2def557ae7d63cda1f93
43
+ - Root=1-62fd0bb0-24e313d41fce5fd10e2eeeda
44
44
  X-Device-Id:
45
- - 65fb9d676354668c7128f58217c94230e32303007b66559078fee6aefb88e8a4
45
+ - 2a43c9a2f4fc3f8e06bc3007f8c13908180b0c7555c38d14a7ad494f0a6a4ddb
46
46
  X-Envoy-Upstream-Service-Time:
47
- - '37'
47
+ - '45'
48
48
  Server:
49
49
  - envoy
50
50
  body:
51
51
  encoding: UTF-8
52
52
  string: 'null'
53
- recorded_at: Tue, 26 Jul 2022 21:17:15 GMT
53
+ recorded_at: Wed, 17 Aug 2022 15:39:28 GMT
54
54
  recorded_with: VCR 6.1.0
@@ -3,12 +3,13 @@
3
3
  require 'spec_helper'
4
4
 
5
5
  RSpec.describe SolidusBolt::MerchantConfiguration::SetCallbackUrlsService, :vcr, :bolt_configuration do
6
- subject(:api) { described_class.new(params) }
6
+ subject(:api) { described_class.new(**params) }
7
7
 
8
8
  let(:params) {
9
9
  {
10
10
  oauth_redirect: 'http://localhost:3000/users/auth/bolt',
11
- oauth_logout: 'http://localhost:3000//user/spree_user/logout'
11
+ oauth_logout: 'http://localhost:3000/user/spree_user/logout',
12
+ get_account: 'http://localhost:3000/api/accounts/bolt'
12
13
  }
13
14
  }
14
15
 
data/spec/spec_helper.rb CHANGED
@@ -8,6 +8,7 @@ require 'solidus_dev_support/rspec/coverage'
8
8
  require 'pry'
9
9
  require 'vcr'
10
10
  require 'webmock/rspec'
11
+ require 'net/smtp'
11
12
 
12
13
  # Create the dummy app if it's still missing.
13
14
  dummy_env = "#{__dir__}/dummy/config/environment.rb"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solidus_bolt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - piyushswain
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: exe
12
12
  cert_chain: []
13
- date: 2022-07-28 00:00:00.000000000 Z
13
+ date: 2022-09-01 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-rails
@@ -158,6 +158,20 @@ dependencies:
158
158
  - - ">="
159
159
  - !ruby/object:Gem::Version
160
160
  version: '0'
161
+ - !ruby/object:Gem::Dependency
162
+ name: net-smtp
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - ">="
166
+ - !ruby/object:Gem::Version
167
+ version: '0'
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - ">="
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
161
175
  - !ruby/object:Gem::Dependency
162
176
  name: pry
163
177
  requirement: !ruby/object:Gem::Requirement
@@ -283,7 +297,7 @@ files:
283
297
  - app/services/solidus_bolt/users/sync_addresses_service.rb
284
298
  - app/services/solidus_bolt/users/sync_payment_sources_service.rb
285
299
  - app/services/solidus_bolt/webhooks/create_service.rb
286
- - app/views/spree/admin/bolt_callback_urls/new.html.erb
300
+ - app/views/spree/admin/bolt_callback_urls/edit.html.erb
287
301
  - app/views/spree/admin/bolt_webhooks/new.html.erb
288
302
  - app/views/spree/admin/bolts/_configuration.html.erb
289
303
  - app/views/spree/admin/bolts/_form.html.erb
@@ -416,7 +430,7 @@ require_paths:
416
430
  - lib
417
431
  required_ruby_version: !ruby/object:Gem::Requirement
418
432
  requirements:
419
- - - "~>"
433
+ - - ">="
420
434
  - !ruby/object:Gem::Version
421
435
  version: '2.5'
422
436
  required_rubygems_version: !ruby/object:Gem::Requirement