workarea-sezzle 1.0.3 → 1.0.4
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/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/views/workarea/storefront/sezzle/_script.html.haml +3 -6
- 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
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: be87020a46f155631d5dea416c434b671a902daa3c3160788cfb53d33332adf3
|
4
|
+
data.tar.gz: 31120de1aaea7033e0ffd48a522e753bc756e08cad483e7ad9551b6384d82571
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6afd0ccedf88ea81ac3f85f1ffe2b34e9bdfc7355444fee837ba0d3fc3b3d94f2aa57200903ccef0e9662e31804085f8d4ad6d77c5731fb241b6f3fc9d66c62f
|
7
|
+
data.tar.gz: 514f6181d64f6d4b5bce6819da5879460b608fd29e228bb7db9640db656f80c326d3d7dfbd0039b736c58a0d72a4ab67c6ee61fdc777f5522a260111bc93a97e
|
@@ -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
|
@@ -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}" }
|
@@ -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
|
|
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.4
|
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-03-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: workarea
|
@@ -57,14 +57,15 @@ files:
|
|
57
57
|
- app/controllers/workarea/storefront/checkout/place_order_controller.decorator
|
58
58
|
- app/controllers/workarea/storefront/sezzle_controller.rb
|
59
59
|
- app/helpers/.keep
|
60
|
+
- app/helpers/workarea/storefront/sezzle_helper.rb
|
60
61
|
- app/mailers/.keep
|
61
62
|
- app/models/.keep
|
63
|
+
- app/models/workarea/payment.decorator
|
62
64
|
- app/models/workarea/payment/authorize/sezzle.rb
|
63
65
|
- app/models/workarea/payment/capture/sezzle.rb
|
64
66
|
- app/models/workarea/payment/purchase/sezzle.rb
|
65
67
|
- app/models/workarea/payment/refund/sezzle.rb
|
66
68
|
- app/models/workarea/payment/tender/sezzle.rb
|
67
|
-
- app/models/workarea/paymentl.decorator
|
68
69
|
- app/services/workarea/sezzle/order_builder.rb
|
69
70
|
- app/view_models/workarea/storefront/checkout/payment_view_model.decorator
|
70
71
|
- app/views/.keep
|