solidus_bolt 0.2.0 → 0.3.0

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
  SHA256:
3
- metadata.gz: f9f19675a463bcfbccc9fe98a89fc973d5bdfb34d66a57e48ad3882441877863
4
- data.tar.gz: d79c693485c474464c5563be4710c7c3898031ef879df7d9cb639d9ea203d195
3
+ metadata.gz: f450560bb140e6c7a301138a192a5c8a96016500980580de6866eb1ed79a061d
4
+ data.tar.gz: 84ace4cc0e18e06ddb78b72ff4d06460c1bc0eeed5f7ad1beb1c53e0791a8a8f
5
5
  SHA512:
6
- metadata.gz: 6fe90bea4b8ccd2712913f0ac7241a4b00458b066aa90cceda1adab3a6b0bad29fc0136f116b3edbf39d03d3b586cfbf89c9b071e0477fa4ec1f1501a100da42
7
- data.tar.gz: 646680ba9a1f2a81337135e242696a759ae04f469d442e3b5241d1c255035443a0a066fc05fe220d16481dbf1314c1a2d1b246a97de7e0db47dd7e7aa0e091c3
6
+ metadata.gz: c2be760b6012c698408e74d73a5b312cd3b9117f8defee100ac4f4234fa404efcff9d8553fa42170764772d2a334162ac7a30a0f3a2d4dbeb8544f29ea354547
7
+ data.tar.gz: 171b51d8f32782f81c7d50871161f8a731ccdc308cc9485c21efdb14a03248a8112f27db93cf2a4bebc69a3af2c75aa6389297242c4c00b4dfd2001a9db6b26b
data/README.md CHANGED
@@ -27,8 +27,6 @@ Many of the API calls handled by this gem use the variables set in Bolt Configur
27
27
 
28
28
  ```
29
29
  BOLT_ENVIRONMENT
30
- BOLT_MERCHANT_PUBLIC_ID
31
- BOLT_DIVISION_PUBLIC_ID
32
30
  BOLT_API_KEY
33
31
  BOLT_SIGNING_SECRET
34
32
  BOLT_PUBLISHABLE_KEY
@@ -16,6 +16,8 @@ const tokenize = async (paymentField, paymentMethodId, frontend) => {
16
16
  if (result["token"]) {
17
17
  updateOrder(result, paymentMethodId, frontend)
18
18
  } else {
19
+ const submitButton = document.getElementById("bolt-submit-button")
20
+ submitButton.disabled = false;
19
21
  console.log(`error ${result["type"]}: ${result["message"]}`);
20
22
  }
21
23
  });
@@ -30,8 +30,6 @@ module Spree
30
30
  .require(:solidus_bolt_bolt_configuration)
31
31
  .permit(
32
32
  :environment,
33
- :merchant_public_id,
34
- :division_public_id,
35
33
  :api_key,
36
34
  :signing_secret,
37
35
  :publishable_key
@@ -15,6 +15,14 @@ module SolidusBolt
15
15
 
16
16
  validate :config_can_be_created, on: :create
17
17
 
18
+ def merchant_public_id
19
+ publishable_key.split('.').first
20
+ end
21
+
22
+ def division_public_id
23
+ publishable_key.split('.').second
24
+ end
25
+
18
26
  def self.fetch
19
27
  first_or_create
20
28
  end
@@ -2,7 +2,7 @@
2
2
  <table class="index">
3
3
  <thead>
4
4
  <tr>
5
- <th><%= SolidusBolt::BoltConfiguration.human_attribute_name(:merchant_public_id) %></th>
5
+ <th><%= SolidusBolt::BoltConfiguration.human_attribute_name(:publishable_key) %></th>
6
6
  <th><%= SolidusBolt::BoltConfiguration.human_attribute_name(:environment) %></th>
7
7
  <th><%= SolidusBolt::BoltConfiguration.human_attribute_name(:created_at) %></th>
8
8
  <th><%= SolidusBolt::BoltConfiguration.human_attribute_name(:updated_at) %></th>
@@ -11,7 +11,7 @@
11
11
  </thead>
12
12
  <tbody>
13
13
  <tr>
14
- <td><%= @bolt_configuration.merchant_public_id %></td>
14
+ <td><%= @bolt_configuration.publishable_key %></td>
15
15
  <td><%= @bolt_configuration.environment %></td>
16
16
  <td>
17
17
  <%= @bolt_configuration.created_at.to_s(:long) %>
@@ -6,10 +6,6 @@
6
6
  <div class="col-12">
7
7
  <%= f.label :environment %>
8
8
  <%= f.select :environment, %w[production sandbox staging] %><br />
9
- <%= f.label 'Merchant Public Id' %><br />
10
- <%= f.text_field :merchant_public_id, class: 'fullwidth' %>
11
- <%= f.label 'Division Public Id' %><br />
12
- <%= f.text_field :division_public_id, class: 'fullwidth' %>
13
9
  <%= f.label :api_key %><br />
14
10
  <%= f.text_field :api_key, class: 'fullwidth' %>
15
11
  <%= f.label :signing_secret %><br />
@@ -0,0 +1,6 @@
1
+ class RemoveMerchantIdAndDivisionPublicIdOnBoltConfiguration < ActiveRecord::Migration[6.1]
2
+ def change
3
+ remove_column :solidus_bolt_bolt_configurations, :division_public_id, :string
4
+ remove_column :solidus_bolt_bolt_configurations, :merchant_public_id, :string
5
+ end
6
+ end
data/db/seeds.rb CHANGED
@@ -3,8 +3,6 @@
3
3
  solidus_bolt_configuration = SolidusBolt::BoltConfiguration.fetch
4
4
 
5
5
  solidus_bolt_configuration.environment = ENV.fetch('BOLT_ENVIRONMENT', 'sandbox')
6
- solidus_bolt_configuration.merchant_public_id = ENV['BOLT_MERCHANT_PUBLIC_ID']
7
- solidus_bolt_configuration.division_public_id = ENV['BOLT_DIVISION_PUBLIC_ID']
8
6
  solidus_bolt_configuration.api_key = ENV['BOLT_API_KEY']
9
7
  solidus_bolt_configuration.signing_secret = ENV['BOLT_SIGNING_SECRET']
10
8
  solidus_bolt_configuration.publishable_key = ENV['BOLT_PUBLISHABLE_KEY']
@@ -3,11 +3,9 @@
3
3
  FactoryBot.define do
4
4
  factory :bolt_configuration, class: SolidusBolt::BoltConfiguration do
5
5
  environment { 'sandbox' }
6
- merchant_public_id { SecureRandom.hex }
7
- division_public_id { SecureRandom.hex }
8
6
  api_key { SecureRandom.hex }
9
7
  signing_secret { SecureRandom.hex }
10
- publishable_key { SecureRandom.hex }
8
+ publishable_key { "#{SecureRandom.hex}.#{SecureRandom.hex}.#{SecureRandom.hex}" }
11
9
  end
12
10
 
13
11
  factory :bolt_payment_method, class: SolidusBolt::PaymentMethod do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBolt
4
- VERSION = '0.2.0'
4
+ VERSION = '0.3.0'
5
5
  end
@@ -5,8 +5,6 @@ RSpec.describe SolidusBolt::BoltConfiguration, type: :model do
5
5
  [
6
6
  'id',
7
7
  'environment',
8
- 'merchant_public_id',
9
- 'division_public_id',
10
8
  'api_key',
11
9
  'signing_secret',
12
10
  'publishable_key',
@@ -46,8 +44,6 @@ RSpec.describe SolidusBolt::BoltConfiguration, type: :model do
46
44
  it 'is true for a record with empty fields' do
47
45
  create(
48
46
  :bolt_configuration,
49
- merchant_public_id: '',
50
- division_public_id: '',
51
47
  api_key: '',
52
48
  signing_secret: '',
53
49
  publishable_key: ''
@@ -61,6 +57,20 @@ RSpec.describe SolidusBolt::BoltConfiguration, type: :model do
61
57
  end
62
58
  end
63
59
 
60
+ describe '#merchant_public_id' do
61
+ it 'returns the merchant_public_id' do
62
+ bolt_configuration = create(:bolt_configuration, publishable_key: 'abc.def.ghi')
63
+ expect(bolt_configuration.merchant_public_id).to eq('abc')
64
+ end
65
+ end
66
+
67
+ describe '#division_public_id' do
68
+ it 'returns the division_public_id' do
69
+ bolt_configuration = create(:bolt_configuration, publishable_key: 'abc.def.ghi')
70
+ expect(bolt_configuration.division_public_id).to eq('def')
71
+ end
72
+ end
73
+
64
74
  describe '#environment_url' do
65
75
  context 'when production envornment' do
66
76
  let(:config) { create(:bolt_configuration, environment: 'production') }
@@ -6,8 +6,6 @@ RSpec.describe "Spree::Admin::Bolts", type: :request do
6
6
  let(:bolt_configuration_params) {
7
7
  {
8
8
  environment: 'sandbox',
9
- merchant_public_id: SecureRandom.hex,
10
- division_public_id: SecureRandom.hex,
11
9
  api_key: SecureRandom.hex,
12
10
  signing_secret: SecureRandom.hex,
13
11
  publishable_key: SecureRandom.hex
@@ -56,8 +54,6 @@ RSpec.describe "Spree::Admin::Bolts", type: :request do
56
54
 
57
55
  updated_attributes = SolidusBolt::BoltConfiguration.fetch.attributes.slice(
58
56
  'environment',
59
- 'merchant_public_id',
60
- 'division_public_id',
61
57
  'api_key',
62
58
  'signing_secret',
63
59
  'publishable_key'
@@ -4,13 +4,15 @@ require 'spec_helper'
4
4
 
5
5
  RSpec.describe SolidusBolt::Webhooks::CreateService, :vcr, :bolt_configuration do
6
6
  describe '#call', vcr: true do
7
- subject(:create) { described_class.call(url: 'https://solidus-test.com/webhook', event: event) }
7
+ subject(:create_service) { described_class.call(url: 'https://solidus-test.com/webhook', event: event) }
8
+
9
+ before { SolidusBolt::BoltConfiguration.fetch.update(publishable_key: 'abc.def.ghi') }
8
10
 
9
11
  context 'with an event' do
10
12
  let(:event) { 'payment' }
11
13
 
12
14
  it 'returns a webhook id' do
13
- expect(create).to match hash_including('webhook_id')
15
+ expect(create_service).to match hash_including('webhook_id')
14
16
  end
15
17
  end
16
18
 
@@ -18,7 +20,7 @@ RSpec.describe SolidusBolt::Webhooks::CreateService, :vcr, :bolt_configuration d
18
20
  let(:event) { 'all' }
19
21
 
20
22
  it 'returns a webhook id' do
21
- expect(create).to match hash_including('webhook_id')
23
+ expect(create_service).to match hash_including('webhook_id')
22
24
  end
23
25
  end
24
26
 
@@ -26,7 +28,7 @@ RSpec.describe SolidusBolt::Webhooks::CreateService, :vcr, :bolt_configuration d
26
28
  let(:event) { '' }
27
29
 
28
30
  it 'raises a server error' do
29
- expect{ create }.to raise_error SolidusBolt::ServerError
31
+ expect{ create_service }.to raise_error SolidusBolt::ServerError
30
32
  end
31
33
  end
32
34
  end
@@ -5,8 +5,6 @@ RSpec.configure do |config|
5
5
  solidus_bolt_configuration = SolidusBolt::BoltConfiguration.fetch
6
6
 
7
7
  solidus_bolt_configuration.environment = 'sandbox'
8
- solidus_bolt_configuration.merchant_public_id = ENV['BOLT_MERCHANT_PUBLIC_ID']
9
- solidus_bolt_configuration.division_public_id = ENV['BOLT_DIVISION_PUBLIC_ID']
10
8
  solidus_bolt_configuration.api_key = ENV['BOLT_API_KEY']
11
9
  solidus_bolt_configuration.signing_secret = ENV['BOLT_SIGNING_SECRET']
12
10
  solidus_bolt_configuration.publishable_key = ENV['BOLT_PUBLISHABLE_KEY']
data/spec/support/vcr.rb CHANGED
@@ -20,7 +20,6 @@ VCR.configure do |config|
20
20
 
21
21
  config.filter_sensitive_data('<PUBLISHABLE_KEY>') { SolidusBolt::BoltConfiguration.fetch.publishable_key }
22
22
  config.filter_sensitive_data('<API_KEY>') { SolidusBolt::BoltConfiguration.fetch.api_key }
23
- config.filter_sensitive_data('<DIVISION_ID>') { SolidusBolt::BoltConfiguration.fetch.division_public_id }
24
23
 
25
24
  # Let's you set default VCR record mode with VCR_RECORDE_MODE=all for re-recording
26
25
  # episodes. :once is VCR default
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.2.0
4
+ version: 0.3.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-22 00:00:00.000000000 Z
13
+ date: 2022-07-25 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-rails
@@ -330,6 +330,7 @@ files:
330
330
  - db/migrate/20220530102107_rename_bolt_configuration_merchant_id_to_division_public_id.rb
331
331
  - db/migrate/20220531075527_update_bolt_configuration_environment_column_restrictions.rb
332
332
  - db/migrate/20220629131950_remove_bearer_token_on_solidus_bolt_bolt_configuration.rb
333
+ - db/migrate/20220725133701_remove_merchant_id_and_division_public_id_on_bolt_configuration.rb
333
334
  - db/seeds.rb
334
335
  - lib/generators/solidus_bolt/install/install_generator.rb
335
336
  - lib/generators/solidus_bolt/install/templates/initializer.rb