workarea-sezzle 1.0.0 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +57 -0
- data/Rakefile +3 -3
- data/app/controllers/workarea/storefront/sezzle_controller.rb +6 -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/api/storefront/orders/tenders/_sezzle.json.jbuilder +4 -0
- 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 +51 -0
- data/lib/workarea/sezzle/engine.rb +6 -0
- data/lib/workarea/sezzle/gateway.rb +7 -0
- data/lib/workarea/sezzle/version.rb +1 -1
- data/test/integration/workarea/storefront/sezzle_integration_test.rb +6 -6
- 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: 1f64801c67844cdc36f81d900b207460bd0a5fc3a07583ce69d62d5460a3aafa
|
4
|
+
data.tar.gz: 93e04f04ad21cbe38e222d3197120fcdcf60dc5fff94e5f575c179955c143246
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad298f476db067ae3ae3250c30ea43bb97a9642f5535788b0dd749986eb88b582f3fdbefa7211809114967ea9a37104a2eaea082ea4103e0ae2b37997a7ed78
|
7
|
+
data.tar.gz: d14a015cef5f988db405f20085b08be82136c7056311937ee2032909c1f18dd28b7f85ec58104023904f853171d446d2a4d657f7a7d7a3538fd28e35581fe538
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
Workarea Sezzle 1.0.5 (2021-05-13)
|
2
|
+
--------------------------------------------------------------------------------
|
3
|
+
|
4
|
+
* Ensure return URLs sent to sezzle include locale when not default
|
5
|
+
|
6
|
+
|
7
|
+
Matt Duffy
|
8
|
+
|
9
|
+
* Prep new release
|
10
|
+
|
11
|
+
|
12
|
+
Jeff Yucis
|
13
|
+
|
14
|
+
* Verify that that the authorization was successful when completing a sezzle purchase.
|
15
|
+
|
16
|
+
|
17
|
+
Jeff Yucis
|
18
|
+
|
19
|
+
* SEZZ-5 Add multi-language support
|
20
|
+
|
21
|
+
Only supports EN and FR, per Sezzle docs.
|
22
|
+
Add new helper for getting Rails locale.
|
23
|
+
Remove translation templates as they were the defaults anyway.
|
24
|
+
Add language to script.
|
25
|
+
|
26
|
+
James Dobson
|
27
|
+
|
28
|
+
|
29
|
+
|
30
|
+
Workarea Sezzle 1.0.4 (2021-03-29)
|
31
|
+
--------------------------------------------------------------------------------
|
32
|
+
|
33
|
+
* Verify that that the authorization was successful when completing a sezzle purchase.
|
34
|
+
|
35
|
+
Jeff Yucis
|
36
|
+
|
37
|
+
* SEZZ-5 Add multi-language support
|
38
|
+
|
39
|
+
Only supports EN and FR, per Sezzle docs.
|
40
|
+
Add new helper for getting Rails locale.
|
41
|
+
Remove translation templates as they were the defaults anyway.
|
42
|
+
Add language to script.
|
43
|
+
|
44
|
+
James Dobson
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
Workarea Sezzle 1.0.3 (2021-01-08)
|
49
|
+
--------------------------------------------------------------------------------
|
50
|
+
|
51
|
+
* SEZZ-4 Change from ID to class select. For package product considerations.
|
52
|
+
|
53
|
+
|
54
|
+
James Dobson
|
55
|
+
|
56
|
+
|
57
|
+
|
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
|
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,11 @@ 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
|
+
|
100
105
|
private
|
101
106
|
|
102
107
|
def response(body, status = 200)
|
@@ -123,6 +128,52 @@ module Workarea
|
|
123
128
|
"uuid": '6c9db5d4-d09a-4224-860a-b5438ac32ca8'
|
124
129
|
}
|
125
130
|
end
|
131
|
+
|
132
|
+
def get_order_response
|
133
|
+
{
|
134
|
+
"authorization": {
|
135
|
+
"approved": true,
|
136
|
+
"authorization_amount": {
|
137
|
+
"amount_in_cents": 10000,
|
138
|
+
"currency": "USD"
|
139
|
+
},
|
140
|
+
"metadata": {
|
141
|
+
"location_id": "123",
|
142
|
+
"store_manager": "Jane Doe",
|
143
|
+
"store_name": "Downtown Minneapolis"
|
144
|
+
},
|
145
|
+
"order_amount": {
|
146
|
+
"amount_in_cents": 10000,
|
147
|
+
"currency": "USD"
|
148
|
+
},
|
149
|
+
"reference_id": "ord_12345",
|
150
|
+
"uuid": "12a34bc5-6de7-890f-g123-4hi1238jk902"
|
151
|
+
}
|
152
|
+
}
|
153
|
+
end
|
154
|
+
|
155
|
+
def get_order_response_auth_failure
|
156
|
+
{
|
157
|
+
"authorization": {
|
158
|
+
"approved": false,
|
159
|
+
"authorization_amount": {
|
160
|
+
"amount_in_cents": 10000,
|
161
|
+
"currency": "USD"
|
162
|
+
},
|
163
|
+
"metadata": {
|
164
|
+
"location_id": "123",
|
165
|
+
"store_manager": "Jane Doe",
|
166
|
+
"store_name": "Downtown Minneapolis"
|
167
|
+
},
|
168
|
+
"order_amount": {
|
169
|
+
"amount_in_cents": 10000,
|
170
|
+
"currency": "USD"
|
171
|
+
},
|
172
|
+
"reference_id": "ord_12345",
|
173
|
+
"uuid": "12a34bc5-6de7-890f-g123-4hi1238jk902"
|
174
|
+
}
|
175
|
+
}
|
176
|
+
end
|
126
177
|
end
|
127
178
|
end
|
128
179
|
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
|
@@ -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
|
|
@@ -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.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeff Yucis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-13 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,18 +57,20 @@ 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
|
70
72
|
- app/views/workarea/admin/orders/tenders/_sezzle.html.haml
|
73
|
+
- app/views/workarea/api/storefront/orders/tenders/_sezzle.json.jbuilder
|
71
74
|
- app/views/workarea/storefront/carts/_sezzle_widget.html.haml
|
72
75
|
- app/views/workarea/storefront/checkouts/_sezzle_payment.html.haml
|
73
76
|
- app/views/workarea/storefront/order_mailer/tenders/_sezzle.html.haml
|