solidus_bolt 0.1.0 → 0.2.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: 742875df47de9e63b63e2abb6d986c8e6fda7b1f5298fc49be6e04d06cd5a050
4
- data.tar.gz: 8e3f173daca61cb9b03b63ee26d70e06ce0a5462c3803fc9c65150fa1da13cc7
3
+ metadata.gz: f9f19675a463bcfbccc9fe98a89fc973d5bdfb34d66a57e48ad3882441877863
4
+ data.tar.gz: d79c693485c474464c5563be4710c7c3898031ef879df7d9cb639d9ea203d195
5
5
  SHA512:
6
- metadata.gz: a0f3cea501cbc8086af33a9d2871593d4e30e6495807ad2fad05f029711086ec8f2b2d3b6e44149fa838403536129d5a5038347a23a87ff99627a80e3274cd87
7
- data.tar.gz: 90901739f3d6cc165309ef2f0528f6f4897ac8598c8434e01322bbae208a5cd58f1154b6a2bddebd57e5b75808010961f3a710eac83f267df38400d6dcbbb248
6
+ metadata.gz: 6fe90bea4b8ccd2712913f0ac7241a4b00458b066aa90cceda1adab3a6b0bad29fc0136f116b3edbf39d03d3b586cfbf89c9b071e0477fa4ec1f1501a100da42
7
+ data.tar.gz: 646680ba9a1f2a81337135e242696a759ae04f469d442e3b5241d1c255035443a0a066fc05fe220d16481dbf1314c1a2d1b246a97de7e0db47dd7e7aa0e091c3
@@ -75,6 +75,8 @@ document.addEventListener("DOMContentLoaded", async function () {
75
75
  if(boltContainer.dataset["boltUserSignedIn"] != "true") {
76
76
  accountCheckbox = boltEmbedded.create("account_checkbox");
77
77
  accountCheckbox.on("change", checked => createBoltAccount = checked);
78
+ } else {
79
+ createBoltAccount = true;
78
80
  }
79
81
  cardButton.addEventListener("click", () => {
80
82
  const submitButton = document.getElementById("bolt-submit-button")
@@ -7,6 +7,7 @@ module SolidusBolt
7
7
  total_amount: display_total.cents,
8
8
  order_reference: number,
9
9
  currency: currency,
10
+ shipments: bolt_shipments_payload,
10
11
  items: line_items.map do |line_item|
11
12
  {
12
13
  sku: line_item.sku,
@@ -35,6 +36,10 @@ module SolidusBolt
35
36
 
36
37
  private
37
38
 
39
+ def bolt_shipments_payload
40
+ shipments.map(&:bolt_shipment)
41
+ end
42
+
38
43
  def cents(float)
39
44
  (float * 100).to_i
40
45
  end
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SolidusBolt
4
+ module ShipmentDecorator
5
+ def bolt_shipment
6
+ {
7
+ shipping_address: order.ship_address.bolt_address(order.email),
8
+ reference: number,
9
+ cost: display_total.cents
10
+ }
11
+ end
12
+
13
+ Spree::Shipment.prepend(self)
14
+ end
15
+ end
@@ -26,6 +26,12 @@ module SolidusBolt
26
26
  bolt_config.environment_url
27
27
  end
28
28
 
29
+ def try_void(payment)
30
+ return false unless payment.source.can_void?(payment)
31
+
32
+ gateway.void(payment.response_code, originator: payment)
33
+ end
34
+
29
35
  private
30
36
 
31
37
  def bolt_config
data/db/seeds.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  solidus_bolt_configuration = SolidusBolt::BoltConfiguration.fetch
4
4
 
5
- solidus_bolt_configuration.environment = ENV['BOLT_ENVIRONMENT']
5
+ solidus_bolt_configuration.environment = ENV.fetch('BOLT_ENVIRONMENT', 'sandbox')
6
6
  solidus_bolt_configuration.merchant_public_id = ENV['BOLT_MERCHANT_PUBLIC_ID']
7
7
  solidus_bolt_configuration.division_public_id = ENV['BOLT_DIVISION_PUBLIC_ID']
8
8
  solidus_bolt_configuration.api_key = ENV['BOLT_API_KEY']
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidusBolt
4
- VERSION = '0.1.0'
4
+ VERSION = '0.2.0'
5
5
  end
data/solidus_bolt.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_dependency 'httparty'
34
34
  spec.add_dependency 'multi_json'
35
35
  spec.add_dependency 'omniauth-bolt'
36
- spec.add_dependency 'rails', ['>0.a', '< 7.a']
36
+ spec.add_dependency 'rails'
37
37
  spec.add_dependency 'solidus_auth_devise'
38
38
  spec.add_dependency 'solidus_core', ['>= 2.0.0', '< 4']
39
39
  spec.add_dependency 'solidus_social'
@@ -9,6 +9,7 @@ RSpec.describe SolidusBolt::OrderDecorator do
9
9
  total_amount: (order.total * 100).to_i,
10
10
  order_reference: order.number,
11
11
  currency: 'USD',
12
+ shipments: array_including(hash_including(:reference)),
12
13
  items: [{
13
14
  sku: order.line_items.first.sku,
14
15
  name: order.line_items.first.name,
@@ -16,7 +17,8 @@ RSpec.describe SolidusBolt::OrderDecorator do
16
17
  quantity: 1
17
18
  }]
18
19
  }
19
- expect(order.bolt_cart).to eq(result)
20
+
21
+ expect(order.bolt_cart).to match hash_including(result)
20
22
  end
21
23
  end
22
24
 
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe SolidusBolt::ShipmentDecorator do
4
+ describe '#bolt_shipment' do
5
+ subject(:bolt_shipment) { shipment.bolt_shipment }
6
+
7
+ let(:shipment) { create(:shipment, number: 'S000000001') }
8
+ let(:ship_address) { shipment.order.ship_address }
9
+
10
+ it 'is expected' do
11
+ expect(bolt_shipment).to match hash_including(
12
+ shipping_address: hash_including(postal_code: ship_address.zipcode, country_code: ship_address.country_iso),
13
+ reference: 'S000000001',
14
+ cost: 10_000
15
+ )
16
+ end
17
+ end
18
+ end
@@ -18,4 +18,29 @@ RSpec.describe SolidusBolt::PaymentMethod, type: :model do
18
18
  expect(described_class.new.partial_name).to eq 'bolt'
19
19
  end
20
20
  end
21
+
22
+ describe '#try_void' do
23
+ let(:payment) { create(:payment) }
24
+
25
+ context 'when the payment can be voided' do
26
+ subject(:try_void) { described_instance.try_void(payment) }
27
+
28
+ let(:described_instance) { described_class.new }
29
+ let(:response) { ActiveMerchant::Billing::Response.new(true, 'Transaction voided', {}, authorization: '123') }
30
+
31
+ before do
32
+ allow(payment.source).to receive(:can_void?).and_return(true)
33
+ allow(described_instance.gateway).to receive(:void).and_return(response)
34
+ end
35
+
36
+ it 'calls void on the gateway' do
37
+ try_void
38
+
39
+ expect(described_instance.gateway).to have_received(:void).with(
40
+ payment.response_code,
41
+ originator: payment
42
+ )
43
+ end
44
+ end
45
+ end
21
46
  end
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.1.0
4
+ version: 0.2.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-06-30 00:00:00.000000000 Z
13
+ date: 2022-07-22 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: coffee-rails
@@ -86,22 +86,16 @@ dependencies:
86
86
  name: rails
87
87
  requirement: !ruby/object:Gem::Requirement
88
88
  requirements:
89
- - - ">"
90
- - !ruby/object:Gem::Version
91
- version: 0.a
92
- - - "<"
89
+ - - ">="
93
90
  - !ruby/object:Gem::Version
94
- version: 7.a
91
+ version: '0'
95
92
  type: :runtime
96
93
  prerelease: false
97
94
  version_requirements: !ruby/object:Gem::Requirement
98
95
  requirements:
99
- - - ">"
100
- - !ruby/object:Gem::Version
101
- version: 0.a
102
- - - "<"
96
+ - - ">="
103
97
  - !ruby/object:Gem::Version
104
- version: 7.a
98
+ version: '0'
105
99
  - !ruby/object:Gem::Dependency
106
100
  name: solidus_auth_devise
107
101
  requirement: !ruby/object:Gem::Requirement
@@ -271,6 +265,7 @@ files:
271
265
  - app/decorators/models/solidus_bolt/log_entry_decorator.rb
272
266
  - app/decorators/models/solidus_bolt/order_decorator.rb
273
267
  - app/decorators/models/solidus_bolt/payment_decorator.rb
268
+ - app/decorators/models/solidus_bolt/shipment_decorator.rb
274
269
  - app/decorators/omniauth/strategies/bolt_decorator.rb
275
270
  - app/jobs/solidus_bolt/add_address_job.rb
276
271
  - app/models/solidus_bolt.rb
@@ -349,6 +344,7 @@ files:
349
344
  - spec/decorators/models/solidus_bolt/address_decorator_spec.rb
350
345
  - spec/decorators/models/solidus_bolt/order_decorator_spec.rb
351
346
  - spec/decorators/models/solidus_bolt/payment_decorator_spec.rb
347
+ - spec/decorators/models/solidus_bolt/shipment_decorator_spec.rb
352
348
  - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_AddAddressService/_call/with_correct_access_token/receives_a_successful_response.yml
353
349
  - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_AddAddressService/_call/with_existing_address/skips_the_add_address_call.yml
354
350
  - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_AddAddressService/_call/with_wrong_access_token/gives_an_error.yml
@@ -442,6 +438,7 @@ test_files:
442
438
  - spec/decorators/models/solidus_bolt/address_decorator_spec.rb
443
439
  - spec/decorators/models/solidus_bolt/order_decorator_spec.rb
444
440
  - spec/decorators/models/solidus_bolt/payment_decorator_spec.rb
441
+ - spec/decorators/models/solidus_bolt/shipment_decorator_spec.rb
445
442
  - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_AddAddressService/_call/with_correct_access_token/receives_a_successful_response.yml
446
443
  - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_AddAddressService/_call/with_existing_address/skips_the_add_address_call.yml
447
444
  - spec/fixtures/vcr_cassettes/SolidusBolt_Accounts_AddAddressService/_call/with_wrong_access_token/gives_an_error.yml