solidus_bolt 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/solidus_bolt.js +2 -0
- data/app/decorators/models/solidus_bolt/order_decorator.rb +5 -0
- data/app/decorators/models/solidus_bolt/shipment_decorator.rb +15 -0
- data/app/models/solidus_bolt/payment_method.rb +6 -0
- data/db/seeds.rb +1 -1
- data/lib/solidus_bolt/version.rb +1 -1
- data/solidus_bolt.gemspec +1 -1
- data/spec/decorators/models/solidus_bolt/order_decorator_spec.rb +3 -1
- data/spec/decorators/models/solidus_bolt/shipment_decorator_spec.rb +18 -0
- data/spec/models/solidus_bolt/payment_method_spec.rb +25 -0
- metadata +9 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9f19675a463bcfbccc9fe98a89fc973d5bdfb34d66a57e48ad3882441877863
|
4
|
+
data.tar.gz: d79c693485c474464c5563be4710c7c3898031ef879df7d9cb639d9ea203d195
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
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']
|
data/lib/solidus_bolt/version.rb
CHANGED
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'
|
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
|
-
|
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.
|
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-
|
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:
|
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:
|
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
|