spree_vpago 2.2.2.pre.pre28 → 2.2.2.pre.pre29

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f4223baa916c63136d13cdc1e6a10e0cab90401325df3fde6bcd05e837d28556
4
- data.tar.gz: ffff5d2363666590557c939385c4d366a81abb05a05dd0b8914590c8e33af5cc
3
+ metadata.gz: ffd067f1f6d9c43a32e0cd36af72cef8ef042118ea0530119849a8c6440717c3
4
+ data.tar.gz: 6bf1d2fb42028a807548ad022e79bd2f42801a2279032b0adc57149253d793da
5
5
  SHA512:
6
- metadata.gz: dcc8364443a80c55cb2f8b91212bbdf96dd7adf91b80802066bea239a6827759f4201f2f434dc65e1a60ec7106af1bbbafe2b10133cbd1379c704fcf8cf3e4f8
7
- data.tar.gz: 6675fda061cd27a3b34057a304d5f5f7fb93830ee0698df9d7e0d83435668f59d867d1c6b4af22c638469e0075b96651ab899399ccebcf924f2d7a34f6c141a0
6
+ metadata.gz: 47958c255b8149390ff8edcc8607aee7ed16222005b6225e1f2d2b9d8c98b1611fb6cfbff280f686ac916feed853c793e2aec98668b29457712457188c903ece
7
+ data.tar.gz: 070a058604d02f921248fe080989ee1d4502e789aeff0db7a58a40803f401bc14ac44fc71b6cbfefc00508ef436c80da41a9f33e4e7d3672979aeb09d7bbc3d8
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.2.2.pre.pre28)
4
+ spree_vpago (2.2.2.pre.pre29)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
@@ -96,7 +96,7 @@ GEM
96
96
  bundler
97
97
  rake
98
98
  thor (>= 0.14.0)
99
- ast (2.4.2)
99
+ ast (2.4.3)
100
100
  async (1.31.0)
101
101
  console (~> 1.10)
102
102
  nio4r (~> 2.3)
@@ -284,7 +284,10 @@ GEM
284
284
  railties (>= 3.2.16)
285
285
  jsbundling-rails (1.3.1)
286
286
  railties (>= 6.0.0)
287
- json (2.6.3)
287
+ json (2.19.2)
288
+ json-schema (6.2.0)
289
+ addressable (~> 2.8)
290
+ bigdecimal (>= 3.1, < 5)
288
291
  jsonapi-rspec (0.0.11)
289
292
  rspec-core
290
293
  rspec-expectations
@@ -303,8 +306,10 @@ GEM
303
306
  activerecord
304
307
  kaminari-core (= 1.2.2)
305
308
  kaminari-core (1.2.2)
309
+ language_server-protocol (3.17.0.5)
306
310
  launchy (2.5.2)
307
311
  addressable (~> 2.8)
312
+ lint_roller (1.1.0)
308
313
  loofah (2.21.3)
309
314
  crass (~> 1.0.2)
310
315
  nokogiri (>= 1.12.0)
@@ -315,6 +320,8 @@ GEM
315
320
  net-smtp
316
321
  marcel (1.0.2)
317
322
  matrix (0.4.2)
323
+ mcp (0.9.0)
324
+ json-schema (>= 4.1)
318
325
  method_source (1.0.0)
319
326
  mini_magick (4.12.0)
320
327
  mini_mime (1.1.2)
@@ -342,14 +349,16 @@ GEM
342
349
  faraday (>= 1, < 3)
343
350
  sawyer (~> 0.9)
344
351
  os (1.1.4)
345
- parallel (1.23.0)
352
+ parallel (1.27.0)
346
353
  paranoia (2.6.1)
347
354
  activerecord (>= 5.1, < 7.1)
348
- parser (3.2.2.1)
355
+ parser (3.3.10.2)
349
356
  ast (~> 2.4.1)
357
+ racc
350
358
  pg (1.5.3)
351
359
  polyglot (0.3.5)
352
360
  popper_js (1.16.1)
361
+ prism (1.9.0)
353
362
  protocol-hpack (1.4.2)
354
363
  protocol-http (0.24.1)
355
364
  protocol-http1 (0.15.0)
@@ -408,11 +417,12 @@ GEM
408
417
  redis-client (>= 0.9.0)
409
418
  redis-client (0.14.1)
410
419
  connection_pool
411
- regexp_parser (2.8.0)
420
+ regexp_parser (2.11.3)
412
421
  responders (3.2.0)
413
422
  actionpack (>= 7.0)
414
423
  railties (>= 7.0)
415
- rexml (3.2.5)
424
+ rexml (3.2.9)
425
+ strscan
416
426
  rspec-activemodel-mocks (1.1.0)
417
427
  activemodel (>= 3.0)
418
428
  activesupport (>= 3.0)
@@ -438,18 +448,21 @@ GEM
438
448
  rspec-support (3.12.0)
439
449
  rspec_junit_formatter (0.6.0)
440
450
  rspec-core (>= 2, < 4, != 2.12.0)
441
- rubocop (1.51.0)
451
+ rubocop (1.85.1)
442
452
  json (~> 2.3)
453
+ language_server-protocol (~> 3.17.0.2)
454
+ lint_roller (~> 1.1.0)
455
+ mcp (~> 0.6)
443
456
  parallel (~> 1.10)
444
- parser (>= 3.2.0.0)
457
+ parser (>= 3.3.0.2)
445
458
  rainbow (>= 2.2.2, < 4.0)
446
- regexp_parser (>= 1.8, < 3.0)
447
- rexml (>= 3.2.5, < 4.0)
448
- rubocop-ast (>= 1.28.0, < 2.0)
459
+ regexp_parser (>= 2.9.3, < 3.0)
460
+ rubocop-ast (>= 1.49.0, < 2.0)
449
461
  ruby-progressbar (~> 1.7)
450
- unicode-display_width (>= 2.4.0, < 3.0)
451
- rubocop-ast (1.28.1)
452
- parser (>= 3.2.1.0)
462
+ unicode-display_width (>= 2.4.0, < 4.0)
463
+ rubocop-ast (1.49.1)
464
+ parser (>= 3.3.7.2)
465
+ prism (~> 1.7)
453
466
  rubocop-rails (2.19.1)
454
467
  activesupport (>= 4.2.0)
455
468
  rack (>= 1.1)
@@ -606,6 +619,7 @@ GEM
606
619
  stimulus-rails (1.3.4)
607
620
  railties (>= 6.0.0)
608
621
  stringex (2.8.6)
622
+ strscan (3.1.7)
609
623
  thor (1.2.2)
610
624
  tilt (2.1.0)
611
625
  timecop (0.9.6)
@@ -619,7 +633,9 @@ GEM
619
633
  railties (>= 6.0.0)
620
634
  tzinfo (2.0.6)
621
635
  concurrent-ruby (~> 1.0)
622
- unicode-display_width (2.4.2)
636
+ unicode-display_width (3.2.0)
637
+ unicode-emoji (~> 4.1)
638
+ unicode-emoji (4.2.0)
623
639
  validates_zipcode (0.5.2)
624
640
  activemodel (>= 4.2.0)
625
641
  vcr (6.2.0)
@@ -5,16 +5,14 @@ module Spree
5
5
  scope = current_store.payment_methods_including_vendor.accessible_by(current_ability, :index)
6
6
 
7
7
  if params[:tab] == 'vendors'
8
- scope = scope.where.not(vendor_id: nil)
8
+ scope.where.not(vendor_id: nil)
9
9
  elsif params[:tab] == 'tenants'
10
- scope = scope.joins(:vendor)
11
- .where.not(vendor_id: nil)
12
- .where.not(spree_vendors: { tenant_id: nil })
10
+ scope.joins(:vendor)
11
+ .where.not(vendor_id: nil)
12
+ .where.not(spree_vendors: { tenant_id: nil })
13
13
  else
14
- scope = scope.where(vendor_id: nil)
14
+ scope.where(vendor_id: nil)
15
15
  end
16
-
17
- scope
18
16
  end
19
17
 
20
18
  # override
@@ -51,7 +49,7 @@ module Spree
51
49
  end
52
50
 
53
51
  attributes = payment_method_params.merge(preferences_params)
54
- attributes.each do |k, _v|
52
+ attributes.each_key do |k|
55
53
  attributes.delete(k) if k.include?('password') && attributes[k].blank?
56
54
  end
57
55
 
@@ -15,7 +15,7 @@ module Vpago
15
15
 
16
16
  # Each payment method may have their own additional processing script,
17
17
  # so we will look for the partial based on the payment method class name.
18
- #
18
+ #
19
19
  # eg. processing_scripts/spree/gateway/payway_v2
20
20
  def render_additional_processing_script(payment)
21
21
  processing_script_partial_path = "spree/vpago_payments/processing_scripts/#{payment.payment_method.class.to_s.underscore}"
@@ -156,7 +156,14 @@ module Spree
156
156
  end
157
157
 
158
158
  def check_transaction(payment)
159
- checker = Vpago::PaywayV2::TransactionStatus.new(payment)
159
+ # ABA requires the use of the v2 API, but it does not yet support payout responses.
160
+ # Until v2 fully supports payouts, we fall back to v1 when payouts are enabled.
161
+ # Otherwise, we use v2 by default.
162
+ checker = if enable_payout?
163
+ Vpago::PaywayV2::TransactionStatus.new(payment)
164
+ else
165
+ Vpago::PaywayV2::TransactionStatusV2.new(payment)
166
+ end
160
167
  checker.call
161
168
  checker
162
169
  end
@@ -199,7 +206,7 @@ module Spree
199
206
 
200
207
  return nil if payouts_response.nil? || !payouts_response.is_a?(Array) || payouts_response.empty?
201
208
 
202
- payouts_response.map { |payout| payout['amt'].to_f || 0 }.sum
209
+ payouts_response.map { |payout| payout['amt'].to_f }.sum
203
210
  end
204
211
  end
205
212
  end
@@ -19,13 +19,9 @@
19
19
  }
20
20
 
21
21
  function openUrl(url, delay = 0) {
22
- if(delay > 0) {
23
- setTimeout(function() {
24
- window.location.href = url;
25
- }, delay);
26
- } else {
22
+ setTimeout(function() {
27
23
  window.location.href = url;
28
- }
24
+ }, delay);
29
25
  }
30
26
 
31
27
  function showRedirectContainer(buttonLabel = null, onClick = null) {
@@ -57,12 +53,11 @@
57
53
  return response.json();
58
54
  })
59
55
  .then(function(data) {
60
- var shouldDelayBeforeOpenCheckoutUrl = false;
61
56
  var shouldShowRedirectContainer = false;
62
57
 
63
58
  console.log("[Vpago] checkout response data:", JSON.stringify(data));
64
59
 
65
- // When status code is 4 (dublicated transaction),
60
+ // When status code is 4 (duplicated transaction),
66
61
  // Possibly user refresh the checkout page even after the transaction is completed.
67
62
  // So in this case, we should hide loading spinner and show redirect container UI
68
63
  // While it check transaction status in the background. It will automatically redirect user to the result page after checking.
@@ -74,12 +69,11 @@
74
69
 
75
70
  if (data.abapay_deeplink && shouldOpenAbaPayDeeplink) {
76
71
  openDeeplinkUrl(data.abapay_deeplink);
77
- shouldDelayBeforeOpenCheckoutUrl = true;
78
72
  shouldShowRedirectContainer = true;
79
73
  }
80
74
 
81
75
  if (data.checkout_qr_url && shouldOpenCheckoutUrl) {
82
- openUrl(data.checkout_qr_url, shouldDelayBeforeOpenCheckoutUrl ? 500 : 0);
76
+ openUrl(data.checkout_qr_url);
83
77
  shouldShowRedirectContainer = false;
84
78
  }
85
79
 
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.2.2-pre28'.freeze
4
+ VERSION = '2.2.2-pre29'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
@@ -24,7 +24,7 @@ module Vpago
24
24
  end
25
25
 
26
26
  def amount
27
- format('%.2f', (@payment.amount + transaction_fee))
27
+ format('%.2f', @payment.amount + transaction_fee)
28
28
  end
29
29
 
30
30
  def transaction_fee_fix
@@ -103,8 +103,15 @@ module Vpago
103
103
  end
104
104
 
105
105
  def return_deeplink_url
106
- # for some cases opening from telegram webview, fb, messenger webview, deeplink back to app doesn't work.
107
- # so, return nil will ensure ABA won't return back to wrong app, for android, it will auto pop which to previous app and correct behavior, for ios, it will stuck, user can click back button to go back to app.
106
+ # In Telegram, Facebook, and Messenger webviews, there is no reliable way for
107
+ # ABA to detect the originating app. Using `continue_success_url` may open the
108
+ # default browser instead of the intended app (e.g., Telegram or Facebook),
109
+ # resulting in a poor user experience.
110
+ #
111
+ # To prevent ABA from returning to the wrong app, we allow returning nil by
112
+ # setting `disable_return_deeplink: true`:
113
+ # - Android: ABA app automatically returns to the previous app (expected behavior)
114
+ # - iOS: no automatic redirect occurs, but users can tap "Back to <App>" at the top of ABA
108
115
  return nil if @disable_return_deeplink
109
116
 
110
117
  app_scheme = @payment.payment_method.preferences[:app_scheme]
@@ -1,52 +1,37 @@
1
1
  require 'faraday'
2
2
 
3
- # API documentation:
4
- # https://developer.payway.com.kh/check-transaction-14530826e0
5
3
  module Vpago
6
4
  module PaywayV2
7
5
  class TransactionStatus < Base
6
+ # status:
7
+ # 0 – Approved, PRE_AUTH, PREAUTH_APPROVED
8
+ # 1 – Created
9
+ # 2 – Pending
10
+ # 3 – Declined
11
+ # 4 – Refunded
12
+ # 5 – Wrong Hash
13
+ # 7 - Cancelled
14
+ # 11 – Other Server-side Error
8
15
  def call
9
16
  @response = check_remote_status
10
17
  end
11
18
 
12
- # 00 : Success!
13
- # 5 : Invalid hash
14
- # 6 : Transaction not found
15
- # 8 : Invalid merchant profile
16
- # 11 : Internal server error
17
- # 429 : Reach request limit
18
- def status_code
19
- status_data = json_response['status']
20
- return nil unless status_data.is_a?(Hash)
21
-
22
- status_data['code']
23
- end
24
-
25
- # APPROVED : Transaction successfully completed with the full purchase amount.
26
- # PRE-AUTH : Transaction successfully processed with a pre-authorization hold on funds pending final capture.
27
- # REFUNDED : Transaction has been fully or partially refunded.
28
- # PENDING : Transaction is awaiting payment completion by the payer.
29
- # DECLINED : Transaction has been declined.
30
- # CANCELLED : Merchant canceled the pre-authorization or closed the transaction.
31
- def payment_status
32
- data = json_response['data']
33
- return nil unless data.is_a?(Hash)
34
-
35
- data['payment_status']
19
+ def status
20
+ json_response['status']&.to_s
36
21
  end
37
22
 
38
23
  def success?
39
- %w[APPROVED PRE-AUTH].include?(payment_status)
24
+ status == '0'
40
25
  end
41
26
 
42
27
  # request failed does not mean payment failed.
43
28
  # but it failed when status is failed.
44
29
  def pending?
45
- %w[PENDING].include?(payment_status)
30
+ %w[1 2].include?(status)
46
31
  end
47
32
 
48
33
  def failed?
49
- %w[5 6 8].include?(status_code) || %w[DECLINED CANCELLED].include?(payment_status)
34
+ %w[3 4 5 7].include?(status)
50
35
  end
51
36
 
52
37
  def check_remote_status
@@ -69,7 +54,7 @@ module Vpago
69
54
 
70
55
  return nil if payouts_response.nil? || !payouts_response.is_a?(Array) || payouts_response.empty?
71
56
 
72
- payouts_response.map { |payout| payout['amt'].to_f || 0 }.sum
57
+ payouts_response.map { |payout| payout['amt'].to_f }.sum
73
58
  end
74
59
 
75
60
  def error_message
@@ -93,7 +78,7 @@ module Vpago
93
78
  end
94
79
 
95
80
  def check_transaction_url
96
- "#{host}/api/payment-gateway/v1/payments/check-transaction-2"
81
+ "#{host}/api/payment-gateway/v1/payments/check-transaction"
97
82
  end
98
83
  end
99
84
  end
@@ -0,0 +1,95 @@
1
+ require 'faraday'
2
+
3
+ # API documentation:
4
+ # https://developer.payway.com.kh/check-transaction-14530826e0
5
+ module Vpago
6
+ module PaywayV2
7
+ class TransactionStatusV2 < Base
8
+ def call
9
+ @response = check_remote_status
10
+ end
11
+
12
+ # 00 : Success!
13
+ # 5 : Invalid hash
14
+ # 6 : Transaction not found
15
+ # 8 : Invalid merchant profile
16
+ # 11 : Internal server error
17
+ # 429 : Reach request limit
18
+ def status_code
19
+ status_data = json_response['status']
20
+ return nil unless status_data.is_a?(Hash)
21
+
22
+ status_data['code']&.to_s
23
+ end
24
+
25
+ # APPROVED : Transaction successfully completed with the full purchase amount.
26
+ # PRE-AUTH : Transaction successfully processed with a pre-authorization hold on funds pending final capture.
27
+ # REFUNDED : Transaction has been fully or partially refunded.
28
+ # PENDING : Transaction is awaiting payment completion by the payer.
29
+ # DECLINED : Transaction has been declined.
30
+ # CANCELLED : Merchant canceled the pre-authorization or closed the transaction.
31
+ def payment_status
32
+ data = json_response['data']
33
+ return nil unless data.is_a?(Hash)
34
+
35
+ data['payment_status']
36
+ end
37
+
38
+ def success?
39
+ %w[APPROVED PRE-AUTH].include?(payment_status)
40
+ end
41
+
42
+ # request failed does not mean payment failed.
43
+ # but it failed when status is failed.
44
+ def pending?
45
+ %w[PENDING].include?(payment_status)
46
+ end
47
+
48
+ def failed?
49
+ %w[5 6 8].include?(status_code) || %w[DECLINED CANCELLED].include?(payment_status)
50
+ end
51
+
52
+ def check_remote_status
53
+ conn = Faraday::Connection.new do |faraday|
54
+ faraday.request :url_encoded
55
+ end
56
+
57
+ data = {
58
+ req_time: req_time,
59
+ merchant_id: merchant_id,
60
+ tran_id: transaction_id,
61
+ hash: checker_hmac
62
+ }
63
+
64
+ conn.post(check_transaction_url, data)
65
+ end
66
+
67
+ def error_message
68
+ status_data = json_response['status']
69
+ return nil unless status_data.is_a?(Hash)
70
+
71
+ status_data['message']
72
+ end
73
+
74
+ def json_response
75
+ @json_response ||= begin
76
+ JSON.parse(@response.body)
77
+ rescue JSON::ParserError
78
+ {}
79
+ end
80
+ end
81
+
82
+ def checker_hmac
83
+ data = "#{req_time}#{merchant_id}#{transaction_id}"
84
+ hash = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha512'), api_key, data))
85
+
86
+ # somehow php counter part are not able to decode if the \n present.
87
+ hash.delete("\n")
88
+ end
89
+
90
+ def check_transaction_url
91
+ "#{host}/api/payment-gateway/v1/payments/check-transaction-2"
92
+ end
93
+ end
94
+ end
95
+ 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.pre28
4
+ version: 2.2.2.pre.pre29
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-20 00:00:00.000000000 Z
11
+ date: 2026-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -404,6 +404,7 @@ files:
404
404
  - lib/vpago/payway_v2/pre_auth_canceler.rb
405
405
  - lib/vpago/payway_v2/pre_auth_completer.rb
406
406
  - lib/vpago/payway_v2/transaction_status.rb
407
+ - lib/vpago/payway_v2/transaction_status_v2.rb
407
408
  - lib/vpago/true_money/base.rb
408
409
  - lib/vpago/true_money/checkout.rb
409
410
  - lib/vpago/true_money/refund_issuer.rb