workarea-sezzle 1.0.1 → 1.0.6
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/CHANGELOG.md +72 -0
- data/Rakefile +3 -3
- data/app/controllers/workarea/storefront/sezzle_controller.rb +7 -1
- data/app/helpers/workarea/storefront/sezzle_helper.rb +9 -0
- data/app/models/workarea/{paymentl.decorator → payment.decorator} +0 -0
- data/app/services/workarea/sezzle/order_builder.rb +3 -3
- data/app/views/workarea/storefront/carts/_sezzle_widget.html.haml +1 -1
- data/app/views/workarea/storefront/products/_sezzle_widget.html.haml +1 -1
- data/app/views/workarea/storefront/sezzle/_script.html.haml +3 -6
- data/config/initializers/workarea.rb +2 -2
- data/lib/workarea/sezzle/bogus_gateway.rb +55 -0
- data/lib/workarea/sezzle/engine.rb +6 -0
- data/lib/workarea/sezzle/gateway.rb +14 -0
- data/lib/workarea/sezzle/response.rb +1 -1
- data/lib/workarea/sezzle/version.rb +1 -1
- data/test/integration/workarea/storefront/sezzle_integration_test.rb +6 -6
- data/test/lib/workarea/sezzle/response_test.rb +14 -0
- data/test/services/workarea/sezzle/order_builder_test.rb +31 -0
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2c5c2c20d3e860aad00833b6aae3b01ff2ebbaa371cb81329f036e677881e32
|
4
|
+
data.tar.gz: 48193e0d3b063a025de7cc4a48f311581c640fe3e3ab34f460a68de8c8346688
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab0ea0faa9993f3de70847e037cd92ad667354b45b5b2fc01182f96ca7da6cdc01539bd52bb1ccb5672ae0e7443d2afa242305a5baac0690cb498c2f99f2ef57
|
7
|
+
data.tar.gz: b4a16be067c0e81876dd1aee9420360453d527be22856daae6e7a7480e619c15f7f7fe46a840783c15c034bb9f8ecb1607b6b2c1acab7d0c71618acab4f23c56
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
Workarea Sezzle 1.0.6 (2021-05-26)
|
2
|
+
--------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
* Bump version to 1.0.6
|
5
|
+
|
6
|
+
|
7
|
+
Jeff Yucis
|
8
|
+
|
9
|
+
* Call sezzle to delete checkout when user cancels sezzle
|
10
|
+
|
11
|
+
|
12
|
+
Matt Duffy
|
13
|
+
|
14
|
+
|
15
|
+
|
16
|
+
Workarea Sezzle 1.0.5 (2021-05-13)
|
17
|
+
--------------------------------------------------------------------------------
|
18
|
+
|
19
|
+
* Ensure return URLs sent to sezzle include locale when not default
|
20
|
+
|
21
|
+
|
22
|
+
Matt Duffy
|
23
|
+
|
24
|
+
* Prep new release
|
25
|
+
|
26
|
+
|
27
|
+
Jeff Yucis
|
28
|
+
|
29
|
+
* Verify that that the authorization was successful when completing a sezzle purchase.
|
30
|
+
|
31
|
+
|
32
|
+
Jeff Yucis
|
33
|
+
|
34
|
+
* SEZZ-5 Add multi-language support
|
35
|
+
|
36
|
+
Only supports EN and FR, per Sezzle docs.
|
37
|
+
Add new helper for getting Rails locale.
|
38
|
+
Remove translation templates as they were the defaults anyway.
|
39
|
+
Add language to script.
|
40
|
+
|
41
|
+
James Dobson
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
Workarea Sezzle 1.0.4 (2021-03-29)
|
46
|
+
--------------------------------------------------------------------------------
|
47
|
+
|
48
|
+
* Verify that that the authorization was successful when completing a sezzle purchase.
|
49
|
+
|
50
|
+
Jeff Yucis
|
51
|
+
|
52
|
+
* SEZZ-5 Add multi-language support
|
53
|
+
|
54
|
+
Only supports EN and FR, per Sezzle docs.
|
55
|
+
Add new helper for getting Rails locale.
|
56
|
+
Remove translation templates as they were the defaults anyway.
|
57
|
+
Add language to script.
|
58
|
+
|
59
|
+
James Dobson
|
60
|
+
|
61
|
+
|
62
|
+
|
63
|
+
Workarea Sezzle 1.0.3 (2021-01-08)
|
64
|
+
--------------------------------------------------------------------------------
|
65
|
+
|
66
|
+
* SEZZ-4 Change from ID to class select. For package product considerations.
|
67
|
+
|
68
|
+
|
69
|
+
James Dobson
|
70
|
+
|
71
|
+
|
72
|
+
|
data/Rakefile
CHANGED
@@ -32,9 +32,9 @@ require 'workarea/sezzle/version'
|
|
32
32
|
|
33
33
|
desc "Release version #{Workarea::Sezzle::VERSION} of the gem"
|
34
34
|
task :release do
|
35
|
-
|
36
|
-
|
37
|
-
|
35
|
+
Rake::Task['workarea:changelog'].execute
|
36
|
+
system 'git add CHANGELOG.md'
|
37
|
+
system 'git commit -m "Update CHANGELOG"'
|
38
38
|
|
39
39
|
system "git tag -a v#{Workarea::Sezzle::VERSION} -m 'Tagging #{Workarea::Sezzle::VERSION}'"
|
40
40
|
system 'git push origin HEAD --follow-tags'
|
@@ -45,11 +45,16 @@ module Workarea
|
|
45
45
|
|
46
46
|
shipping = current_shipping
|
47
47
|
|
48
|
+
# verify that the authorization was successfull
|
49
|
+
tender = payment.sezzle
|
50
|
+
verifcation_response = gateway.get_order(tender.sezzle_id)
|
51
|
+
verfied = verifcation_response.body["authorization"]["approved"] rescue false
|
52
|
+
|
48
53
|
Pricing.perform(current_order, shipping)
|
49
54
|
payment.adjust_tender_amounts(current_order.total_price)
|
50
55
|
|
51
56
|
# place the order.
|
52
|
-
if current_checkout.place_order
|
57
|
+
if verfied && current_checkout.place_order
|
53
58
|
completed_place_order
|
54
59
|
else
|
55
60
|
incomplete_place_order
|
@@ -62,6 +67,7 @@ module Workarea
|
|
62
67
|
current_order.user_id = current_user.try(:id)
|
63
68
|
|
64
69
|
payment = current_checkout.payment
|
70
|
+
gateway.delete_checkout(payment.sezzle.sezzle_id)
|
65
71
|
payment.clear_sezzle
|
66
72
|
|
67
73
|
flash[:success] = t('workarea.storefront.sezzle.cancel_message')
|
File without changes
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Workarea
|
2
2
|
module Sezzle
|
3
3
|
class OrderBuilder
|
4
|
-
module
|
4
|
+
module Routing
|
5
5
|
include Workarea::I18n::DefaultUrlOptions
|
6
6
|
include Storefront::Engine.routes.url_helpers
|
7
7
|
extend self
|
@@ -114,14 +114,14 @@ module Workarea
|
|
114
114
|
end
|
115
115
|
|
116
116
|
def complete_url
|
117
|
-
|
117
|
+
Routing.complete_sezzle_url(
|
118
118
|
host: Workarea.config.host,
|
119
119
|
order_id: order.id
|
120
120
|
)
|
121
121
|
end
|
122
122
|
|
123
123
|
def cancel_url
|
124
|
-
|
124
|
+
Routing.cancel_sezzle_url(
|
125
125
|
host: Workarea.config.host,
|
126
126
|
order_id: order.id
|
127
127
|
)
|
@@ -11,12 +11,9 @@
|
|
11
11
|
{
|
12
12
|
targetXPath: "#{Workarea.config.sezzle.cart_config[:target_xpath]}",
|
13
13
|
renderToPath: "#{Workarea.config.sezzle.cart_config[:render_to_path]}",
|
14
|
-
urlMatch: "#{Workarea.config.sezzle.cart_config[:url_match]}"
|
15
|
-
altVersionTemplate: {
|
16
|
-
'en': '4 interest-free payments of %%price%% with %%logo%% %%info%%',
|
17
|
-
'fr': '4 paiements de %%price%% sans intérêts avec %%logo%% %%info%%'
|
18
|
-
}
|
14
|
+
urlMatch: "#{Workarea.config.sezzle.cart_config[:url_match]}"
|
19
15
|
}
|
20
|
-
]
|
16
|
+
],
|
17
|
+
language: "#{sezzle_language}"
|
21
18
|
}
|
22
19
|
%script{ src: "https://widget.sezzle.com/v1/javascript/price-widget?uuid=#{Workarea.config.sezzle_merchant_id}" }
|
@@ -7,14 +7,14 @@ Workarea.configure do |config|
|
|
7
7
|
config.sezzle.open_timeout = 10
|
8
8
|
|
9
9
|
config.sezzle.product_config = {
|
10
|
-
target_xpath: '
|
10
|
+
target_xpath: '.sezzle/.sezzle__prices',
|
11
11
|
render_to_path: './',
|
12
12
|
url_match: 'products',
|
13
13
|
split_price_elements_on: '–'
|
14
14
|
}
|
15
15
|
|
16
16
|
config.sezzle.cart_config = {
|
17
|
-
target_xpath: '
|
17
|
+
target_xpath: '.sezzle/.sezzle__prices',
|
18
18
|
render_to_path: './',
|
19
19
|
url_match: 'cart'
|
20
20
|
}
|
@@ -97,6 +97,15 @@ module Workarea
|
|
97
97
|
Response.new(response(payment_response_body))
|
98
98
|
end
|
99
99
|
|
100
|
+
def get_order(id, attrs = {})
|
101
|
+
return Response.new(response(get_order_response_auth_failure)) if id == 'failure'
|
102
|
+
Response.new(response(get_order_response))
|
103
|
+
end
|
104
|
+
|
105
|
+
def delete_checkout(id)
|
106
|
+
return Response.new(response(nil, 204))
|
107
|
+
end
|
108
|
+
|
100
109
|
private
|
101
110
|
|
102
111
|
def response(body, status = 200)
|
@@ -123,6 +132,52 @@ module Workarea
|
|
123
132
|
"uuid": '6c9db5d4-d09a-4224-860a-b5438ac32ca8'
|
124
133
|
}
|
125
134
|
end
|
135
|
+
|
136
|
+
def get_order_response
|
137
|
+
{
|
138
|
+
"authorization": {
|
139
|
+
"approved": true,
|
140
|
+
"authorization_amount": {
|
141
|
+
"amount_in_cents": 10000,
|
142
|
+
"currency": "USD"
|
143
|
+
},
|
144
|
+
"metadata": {
|
145
|
+
"location_id": "123",
|
146
|
+
"store_manager": "Jane Doe",
|
147
|
+
"store_name": "Downtown Minneapolis"
|
148
|
+
},
|
149
|
+
"order_amount": {
|
150
|
+
"amount_in_cents": 10000,
|
151
|
+
"currency": "USD"
|
152
|
+
},
|
153
|
+
"reference_id": "ord_12345",
|
154
|
+
"uuid": "12a34bc5-6de7-890f-g123-4hi1238jk902"
|
155
|
+
}
|
156
|
+
}
|
157
|
+
end
|
158
|
+
|
159
|
+
def get_order_response_auth_failure
|
160
|
+
{
|
161
|
+
"authorization": {
|
162
|
+
"approved": false,
|
163
|
+
"authorization_amount": {
|
164
|
+
"amount_in_cents": 10000,
|
165
|
+
"currency": "USD"
|
166
|
+
},
|
167
|
+
"metadata": {
|
168
|
+
"location_id": "123",
|
169
|
+
"store_manager": "Jane Doe",
|
170
|
+
"store_name": "Downtown Minneapolis"
|
171
|
+
},
|
172
|
+
"order_amount": {
|
173
|
+
"amount_in_cents": 10000,
|
174
|
+
"currency": "USD"
|
175
|
+
},
|
176
|
+
"reference_id": "ord_12345",
|
177
|
+
"uuid": "12a34bc5-6de7-890f-g123-4hi1238jk902"
|
178
|
+
}
|
179
|
+
}
|
180
|
+
end
|
126
181
|
end
|
127
182
|
end
|
128
183
|
end
|
@@ -5,6 +5,12 @@ module Workarea
|
|
5
5
|
class Engine < ::Rails::Engine
|
6
6
|
include Workarea::Plugin
|
7
7
|
isolate_namespace Workarea::Sezzle
|
8
|
+
|
9
|
+
config.to_prepare do
|
10
|
+
Workarea::Storefront::ApplicationController.helper(
|
11
|
+
Workarea::Storefront::SezzleHelper
|
12
|
+
)
|
13
|
+
end
|
8
14
|
end
|
9
15
|
end
|
10
16
|
end
|
@@ -35,6 +35,20 @@ module Workarea
|
|
35
35
|
Sezzle::Response.new(response)
|
36
36
|
end
|
37
37
|
|
38
|
+
def get_order(id, attrs = {})
|
39
|
+
response = connection.get do |req|
|
40
|
+
req.url "v2/order/#{id}"
|
41
|
+
end
|
42
|
+
Sezzle::Response.new(response)
|
43
|
+
end
|
44
|
+
|
45
|
+
def delete_checkout(id)
|
46
|
+
response = connection.delete do |req|
|
47
|
+
req.url "v2/order/#{id}/checkout"
|
48
|
+
end
|
49
|
+
Sezzle::Response.new(response)
|
50
|
+
end
|
51
|
+
|
38
52
|
private
|
39
53
|
|
40
54
|
def connection
|
@@ -155,15 +155,15 @@ module Workarea
|
|
155
155
|
assert_equal('purchase', store_credit_tender.transactions.first.action)
|
156
156
|
end
|
157
157
|
|
158
|
-
def
|
158
|
+
def test_failed_sezzle_authorize
|
159
159
|
payment = Payment.find(order.id)
|
160
160
|
|
161
|
-
payment.set_sezzle(
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
get storefront.complete_sezzle_path(params)
|
161
|
+
payment.set_sezzle(
|
162
|
+
sezzle_id: 'failure',
|
163
|
+
sezzle_response: '{}'
|
164
|
+
)
|
166
165
|
|
166
|
+
get storefront.complete_sezzle_path(order_id: order.id)
|
167
167
|
payment.reload
|
168
168
|
order.reload
|
169
169
|
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
module Workarea
|
4
|
+
module Sezzle
|
5
|
+
class ResponseTest < TestCase
|
6
|
+
def test_success?
|
7
|
+
assert(Response.new(OpenStruct.new(status: 200)).success?)
|
8
|
+
assert(Response.new(OpenStruct.new(status: 201)).success?)
|
9
|
+
assert(Response.new(OpenStruct.new(status: 204)).success?)
|
10
|
+
refute(Response.new(OpenStruct.new(status: 500)).success?)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -3,6 +3,22 @@ require 'test_helper'
|
|
3
3
|
module Workarea
|
4
4
|
module Sezzle
|
5
5
|
class OrderBuilderTest < Workarea::TestCase
|
6
|
+
setup :set_i18n
|
7
|
+
teardown :reset_i18n
|
8
|
+
|
9
|
+
def set_i18n
|
10
|
+
@_default_locale = ::I18n.config.default_locale
|
11
|
+
@_locale = ::I18n.locale
|
12
|
+
|
13
|
+
::I18n.config.default_locale = :en
|
14
|
+
::I18n.locale = :en
|
15
|
+
end
|
16
|
+
|
17
|
+
def reset_i18n
|
18
|
+
::I18n.config.default_locale = @_default_locale
|
19
|
+
::I18n.locale = @_locale
|
20
|
+
end
|
21
|
+
|
6
22
|
def test_build
|
7
23
|
create_order_total_discount
|
8
24
|
order = create_order
|
@@ -16,8 +32,23 @@ module Workarea
|
|
16
32
|
|
17
33
|
order.reload
|
18
34
|
payment.reload
|
35
|
+
|
36
|
+
::I18n.locale = :fr
|
19
37
|
order_hash = Workarea::Sezzle::OrderBuilder.new(order).build
|
20
38
|
|
39
|
+
assert_includes(order_hash[:cancel_url][:href], 'locale=fr')
|
40
|
+
assert_includes(order_hash[:complete_url][:href], 'locale=fr')
|
41
|
+
|
42
|
+
assert_nothing_raised { order_hash.to_json }
|
43
|
+
|
44
|
+
::I18n.locale = :en
|
45
|
+
order_hash = Workarea::Sezzle::OrderBuilder.new(order).build
|
46
|
+
|
47
|
+
assert_nothing_raised { order_hash.to_json }
|
48
|
+
|
49
|
+
refute_includes(order_hash[:cancel_url][:href], 'locale=')
|
50
|
+
refute_includes(order_hash[:complete_url][:href], 'locale=')
|
51
|
+
|
21
52
|
customer = order_hash[:customer]
|
22
53
|
assert_equal(order.email, customer[:email])
|
23
54
|
assert_equal('Bob', customer[:first_name])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: workarea-sezzle
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Yucis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -37,6 +37,7 @@ files:
|
|
37
37
|
- ".gitignore"
|
38
38
|
- ".rubocop.yml"
|
39
39
|
- ".scss-lint.yml"
|
40
|
+
- CHANGELOG.md
|
40
41
|
- Gemfile
|
41
42
|
- LICENSE
|
42
43
|
- README.md
|
@@ -56,14 +57,15 @@ files:
|
|
56
57
|
- app/controllers/workarea/storefront/checkout/place_order_controller.decorator
|
57
58
|
- app/controllers/workarea/storefront/sezzle_controller.rb
|
58
59
|
- app/helpers/.keep
|
60
|
+
- app/helpers/workarea/storefront/sezzle_helper.rb
|
59
61
|
- app/mailers/.keep
|
60
62
|
- app/models/.keep
|
63
|
+
- app/models/workarea/payment.decorator
|
61
64
|
- app/models/workarea/payment/authorize/sezzle.rb
|
62
65
|
- app/models/workarea/payment/capture/sezzle.rb
|
63
66
|
- app/models/workarea/payment/purchase/sezzle.rb
|
64
67
|
- app/models/workarea/payment/refund/sezzle.rb
|
65
68
|
- app/models/workarea/payment/tender/sezzle.rb
|
66
|
-
- app/models/workarea/paymentl.decorator
|
67
69
|
- app/services/workarea/sezzle/order_builder.rb
|
68
70
|
- app/view_models/workarea/storefront/checkout/payment_view_model.decorator
|
69
71
|
- app/views/.keep
|
@@ -133,6 +135,7 @@ files:
|
|
133
135
|
- test/dummy/lib/assets/.keep
|
134
136
|
- test/dummy/log/.keep
|
135
137
|
- test/integration/workarea/storefront/sezzle_integration_test.rb
|
138
|
+
- test/lib/workarea/sezzle/response_test.rb
|
136
139
|
- test/models/workarea/payment/sezzle_payment_integration_test.rb
|
137
140
|
- test/services/workarea/sezzle/order_builder_test.rb
|
138
141
|
- test/teaspoon_env.rb
|