spree_vpago 2.4.0.pre.pre1 → 2.4.0.pre.pre3
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/Gemfile.lock +27 -26
- data/app/controllers/spree/admin/payment_acleda_v2_base_controller.rb +21 -0
- data/app/controllers/spree/admin/payment_acleda_v2_checkers_controller.rb +26 -0
- data/app/controllers/spree/admin/payment_acleda_v2_queriers_controller.rb +38 -0
- data/app/controllers/spree/admin/payment_payway_queriers_controller.rb +7 -0
- data/app/controllers/spree/admin/payment_vattanac_base_controller.rb +21 -0
- data/app/controllers/spree/admin/payment_vattanac_checkers_controller.rb +26 -0
- data/app/controllers/spree/admin/payment_vattanac_queriers_controller.rb +38 -0
- data/app/controllers/spree/vpago_payments_controller.rb +15 -3
- data/app/helpers/vpago/vpago_payments_helper.rb +6 -0
- data/app/models/spree/payment_method/cash_on.rb +7 -0
- data/app/models/vpago/order_decorator.rb +1 -1
- data/app/models/vpago/payment_decorator.rb +0 -4
- data/app/models/vpago/payment_method_decorator.rb +8 -6
- data/app/serializers/spree/v2/storefront/payment_method_serializer_decorator.rb +6 -0
- data/app/services/vpago/payment_redirect_handler.rb +6 -6
- data/app/views/spree/admin/payments/source_views/_acleda_v2.html.erb +2 -2
- data/app/views/spree/admin/payments/source_views/_vattanac.html.erb +3 -3
- data/app/views/spree/vpago_payments/_success_script.html.erb +7 -0
- data/app/views/spree/vpago_payments/success.html.erb +2 -0
- data/config/locales/en.yml +1 -0
- data/config/locales/km.yml +1 -0
- data/config/routes.rb +6 -7
- data/lib/spree_vpago/engine.rb +0 -1
- data/lib/spree_vpago/version.rb +1 -1
- data/lib/vpago/acleda_v2/payment_request_updater.rb +54 -0
- data/lib/vpago/http_timeouts.rb +6 -0
- data/lib/vpago/payway_v2/payment_request_updater.rb +5 -0
- data/lib/vpago/payway_v2/transaction_status.rb +2 -0
- data/lib/vpago/payway_v2/transaction_status_v2.rb +2 -0
- data/lib/vpago/true_money/base.rb +1 -1
- data/lib/vpago/true_money/transaction_status.rb +1 -1
- data/lib/vpago/vattanac/base.rb +3 -2
- data/lib/vpago/vattanac/payment_request_updater.rb +54 -0
- data/lib/vpago/vattanac/transaction_status.rb +17 -1
- data/lib/vpago/wing_sdk/base.rb +1 -1
- data/spree_vpago.gemspec +1 -1
- metadata +16 -12
- data/app/controllers/spree/miniapp/acledas_controller.rb +0 -29
- data/app/models/spree/gateway/acleda_mini_app.rb +0 -20
- data/app/services/vpago/acleda_mini_app/session/create.rb +0 -99
- data/app/views/spree/admin/payments/source_views/_acleda_mini_app.html.erb +0 -6
- data/app/views/spree/vpago_payments/forms/spree/gateway/_acleda_mini_app.html.erb +0 -93
- data/lib/vpago/acleda_mini_app/checkout.rb +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e361db28503471424737c1633bb7e5fcacccdc7c1a63faddd76ad3e226ceb6f7
|
|
4
|
+
data.tar.gz: cd5936a07fdfcfb314ac0d068d88b0e6137e6f5cb7e37295aa034368bcea33af
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5691409e7f910c70fd1012358eafc766b45131e4db286106f5a58a8390c0f7bb2ad1fbba892805a6f7ab3b4ec75bb77f8df1e76ccde90f153efadc6e835bed0
|
|
7
|
+
data.tar.gz: 874db861928b7f5cd71ccd9d17172057de242748f2cc0c11735b03a49951c80151d02cde118ee4ea21961209113529bb1e89562c9e6e8e843f38c4369ef03f71
|
data/Gemfile.lock
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
spree_vpago (2.4.0.pre.
|
|
4
|
+
spree_vpago (2.4.0.pre.pre3)
|
|
5
5
|
faraday
|
|
6
6
|
google-cloud-firestore
|
|
7
7
|
spree_api (>= 4.5)
|
|
8
8
|
spree_backend (>= 4.5)
|
|
9
9
|
spree_core (>= 4.5)
|
|
10
|
-
spree_extension
|
|
10
|
+
spree_extension (< 1.0)
|
|
11
11
|
spree_multi_vendor (>= 2.4.1)
|
|
12
12
|
|
|
13
13
|
GEM
|
|
@@ -128,7 +128,7 @@ GEM
|
|
|
128
128
|
babel-source (>= 4.0, < 6)
|
|
129
129
|
execjs (~> 2.0)
|
|
130
130
|
base64 (0.3.0)
|
|
131
|
-
bcrypt (3.1.
|
|
131
|
+
bcrypt (3.1.22)
|
|
132
132
|
bigdecimal (3.1.8)
|
|
133
133
|
bootstrap (4.6.2.1)
|
|
134
134
|
autoprefixer-rails (>= 9.1.0)
|
|
@@ -176,10 +176,11 @@ GEM
|
|
|
176
176
|
rainbow (>= 2.1.0)
|
|
177
177
|
diff-lcs (1.5.0)
|
|
178
178
|
docile (1.4.0)
|
|
179
|
-
doorkeeper (5.
|
|
179
|
+
doorkeeper (5.9.9)
|
|
180
180
|
railties (>= 5)
|
|
181
181
|
erubi (1.12.0)
|
|
182
|
-
execjs (2.10.
|
|
182
|
+
execjs (2.10.2)
|
|
183
|
+
json (>= 2)
|
|
183
184
|
factory_bot (4.11.1)
|
|
184
185
|
activesupport (>= 3.0.0)
|
|
185
186
|
faraday (2.7.4)
|
|
@@ -188,7 +189,7 @@ GEM
|
|
|
188
189
|
faraday-http-cache (2.5.0)
|
|
189
190
|
faraday (>= 0.8)
|
|
190
191
|
faraday-net_http (3.0.2)
|
|
191
|
-
faraday-retry (2.
|
|
192
|
+
faraday-retry (2.4.0)
|
|
192
193
|
faraday (~> 2.0)
|
|
193
194
|
ffaker (2.21.0)
|
|
194
195
|
ffi (1.15.5)
|
|
@@ -198,7 +199,7 @@ GEM
|
|
|
198
199
|
flatpickr (4.6.13.1)
|
|
199
200
|
friendly_id (5.5.0)
|
|
200
201
|
activerecord (>= 4.0.0)
|
|
201
|
-
gapic-common (1.
|
|
202
|
+
gapic-common (1.5.0)
|
|
202
203
|
faraday (>= 1.9, < 3.a)
|
|
203
204
|
faraday-retry (>= 1.0, < 3.a)
|
|
204
205
|
google-cloud-env (~> 2.2)
|
|
@@ -207,7 +208,7 @@ GEM
|
|
|
207
208
|
googleapis-common-protos (~> 1.6)
|
|
208
209
|
googleapis-common-protos-types (~> 1.15)
|
|
209
210
|
googleauth (~> 1.12)
|
|
210
|
-
grpc (
|
|
211
|
+
grpc (>= 1.83, < 2.a)
|
|
211
212
|
gem-release (2.2.2)
|
|
212
213
|
github_changelog_generator (1.16.4)
|
|
213
214
|
activesupport
|
|
@@ -221,45 +222,45 @@ GEM
|
|
|
221
222
|
globalid (1.1.0)
|
|
222
223
|
activesupport (>= 5.0)
|
|
223
224
|
glyphicons (1.0.2)
|
|
224
|
-
google-cloud-core (1.
|
|
225
|
+
google-cloud-core (1.9.0)
|
|
225
226
|
google-cloud-env (>= 1.0, < 3.a)
|
|
226
227
|
google-cloud-errors (~> 1.0)
|
|
227
|
-
google-cloud-env (2.
|
|
228
|
+
google-cloud-env (2.4.0)
|
|
228
229
|
base64 (~> 0.2)
|
|
229
230
|
faraday (>= 1.0, < 3.a)
|
|
230
|
-
google-cloud-errors (1.
|
|
231
|
-
google-cloud-firestore (3.
|
|
231
|
+
google-cloud-errors (1.7.0)
|
|
232
|
+
google-cloud-firestore (3.2.0)
|
|
232
233
|
bigdecimal (~> 3.0)
|
|
233
234
|
concurrent-ruby (~> 1.0)
|
|
234
235
|
google-cloud-core (~> 1.7)
|
|
235
236
|
google-cloud-firestore-v1 (~> 2.0)
|
|
236
237
|
rbtree (~> 0.4.2)
|
|
237
|
-
google-cloud-firestore-v1 (2.
|
|
238
|
-
gapic-common (~> 1.
|
|
238
|
+
google-cloud-firestore-v1 (2.4.0)
|
|
239
|
+
gapic-common (~> 1.3)
|
|
239
240
|
google-cloud-errors (~> 1.0)
|
|
240
241
|
google-cloud-location (~> 1.0)
|
|
241
|
-
google-cloud-location (1.
|
|
242
|
-
gapic-common (~> 1.
|
|
242
|
+
google-cloud-location (1.5.1)
|
|
243
|
+
gapic-common (~> 1.3)
|
|
243
244
|
google-cloud-errors (~> 1.0)
|
|
244
245
|
google-logging-utils (0.2.0)
|
|
245
|
-
google-protobuf (4.33.
|
|
246
|
+
google-protobuf (4.33.6)
|
|
246
247
|
bigdecimal
|
|
247
248
|
rake (>= 13)
|
|
248
|
-
googleapis-common-protos (1.
|
|
249
|
+
googleapis-common-protos (1.10.0)
|
|
249
250
|
google-protobuf (~> 4.26)
|
|
250
251
|
googleapis-common-protos-types (~> 1.21)
|
|
251
252
|
grpc (~> 1.41)
|
|
252
|
-
googleapis-common-protos-types (1.
|
|
253
|
+
googleapis-common-protos-types (1.23.0)
|
|
253
254
|
google-protobuf (~> 4.26)
|
|
254
|
-
googleauth (1.
|
|
255
|
+
googleauth (1.17.4)
|
|
255
256
|
faraday (>= 1.0, < 3.a)
|
|
256
257
|
google-cloud-env (~> 2.2)
|
|
257
258
|
google-logging-utils (~> 0.1)
|
|
258
259
|
jwt (>= 1.4, < 4.0)
|
|
259
|
-
multi_json (~> 1.11)
|
|
260
260
|
os (>= 0.9, < 2.0)
|
|
261
|
+
pstore (~> 0.1)
|
|
261
262
|
signet (>= 0.16, < 2.a)
|
|
262
|
-
grpc (1.
|
|
263
|
+
grpc (1.84.0)
|
|
263
264
|
google-protobuf (>= 3.25, < 5.0)
|
|
264
265
|
googleapis-common-protos-types (~> 1.0)
|
|
265
266
|
hashdiff (1.1.0)
|
|
@@ -369,6 +370,7 @@ GEM
|
|
|
369
370
|
pry (0.14.2)
|
|
370
371
|
coderay (~> 1.1)
|
|
371
372
|
method_source (~> 1.0)
|
|
373
|
+
pstore (0.2.1)
|
|
372
374
|
public_suffix (5.0.1)
|
|
373
375
|
puma (6.2.2)
|
|
374
376
|
nio4r (~> 2.0)
|
|
@@ -412,13 +414,13 @@ GEM
|
|
|
412
414
|
activerecord (>= 6.0.4)
|
|
413
415
|
activesupport (>= 6.0.4)
|
|
414
416
|
i18n
|
|
415
|
-
rbtree (0.4.
|
|
417
|
+
rbtree (0.4.7)
|
|
416
418
|
redis (5.0.6)
|
|
417
419
|
redis-client (>= 0.9.0)
|
|
418
420
|
redis-client (0.14.1)
|
|
419
421
|
connection_pool
|
|
420
422
|
regexp_parser (2.11.3)
|
|
421
|
-
responders (3.2.
|
|
423
|
+
responders (3.2.1)
|
|
422
424
|
actionpack (>= 7.0)
|
|
423
425
|
railties (>= 7.0)
|
|
424
426
|
rexml (3.2.9)
|
|
@@ -492,11 +494,10 @@ GEM
|
|
|
492
494
|
websocket (~> 1.0)
|
|
493
495
|
shoulda-matchers (6.2.0)
|
|
494
496
|
activesupport (>= 5.2.0)
|
|
495
|
-
signet (0.
|
|
497
|
+
signet (0.22.0)
|
|
496
498
|
addressable (~> 2.8)
|
|
497
499
|
faraday (>= 0.17.5, < 3.a)
|
|
498
500
|
jwt (>= 1.5, < 4.0)
|
|
499
|
-
multi_json (~> 1.10)
|
|
500
501
|
simplecov (0.22.0)
|
|
501
502
|
docile (~> 1.1)
|
|
502
503
|
simplecov-html (~> 0.11)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class PaymentAcledaV2BaseController < Spree::Admin::BaseController
|
|
4
|
+
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
6
|
+
before_action :load_payment, only: %i[show update]
|
|
7
|
+
before_action :validate_order, only: [:update]
|
|
8
|
+
|
|
9
|
+
def validate_order
|
|
10
|
+
return unless @payment.order.completed?
|
|
11
|
+
|
|
12
|
+
flash[:error] = Spree.t('vpago.payments.not_allow_for_order_completed')
|
|
13
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load_payment
|
|
17
|
+
@payment = Payment.find_by!(number: params[:id])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class PaymentAcledaV2CheckersController < PaymentAcledaV2BaseController
|
|
4
|
+
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
6
|
+
def update
|
|
7
|
+
options = {
|
|
8
|
+
updated_by_user_id: try_spree_current_user.id,
|
|
9
|
+
updated_reason: Spree.t('vpago.payments.checker_updated_by_description')
|
|
10
|
+
}
|
|
11
|
+
spree_updater = Vpago::AcledaV2::PaymentRequestUpdater.new(@payment, options)
|
|
12
|
+
spree_updater.call
|
|
13
|
+
|
|
14
|
+
@payment.reload
|
|
15
|
+
|
|
16
|
+
if @payment.order.completed?
|
|
17
|
+
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:payments))
|
|
18
|
+
else
|
|
19
|
+
flash[:error] = Spree.t(:unsuccessfully_updated, resource: Spree.t(:payments))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class PaymentAcledaV2QueriersController < PaymentAcledaV2BaseController
|
|
4
|
+
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
6
|
+
around_action :set_writing_role, only: %i[show]
|
|
7
|
+
|
|
8
|
+
def show
|
|
9
|
+
tran_status = @payment.payment_method.check_transaction(@payment)
|
|
10
|
+
|
|
11
|
+
if tran_status.success?
|
|
12
|
+
@payment.update_column(:gateway_status, true)
|
|
13
|
+
flash[:success] =
|
|
14
|
+
Spree.t('vpago.payments.payment_found_with_result', result: tran_status.json_response)
|
|
15
|
+
else
|
|
16
|
+
flash[:error] = Spree.t('vpago.payments.payment_not_found_with_error', error: tran_status.error_message)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
20
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
|
|
21
|
+
VpagoLogger.error(
|
|
22
|
+
label: 'Spree::Admin::PaymentAcledaV2QueriersController#show gateway_timeout',
|
|
23
|
+
data: { payment_number: @payment.number, error_class: e.class.name, error_message: e.message }
|
|
24
|
+
)
|
|
25
|
+
flash[:error] = Spree.t('vpago.payments.gateway_timeout')
|
|
26
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def set_writing_role
|
|
32
|
+
ActiveRecord::Base.connected_to(role: :writing) do
|
|
33
|
+
yield if block_given?
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -16,6 +16,13 @@ module Spree
|
|
|
16
16
|
flash[:error] = Spree.t('vpago.payments.payment_not_found_with_error', error: tran_status.error_message)
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
20
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
|
|
21
|
+
VpagoLogger.error(
|
|
22
|
+
label: 'Spree::Admin::PaymentPaywayQueriersController#show gateway_timeout',
|
|
23
|
+
data: { payment_number: @payment.number, error_class: e.class.name, error_message: e.message }
|
|
24
|
+
)
|
|
25
|
+
flash[:error] = Spree.t('vpago.payments.gateway_timeout')
|
|
19
26
|
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
20
27
|
end
|
|
21
28
|
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class PaymentVattanacBaseController < Spree::Admin::BaseController
|
|
4
|
+
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
6
|
+
before_action :load_payment, only: %i[show update]
|
|
7
|
+
before_action :validate_order, only: [:update]
|
|
8
|
+
|
|
9
|
+
def validate_order
|
|
10
|
+
return unless @payment.order.completed?
|
|
11
|
+
|
|
12
|
+
flash[:error] = Spree.t('vpago.payments.not_allow_for_order_completed')
|
|
13
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def load_payment
|
|
17
|
+
@payment = Payment.find_by!(number: params[:id])
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class PaymentVattanacCheckersController < PaymentVattanacBaseController
|
|
4
|
+
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
6
|
+
def update
|
|
7
|
+
options = {
|
|
8
|
+
updated_by_user_id: try_spree_current_user.id,
|
|
9
|
+
updated_reason: Spree.t('vpago.payments.checker_updated_by_description')
|
|
10
|
+
}
|
|
11
|
+
spree_updater = Vpago::Vattanac::PaymentRequestUpdater.new(@payment, options)
|
|
12
|
+
spree_updater.call
|
|
13
|
+
|
|
14
|
+
@payment.reload
|
|
15
|
+
|
|
16
|
+
if @payment.order.completed?
|
|
17
|
+
flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:payments))
|
|
18
|
+
else
|
|
19
|
+
flash[:error] = Spree.t(:unsuccessfully_updated, resource: Spree.t(:payments))
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
module Spree
|
|
2
|
+
module Admin
|
|
3
|
+
class PaymentVattanacQueriersController < PaymentVattanacBaseController
|
|
4
|
+
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
6
|
+
around_action :set_writing_role, only: %i[show]
|
|
7
|
+
|
|
8
|
+
def show
|
|
9
|
+
tran_status = @payment.payment_method.check_transaction(@payment)
|
|
10
|
+
|
|
11
|
+
if tran_status.success?
|
|
12
|
+
@payment.update_column(:gateway_status, true)
|
|
13
|
+
flash[:success] =
|
|
14
|
+
Spree.t('vpago.payments.payment_found_with_result', result: tran_status.json_response)
|
|
15
|
+
else
|
|
16
|
+
flash[:error] = Spree.t('vpago.payments.payment_not_found_with_error', error: tran_status.error_message)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
20
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
|
|
21
|
+
VpagoLogger.error(
|
|
22
|
+
label: 'Spree::Admin::PaymentVattanacQueriersController#show gateway_timeout',
|
|
23
|
+
data: { payment_number: @payment.number, error_class: e.class.name, error_message: e.message }
|
|
24
|
+
)
|
|
25
|
+
flash[:error] = Spree.t('vpago.payments.gateway_timeout')
|
|
26
|
+
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
private
|
|
30
|
+
|
|
31
|
+
def set_writing_role
|
|
32
|
+
ActiveRecord::Base.connected_to(role: :writing) do
|
|
33
|
+
yield if block_given?
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -24,6 +24,12 @@ module Spree
|
|
|
24
24
|
def processing
|
|
25
25
|
@order = @payment.order
|
|
26
26
|
|
|
27
|
+
# Common, not an edge case: the gateway callback or the checkout page's transaction
|
|
28
|
+
# checker often completes the order before the browser lands here. Skipping this page
|
|
29
|
+
# also skips its Firebase listener, so success must post order_is_completed itself
|
|
30
|
+
# (render_success_script) or an embedding iframe modal never closes.
|
|
31
|
+
return redirect_to @payment.success_url, allow_other_host: true if @order.completed?
|
|
32
|
+
|
|
27
33
|
VpagoLogger.log(label: 'Spree::VpagoPaymentsController#processing', data: vpago_log_context)
|
|
28
34
|
end
|
|
29
35
|
|
|
@@ -60,6 +66,12 @@ module Spree
|
|
|
60
66
|
else
|
|
61
67
|
render json: { status: :pending }, status: :ok
|
|
62
68
|
end
|
|
69
|
+
rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
|
|
70
|
+
VpagoLogger.error(
|
|
71
|
+
label: 'Spree::VpagoPaymentsController#check_transaction gateway_timeout',
|
|
72
|
+
data: vpago_log_context(error_class: e.class.name, error_message: e.message)
|
|
73
|
+
)
|
|
74
|
+
render json: { status: :pending }, status: :ok
|
|
63
75
|
end
|
|
64
76
|
|
|
65
77
|
# POST
|
|
@@ -146,9 +158,9 @@ module Spree
|
|
|
146
158
|
raise ActiveRecord::RecordNotFound unless @payment.present?
|
|
147
159
|
end
|
|
148
160
|
|
|
149
|
-
#
|
|
150
|
-
#
|
|
151
|
-
#
|
|
161
|
+
# These pages are embedded in iframes on many partner sites we don't
|
|
162
|
+
# enumerate, so framing is left unrestricted: no frame-ancestors policy, and
|
|
163
|
+
# Rails' default SAMEORIGIN header is dropped for the iframe actions.
|
|
152
164
|
def allow_iframe_embedding
|
|
153
165
|
response.headers.delete('X-Frame-Options')
|
|
154
166
|
end
|
|
@@ -13,6 +13,12 @@ module Vpago
|
|
|
13
13
|
render partial: 'spree/vpago_payments/transaction_checker'
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
+
# Host apps override success.html.erb; call this from every override so an
|
|
17
|
+
# embedding iframe modal still learns the order completed.
|
|
18
|
+
def render_success_script
|
|
19
|
+
render partial: 'spree/vpago_payments/success_script'
|
|
20
|
+
end
|
|
21
|
+
|
|
16
22
|
# Each payment method may have their own additional processing script,
|
|
17
23
|
# so we will look for the partial based on the payment method class name.
|
|
18
24
|
#
|
|
@@ -11,5 +11,12 @@ module Spree
|
|
|
11
11
|
def auto_capture?
|
|
12
12
|
true
|
|
13
13
|
end
|
|
14
|
+
|
|
15
|
+
# override: Spree::Payment#cancel! calls payment_method.cancel(response_code, payment).
|
|
16
|
+
# Cash has no gateway to void against, so acknowledge success and let the payment
|
|
17
|
+
# transition to `void`.
|
|
18
|
+
def cancel(_response_code, _payment = nil)
|
|
19
|
+
ActiveMerchant::Billing::Response.new(true, 'Cash On: Payment has been canceled.')
|
|
20
|
+
end
|
|
14
21
|
end
|
|
15
22
|
end
|
|
@@ -6,7 +6,6 @@ module Vpago
|
|
|
6
6
|
TYPE_ACLEDA = 'Spree::Gateway::Acleda'.freeze
|
|
7
7
|
TYPE_ACLEDA_V2 = 'Spree::Gateway::AcledaV2'.freeze
|
|
8
8
|
TYPE_ACLEDA_MOBILE = 'Spree::Gateway::AcledaMobile'.freeze
|
|
9
|
-
TYPE_ACLEDA_MINI_APP = 'Spree::Gateway::AcledaMiniApp'.freeze
|
|
10
9
|
TYPE_TRUE_MONEY = 'Spree::Gateway::TrueMoney'.freeze
|
|
11
10
|
TYPE_VATTANAC = 'Spree::Gateway::Vattanac'.freeze
|
|
12
11
|
TYPE_VATTANAC_MINI_APP = 'Spree::Gateway::VattanacMiniApp'.freeze
|
|
@@ -25,7 +24,6 @@ module Vpago
|
|
|
25
24
|
Spree::PaymentMethod::TYPE_ACLEDA,
|
|
26
25
|
Spree::PaymentMethod::TYPE_ACLEDA_V2,
|
|
27
26
|
Spree::PaymentMethod::TYPE_ACLEDA_MOBILE,
|
|
28
|
-
Spree::PaymentMethod::TYPE_ACLEDA_MINI_APP,
|
|
29
27
|
Spree::PaymentMethod::TYPE_VATTANAC,
|
|
30
28
|
Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP,
|
|
31
29
|
Spree::PaymentMethod::TYPE_TRUE_MONEY,
|
|
@@ -82,6 +80,10 @@ module Vpago
|
|
|
82
80
|
::Vpago::Acleda::PaymentRequestUpdater
|
|
83
81
|
elsif type_acleda_mobile?
|
|
84
82
|
::Vpago::AcledaMobile::PaymentRequestUpdater
|
|
83
|
+
elsif type_acleda_v2?
|
|
84
|
+
::Vpago::AcledaV2::PaymentRequestUpdater
|
|
85
|
+
elsif type_vattanac?
|
|
86
|
+
::Vpago::Vattanac::PaymentRequestUpdater
|
|
85
87
|
end
|
|
86
88
|
end
|
|
87
89
|
|
|
@@ -97,10 +99,6 @@ module Vpago
|
|
|
97
99
|
type == Spree::PaymentMethod::TYPE_ACLEDA_V2
|
|
98
100
|
end
|
|
99
101
|
|
|
100
|
-
def type_acleda_mini_app?
|
|
101
|
-
type == Spree::PaymentMethod::TYPE_ACLEDA_MINI_APP
|
|
102
|
-
end
|
|
103
|
-
|
|
104
102
|
def type_payway?
|
|
105
103
|
type == Spree::PaymentMethod::TYPE_PAYWAY
|
|
106
104
|
end
|
|
@@ -113,6 +111,10 @@ module Vpago
|
|
|
113
111
|
type == Spree::PaymentMethod::TYPE_WINGSDK
|
|
114
112
|
end
|
|
115
113
|
|
|
114
|
+
def type_vattanac?
|
|
115
|
+
type == Spree::PaymentMethod::TYPE_VATTANAC
|
|
116
|
+
end
|
|
117
|
+
|
|
116
118
|
def type_vattanac_mini_app?
|
|
117
119
|
type == Spree::PaymentMethod::TYPE_VATTANAC_MINI_APP
|
|
118
120
|
end
|
|
@@ -14,6 +14,12 @@ module Spree
|
|
|
14
14
|
|
|
15
15
|
pref.blank? || pref[:payment_option].blank? ? payment_method.method_type : pref[:payment_option]
|
|
16
16
|
end
|
|
17
|
+
|
|
18
|
+
# Overried the payment method type to show all payment methods as one list on App.
|
|
19
|
+
# Controlled by ENV["PAYMENT_METHOD_VIEW"] = "split" | "join" (default: "join").
|
|
20
|
+
base.attribute :type do |payment_method|
|
|
21
|
+
ENV.fetch('PAYMENT_METHOD_VIEW', 'join') == 'split' ? payment_method.type : 'payment_method'
|
|
22
|
+
end
|
|
17
23
|
end
|
|
18
24
|
end
|
|
19
25
|
end
|
|
@@ -50,7 +50,7 @@ module Vpago
|
|
|
50
50
|
|
|
51
51
|
def process_acleda_gateway
|
|
52
52
|
data = {
|
|
53
|
-
href: "#{ENV.fetch('
|
|
53
|
+
href: "#{ENV.fetch('PAYMENT_BASE_URL', nil)}/acleda_redirects?payment_number=#{@payment.number}"
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
@redirect_options = data
|
|
@@ -81,7 +81,7 @@ module Vpago
|
|
|
81
81
|
def process_payway_v2_card
|
|
82
82
|
## TO DO: generate redirect url
|
|
83
83
|
data = {
|
|
84
|
-
href: "#{ENV.fetch('
|
|
84
|
+
href: "#{ENV.fetch('PAYMENT_BASE_URL', nil)}/payway_v2_card_popups?payment_number=#{@payment.number}"
|
|
85
85
|
}
|
|
86
86
|
|
|
87
87
|
@redirect_options = data
|
|
@@ -115,7 +115,7 @@ module Vpago
|
|
|
115
115
|
end
|
|
116
116
|
|
|
117
117
|
conn.post(abapay_payment.checkout_url, gateway_params) do |request|
|
|
118
|
-
request.headers['Referer'] = ENV.fetch('
|
|
118
|
+
request.headers['Referer'] = ENV.fetch('PAYMENT_BASE_URL', nil)
|
|
119
119
|
end
|
|
120
120
|
end
|
|
121
121
|
|
|
@@ -127,7 +127,7 @@ module Vpago
|
|
|
127
127
|
def process_payway_card
|
|
128
128
|
## TO DO: generate redirect url
|
|
129
129
|
data = {
|
|
130
|
-
href: "#{ENV.fetch('
|
|
130
|
+
href: "#{ENV.fetch('PAYMENT_BASE_URL', nil)}/payway_card_popups?payment_number=#{@payment.number}"
|
|
131
131
|
}
|
|
132
132
|
|
|
133
133
|
@redirect_options = data
|
|
@@ -135,7 +135,7 @@ module Vpago
|
|
|
135
135
|
|
|
136
136
|
def process_wing_gateway
|
|
137
137
|
data = {
|
|
138
|
-
href: "#{ENV.fetch('
|
|
138
|
+
href: "#{ENV.fetch('PAYMENT_BASE_URL', nil)}/wing_redirects?payment_number=#{@payment.number}"
|
|
139
139
|
}
|
|
140
140
|
|
|
141
141
|
@redirect_options = data
|
|
@@ -169,7 +169,7 @@ module Vpago
|
|
|
169
169
|
end
|
|
170
170
|
|
|
171
171
|
@response = conn.post(abapay_payment.action_url, gateway_params) do |request|
|
|
172
|
-
request.headers['Referer'] = ENV.fetch('
|
|
172
|
+
request.headers['Referer'] = ENV.fetch('PAYMENT_BASE_URL', nil)
|
|
173
173
|
end
|
|
174
174
|
end
|
|
175
175
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<%= render 'spree/admin/payments/source_views/vpago_payment_tmpl',
|
|
2
2
|
payment: payment,
|
|
3
|
-
check_status_url:
|
|
4
|
-
heal_payment_url:
|
|
3
|
+
check_status_url: admin_payment_acleda_v2_querier_path(payment),
|
|
4
|
+
heal_payment_url: admin_payment_acleda_v2_checker_path(payment),
|
|
5
5
|
manual_update_payment_url: '' %>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<%= render 'spree/admin/payments/source_views/vpago_payment_tmpl',
|
|
2
|
-
payment: payment,
|
|
3
|
-
check_status_url:
|
|
4
|
-
heal_payment_url:
|
|
2
|
+
payment: payment,
|
|
3
|
+
check_status_url: admin_payment_vattanac_querier_path(payment),
|
|
4
|
+
heal_payment_url: admin_payment_vattanac_checker_path(payment),
|
|
5
5
|
manual_update_payment_url: ''
|
|
6
6
|
%>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
<script>
|
|
2
|
+
// processing redirects here without rendering once the order is complete, so its
|
|
3
|
+
// Firebase listener never posts this. success only renders for completed orders.
|
|
4
|
+
if (window.parent !== window) {
|
|
5
|
+
window.parent.postMessage("order_is_completed", "*");
|
|
6
|
+
}
|
|
7
|
+
</script>
|
data/config/locales/en.yml
CHANGED
|
@@ -35,5 +35,6 @@ en:
|
|
|
35
35
|
failed_require_updated_reason: "You must provide update reason"
|
|
36
36
|
payment_found_with_result: "Found payment with result: %{result}"
|
|
37
37
|
payment_not_found_with_error: "Payment not found with error: %{error}"
|
|
38
|
+
gateway_timeout: "The payment gateway did not respond in time. Please try again shortly."
|
|
38
39
|
query_status: "Query payment status"
|
|
39
40
|
confirm_manual_update: "Are you sure to update this order to complete"
|
data/config/locales/km.yml
CHANGED
|
@@ -31,5 +31,6 @@ spree:
|
|
|
31
31
|
failed_require_updated_reason: "អ្នកត្រូវតែផ្តល់ហេតុផល"
|
|
32
32
|
payment_found_with_result: "រកឃើញការទូទាត់ជាមួយលទ្ធផល %{result}"
|
|
33
33
|
payment_not_found_with_error: "ការទូទាត់មិនត្រូវបានរកឃើញដោយកំហុស: %{error}"
|
|
34
|
+
gateway_timeout: "ផ្នែកទូទាត់មិនបានឆ្លើយតបទាន់ពេលទេ។ សូមព្យាយាមម្តងទៀតក្នុងពេលឆាប់ៗនេះ។"
|
|
34
35
|
query_status: "សួរស្ថានភាពបង់ប្រាក់"
|
|
35
36
|
confirm_manual_update: "តើអ្នកប្រាកដជាធ្វើបច្ចុប្បន្នភាពការបញ្ជាទិញនេះដើម្បីបញ្ចប់"
|
data/config/routes.rb
CHANGED
|
@@ -17,13 +17,6 @@ Spree::Core::Engine.add_routes do
|
|
|
17
17
|
resources :transactions, only: [:show]
|
|
18
18
|
end
|
|
19
19
|
|
|
20
|
-
# ACLEDA Mini App session init (ACLEDA Mini App Integration Spec, Step 01).
|
|
21
|
-
# ACLEDA calls POST /miniapp/acleda with { phone, first_name, last_name }
|
|
22
|
-
# and receives a session-based miniAppUrl.
|
|
23
|
-
namespace :miniapp do
|
|
24
|
-
resources :acleda, only: [:create], controller: 'acledas'
|
|
25
|
-
end
|
|
26
|
-
|
|
27
20
|
resource :vpago_payments do
|
|
28
21
|
collection do
|
|
29
22
|
get :checkout
|
|
@@ -80,6 +73,12 @@ Spree::Core::Engine.add_routes do
|
|
|
80
73
|
resources :payment_payway_checkers
|
|
81
74
|
resources :payment_payway_markers
|
|
82
75
|
|
|
76
|
+
resources :payment_acleda_v2_queriers, only: [:show]
|
|
77
|
+
resources :payment_acleda_v2_checkers, only: [:update]
|
|
78
|
+
|
|
79
|
+
resources :payment_vattanac_queriers, only: [:show]
|
|
80
|
+
resources :payment_vattanac_checkers, only: [:update]
|
|
81
|
+
|
|
83
82
|
resources :products do
|
|
84
83
|
resources :payout_profile_products
|
|
85
84
|
end
|
data/lib/spree_vpago/engine.rb
CHANGED