solidus_bolt 0.6.0 → 0.7.2
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 +4 -4
- data/Gemfile +7 -1
- data/app/controllers/spree/admin/bolt_callback_urls_controller.rb +3 -1
- data/app/services/solidus_bolt/base_service.rb +2 -2
- data/app/views/spree/admin/bolt_callback_urls/edit.html.erb +6 -2
- data/bin/sandbox +8 -1
- data/lib/generators/solidus_bolt/install/install_generator.rb +34 -7
- data/lib/solidus_bolt/engine.rb +34 -32
- data/lib/solidus_bolt/version.rb +1 -1
- data/solidus_bolt.gemspec +2 -1
- data/spec/fixtures/vcr_cassettes/SolidusBolt_MerchantConfiguration_SetCallbackUrlsService/_call/receives_the_correct_response.yml +7 -7
- data/spec/services/solidus_bolt/merchant_configuration/set_callback_urls_service_spec.rb +3 -2
- data/spec/spec_helper.rb +1 -0
- metadata +18 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 5ac6a8e1e336a25d7883473fdeb62b1cf7afd383e94bf3c4dcdc2c3b0552d444
|
|
4
|
+
data.tar.gz: b9e86cdc1b948154ee3dc3dd6e24e46e4167608310cca58e50adee0eacf7aa54
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 46b8c430be3db091703dc445c6a609cd543a9e4b234bfdf7744d7b7450364b2b4bb4bb064b3ce090b4833aaa9b2c82d2cfeb674a556627200f7a07681d862a45
|
|
7
|
+
data.tar.gz: d509775d709db1695574fa5f735e59a41789088a0509c13876ab20cec66b3dc66ca6ccf4beb00ad861bc43a0a6c18857427b7ea649151fc52dfdc1539eb9eae1
|
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
|
-
|
|
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.
|
|
@@ -8,12 +8,14 @@ module Spree
|
|
|
8
8
|
|
|
9
9
|
@oauth_logout = callback_urls['callback_urls'].find { |c| c['type'] == 'oauth_logout' }&.dig('url')
|
|
10
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
|
|
|
@@ -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/
|
|
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/
|
|
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">
|
data/bin/sandbox
CHANGED
|
@@ -49,11 +49,18 @@ fi
|
|
|
49
49
|
|
|
50
50
|
cd ./sandbox
|
|
51
51
|
cat <<RUBY >> Gemfile
|
|
52
|
-
gem
|
|
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
|
|
@@ -40,26 +40,53 @@ 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 = /
|
|
43
|
+
matcher = /(Spree::SocialConfig\.configure\sdo\s\|config\|.*progname\s=\s'omniauth')/m
|
|
44
|
+
# rubocop:disable Layout/HeredocIndentation
|
|
44
45
|
a = <<~BOLT_PROVIDER
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
-
|
|
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
|
+
bolt_configuration = SolidusBolt::BoltConfiguration.fetch
|
|
77
|
+
|
|
78
|
+
if bolt_configuration&.publishable_key.present? && bolt_configuration&.api_key.present?
|
|
79
|
+
provider :bolt, publishable_key: bolt_configuration.publishable_key,
|
|
80
|
+
api_key: bolt_configuration.api_key
|
|
81
|
+
else
|
|
82
|
+
Rails.logger.warn 'Bolt configuration missing'
|
|
83
|
+
end
|
|
84
|
+
rescue StandardError
|
|
85
|
+
end
|
|
86
|
+
BOLT_PROVIDER
|
|
87
|
+
append_file 'config/initializers/solidus_social.rb', bolt_middleware_initializer
|
|
88
|
+
end
|
|
89
|
+
|
|
63
90
|
def run_migrations
|
|
64
91
|
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
92
|
if run_migrations
|
data/lib/solidus_bolt/engine.rb
CHANGED
|
@@ -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
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
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
|
-
|
|
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
|
data/lib/solidus_bolt/version.rb
CHANGED
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('
|
|
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":"
|
|
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
|
-
-
|
|
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=
|
|
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-
|
|
43
|
+
- Root=1-62fd0bb0-24e313d41fce5fd10e2eeeda
|
|
44
44
|
X-Device-Id:
|
|
45
|
-
-
|
|
45
|
+
- 2a43c9a2f4fc3f8e06bc3007f8c13908180b0c7555c38d14a7ad494f0a6a4ddb
|
|
46
46
|
X-Envoy-Upstream-Service-Time:
|
|
47
|
-
- '
|
|
47
|
+
- '45'
|
|
48
48
|
Server:
|
|
49
49
|
- envoy
|
|
50
50
|
body:
|
|
51
51
|
encoding: UTF-8
|
|
52
52
|
string: 'null'
|
|
53
|
-
recorded_at:
|
|
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
|
|
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
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.
|
|
4
|
+
version: 0.7.2
|
|
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-
|
|
13
|
+
date: 2022-09-05 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
|
|
@@ -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
|
|
@@ -425,7 +439,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
425
439
|
- !ruby/object:Gem::Version
|
|
426
440
|
version: '0'
|
|
427
441
|
requirements: []
|
|
428
|
-
rubygems_version: 3.
|
|
442
|
+
rubygems_version: 3.3.17
|
|
429
443
|
signing_key:
|
|
430
444
|
specification_version: 4
|
|
431
445
|
summary: Solidus extension for using Bolt Checkout Service.
|