spree_vpago 2.2.2.pre.pre37 → 2.2.2.pre.pre40
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 +1 -1
- data/app/controllers/spree/admin/payment_payway_queriers_controller.rb +2 -10
- data/app/controllers/spree/vpago_payments_controller.rb +17 -12
- data/app/models/spree/gateway/payway_v2.rb +1 -1
- data/app/models/vpago/payment_decorator.rb +12 -1
- data/app/models/vpago/payouts_generator.rb +1 -1
- data/app/views/spree/vpago_payments/forms/spree/gateway/_payway_v2.html.erb +1 -1
- data/lib/spree_vpago/version.rb +1 -1
- data/lib/vpago/payway_v2/payment_request_updater.rb +2 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: ba1b0a5520634444abf62c6b2bd65ed6660be8bbad0f53ae16a3eb359cabe260
|
|
4
|
+
data.tar.gz: 56fc2911ed815ec53799f6d0a6456d64798e513de758830e34c79af6b871df16
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b29505ce698611342dc6eb6ab1a787cb8ec7a427244a25db1cd476b17431b0425603fd6b8b8cb30ba5262155e5a701d910f5a4bb182815bc64b6daf151fa5f6f
|
|
7
|
+
data.tar.gz: fd7291a06bb337ea5be06da2d0ef7cd2bd0affec96c73057d9d34eceda56b44ec7954347bf1b2858dcd3aa207bca9b5a72db66e101e62c6179b7e1b17038ea91
|
data/Gemfile.lock
CHANGED
|
@@ -2,11 +2,11 @@ module Spree
|
|
|
2
2
|
module Admin
|
|
3
3
|
class PaymentPaywayQueriersController < PaymentPaywayBaseController
|
|
4
4
|
include Spree::Backend::Callbacks
|
|
5
|
+
|
|
5
6
|
around_action :set_writing_role, only: %i[show]
|
|
6
7
|
|
|
7
8
|
def show
|
|
8
|
-
tran_status =
|
|
9
|
-
tran_status.call
|
|
9
|
+
tran_status = @payment.payment_method.check_transaction(@payment)
|
|
10
10
|
|
|
11
11
|
if tran_status.success?
|
|
12
12
|
@payment.update_column(:gateway_status, true)
|
|
@@ -19,14 +19,6 @@ module Spree
|
|
|
19
19
|
redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
|
|
20
20
|
end
|
|
21
21
|
|
|
22
|
-
def transaction_status_service
|
|
23
|
-
if @payment.payment_method.type_payway_v2?
|
|
24
|
-
Vpago::PaywayV2::TransactionStatus
|
|
25
|
-
elsif @payment.payment_method.type_payway?
|
|
26
|
-
Vpago::Payway::TransactionStatus
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
|
|
30
22
|
private
|
|
31
23
|
|
|
32
24
|
def set_writing_role
|
|
@@ -16,6 +16,8 @@ module Spree
|
|
|
16
16
|
return redirect_to @payment.processing_url, allow_other_host: true unless @payment.checkout?
|
|
17
17
|
|
|
18
18
|
@order = @payment.order
|
|
19
|
+
|
|
20
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Showing checkout page for order #{@order.number}")
|
|
19
21
|
end
|
|
20
22
|
|
|
21
23
|
# GET
|
|
@@ -25,7 +27,7 @@ module Spree
|
|
|
25
27
|
|
|
26
28
|
@order = @payment.order
|
|
27
29
|
|
|
28
|
-
Rails.logger.info("[Vpago]
|
|
30
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Showing processing page for order #{@order.number}")
|
|
29
31
|
end
|
|
30
32
|
|
|
31
33
|
# GET
|
|
@@ -36,7 +38,7 @@ module Spree
|
|
|
36
38
|
@order = @payment.order
|
|
37
39
|
raise CanCan::AccessDenied unless @order.completed?
|
|
38
40
|
|
|
39
|
-
Rails.logger.info("[Vpago]
|
|
41
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Showing success page for order #{@order.number}")
|
|
40
42
|
end
|
|
41
43
|
|
|
42
44
|
# GET
|
|
@@ -48,9 +50,9 @@ module Spree
|
|
|
48
50
|
return render json: { status: :failed }, status: :ok if @payment.failed?
|
|
49
51
|
|
|
50
52
|
if @payment.payment_method.support_check_transaction_api?
|
|
51
|
-
Rails.logger.info("[Vpago] Checking transaction for payment #{@payment.number}")
|
|
53
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Checking transaction for payment #{@payment.number}")
|
|
52
54
|
checker = @payment.payment_method.check_transaction(@payment)
|
|
53
|
-
Rails.logger.info("[Vpago] Check transaction result for payment #{@payment.number} with success: #{checker.success?}, failed: #{checker.try(:failed?)}")
|
|
55
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Check transaction result for payment #{@payment.number} with success: #{checker.success?}, failed: #{checker.try(:failed?)}")
|
|
54
56
|
|
|
55
57
|
if checker.success?
|
|
56
58
|
render json: { status: :success }, status: :ok
|
|
@@ -60,43 +62,46 @@ module Spree
|
|
|
60
62
|
render json: { status: :pending }, status: :ok
|
|
61
63
|
end
|
|
62
64
|
else
|
|
65
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Payment method does not support check transaction API")
|
|
63
66
|
render json: { status: :pending }, status: :ok
|
|
64
67
|
end
|
|
65
68
|
end
|
|
66
69
|
|
|
67
70
|
# POST
|
|
68
71
|
def process_payment
|
|
69
|
-
Rails.logger.info("[Vpago] Received payment notification: method=#{request.method}, params=#{params.to_unsafe_h}")
|
|
70
72
|
return render json: { status: :ok }, status: :ok if request.method != 'POST'
|
|
71
73
|
|
|
72
74
|
return_params = sanitize_return_params
|
|
73
75
|
@payment = Vpago::PaymentFinder.new(return_params).find_and_verify
|
|
74
76
|
|
|
77
|
+
# log process payment requested
|
|
78
|
+
Rails.logger.info("[Vpago][#{@payment&.number}] Process payment requested with params: #{return_params}")
|
|
79
|
+
|
|
75
80
|
if @payment.nil?
|
|
76
81
|
Rails.logger.error("[Vpago] Payment not found for params: #{return_params}")
|
|
77
82
|
return render_not_found
|
|
78
83
|
end
|
|
79
84
|
|
|
80
|
-
Rails.logger.info("[Vpago] Payment found: #{@payment&.number}, order: #{@payment&.order&.number}")
|
|
85
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Payment found: #{@payment&.number}, order: #{@payment&.order&.number}")
|
|
81
86
|
|
|
82
87
|
# for ABA reviewing mode, we can disable pushback from bank, and only process it from our app UI instead.
|
|
83
88
|
# This will give ABA team to know that we don't rely on just pushback and have fallback to process payment.
|
|
84
89
|
if @payment.payment_method.type_payway_v2? && @payment.payment_method.reviewing_mode? && request_from_external_server?
|
|
85
|
-
Rails.logger.info("[Vpago] Received payment notification from bank in reviewing mode, skipping processing
|
|
90
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Received payment notification from bank in reviewing mode, skipping processing")
|
|
86
91
|
return render json: { status: :ok }, status: :ok
|
|
87
92
|
end
|
|
88
93
|
|
|
89
94
|
unless @payment.order.paid?
|
|
90
|
-
Rails.logger.info("[Vpago] Enqueuing payment processor job for payment #{@payment.number}
|
|
95
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Enqueuing payment processor job for payment #{@payment.number}")
|
|
91
96
|
Vpago::PaymentProcessorJob.perform_later(
|
|
92
97
|
payment_number: @payment.number
|
|
93
98
|
)
|
|
94
99
|
end
|
|
95
100
|
|
|
96
|
-
Rails.logger.info("[Vpago] Successfully enqueued payment processor job for payment #{@payment.number}
|
|
101
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Successfully enqueued payment processor job for payment #{@payment.number}")
|
|
97
102
|
render json: { status: :ok }, status: :ok
|
|
98
103
|
rescue StandardError => e
|
|
99
|
-
Rails.logger.error("[Vpago] Failed to enqueue payment processor job
|
|
104
|
+
Rails.logger.error("[Vpago][#{@payment.number}] Failed to enqueue payment processor job for payment #{@payment.number}: #{e.message}")
|
|
100
105
|
render json: { status: :internal_server_error, message: 'Failed to enqueue payment processor job' }, status: :internal_server_error
|
|
101
106
|
end
|
|
102
107
|
|
|
@@ -108,11 +113,11 @@ module Spree
|
|
|
108
113
|
return render_not_found unless @payment
|
|
109
114
|
|
|
110
115
|
Vpago::PaymentProcessorJob.perform_later(payment_number: @payment.number) unless @payment.order.paid?
|
|
111
|
-
Rails.logger.info("[Vpago] Successfully enqueued payment processor job for payment #{@payment.number}
|
|
116
|
+
Rails.logger.info("[Vpago][#{@payment.number}] Successfully enqueued payment processor job for payment #{@payment.number}")
|
|
112
117
|
|
|
113
118
|
render json: { status: { code: '000001', message: 'success' }, data: nil }, status: :ok
|
|
114
119
|
rescue StandardError => e
|
|
115
|
-
Rails.logger.error("[Vpago] Failed to enqueue payment processor job
|
|
120
|
+
Rails.logger.error("[Vpago][#{@payment.number}] Failed to enqueue payment processor job for payment #{@payment.number}: #{e.message}")
|
|
116
121
|
render json: { status: :internal_server_error, message: 'Failed to enqueue payment processor job' }, status: :internal_server_error
|
|
117
122
|
end
|
|
118
123
|
|
|
@@ -159,7 +159,7 @@ module Spree
|
|
|
159
159
|
# ABA requires the use of the v2 API, but it does not yet support payout responses.
|
|
160
160
|
# Until v2 fully supports payouts, we fall back to v1 when payouts are enabled.
|
|
161
161
|
# Otherwise, we use v2 by default.
|
|
162
|
-
checker = if payment.
|
|
162
|
+
checker = if payment.preload_payout_ids.any?
|
|
163
163
|
Vpago::PaywayV2::TransactionStatus.new(payment)
|
|
164
164
|
else
|
|
165
165
|
Vpago::PaywayV2::TransactionStatusV2.new(payment)
|
|
@@ -33,6 +33,17 @@ module Vpago
|
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
35
|
|
|
36
|
+
# Stores preloaded payout IDs in private_metadata to avoid N+1 queries
|
|
37
|
+
# when checking whether payouts exist for this payment.
|
|
38
|
+
def preload_payout_ids=(ids)
|
|
39
|
+
self.private_metadata ||= {}
|
|
40
|
+
self.private_metadata['preload_payout_ids'] = ids
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def preload_payout_ids
|
|
44
|
+
self.private_metadata&.fetch('preload_payout_ids', []) || []
|
|
45
|
+
end
|
|
46
|
+
|
|
36
47
|
# override
|
|
37
48
|
def process!
|
|
38
49
|
reset_for_retry! if failed?
|
|
@@ -106,4 +117,4 @@ module Vpago
|
|
|
106
117
|
end
|
|
107
118
|
end
|
|
108
119
|
|
|
109
|
-
Spree::Payment.prepend(Vpago::PaymentDecorator) unless Spree::Payment.
|
|
120
|
+
Spree::Payment.prepend(Vpago::PaymentDecorator) unless Spree::Payment.include?(Vpago::PaymentDecorator)
|
|
@@ -39,7 +39,7 @@ module Vpago
|
|
|
39
39
|
|
|
40
40
|
# If any payouts were rounded, the total may increase slightly.
|
|
41
41
|
# Update the payment amount to match the sum of payouts to avoid mismatch errors.
|
|
42
|
-
payment.update(amount: payouts.map(&:amount).sum)
|
|
42
|
+
payment.update(amount: payouts.map(&:amount).sum, preload_payout_ids: payouts.map(&:id))
|
|
43
43
|
|
|
44
44
|
payouts
|
|
45
45
|
end
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
|
|
73
73
|
shouldShowRedirectContainer = !shouldOpenCheckoutUrl && shouldOpenAbaPayDeeplink;
|
|
74
74
|
if(shouldShowRedirectContainer){
|
|
75
|
-
showRedirectContainer("Open ABA Mobile", () =>
|
|
75
|
+
showRedirectContainer("Open ABA Mobile", () => window.location.href = data.abapay_deeplink);
|
|
76
76
|
}
|
|
77
77
|
})
|
|
78
78
|
.catch(function(error) {
|
data/lib/spree_vpago/version.rb
CHANGED
|
@@ -52,13 +52,11 @@ module Vpago
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def check_payway_status
|
|
55
|
-
|
|
56
|
-
trans_status.call
|
|
57
|
-
trans_status
|
|
55
|
+
@payment.payment_method.check_transaction(@payment)
|
|
58
56
|
end
|
|
59
57
|
|
|
60
58
|
def items_eligible?
|
|
61
|
-
@payment&.order&.line_items&.all?(&:sufficient_stock?) == true
|
|
59
|
+
@payment&.order&.line_items&.all?(&:sufficient_stock?) == true # rubocop:disable Style/SafeNavigationChainLength
|
|
62
60
|
end
|
|
63
61
|
end
|
|
64
62
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spree_vpago
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.2.2.pre.
|
|
4
|
+
version: 2.2.2.pre.pre40
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- You
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-03-
|
|
11
|
+
date: 2026-03-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: faraday
|