solidus_bolt 0.6.0 → 0.7.0

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: 3d91d355d44749ba39444cd212cf3358af9d4fdc765c0aef0331fc0ea363066e
4
- data.tar.gz: d0a97484c2dd27d7ab078480b3a57f979bb438ca714322bc3dd6ba8388dec066
3
+ metadata.gz: 7a29718f8e31f9d466f5699cc9d10bb6052ce24f0e85bc2a9cead45d5ba3a3e6
4
+ data.tar.gz: 037250f96ab9782723363d2137e199a97488bccec18e43a615244761e894530c
5
5
  SHA512:
6
- metadata.gz: 6499d04e3f47a046fbca944f1d7ad0f8a6181c299175fa5b1734960d912295f47b68596c2eb103651edf40147948a3cba211df1e69c9746d6367165b0bb176b1
7
- data.tar.gz: c2d55795d7683a04debbe3d3d18f3a5f46a581759d12d990941af05204fd4281245e238667526ef4ce21d5cf1b54cccbe9c814359729818b285072e3c6467a98
6
+ metadata.gz: 586deaa3255d4ec43442474494397c07207fada7411ab8866c21131467645dd0803f21d4e2f8c583e2aceeed7063deafe939b6c882360e3657899c260899b9fa
7
+ data.tar.gz: ad351e9d4f378fd93c9dfa09993586b0cd3506bfdf0d9fdcbe088d6a4234abf0c676d4c9f2f69e21c36c291e7e785af3a41c1df6a0794c8ac751c9d3419fdfc8
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.
@@ -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
 
@@ -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">
data/bin/sandbox CHANGED
@@ -54,6 +54,8 @@ gem 'solidus_auth_devise', '>= 2.1.0'
54
54
  gem 'rails-i18n'
55
55
  gem 'solidus_i18n'
56
56
 
57
+ gem 'net-smtp', require: false
58
+
57
59
  gem '$extension_name', path: '..'
58
60
 
59
61
  group :test, :development do
@@ -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.6.0'
4
+ VERSION = '0.7.0'
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.6.0
4
+ version: 0.7.0
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-08-31 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