spree_vpago 2.3.9 → 2.3.10

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: 24c3243a11a22045eb530115ea1412bc74d8f9cc1d03ea821d5813f2859cf380
4
- data.tar.gz: 26ade26146ad653b7dff55b117b099b3988fab1c210e04a5b27e6a25e2562df1
3
+ metadata.gz: 83977e379d14f72df6f9812c0053817ead75a9a29d9dbb26efbb505679fd34f1
4
+ data.tar.gz: d478a6a31649dba472adebefb5890c60a5222107252c71b9a835d7260e95cf97
5
5
  SHA512:
6
- metadata.gz: 821eb790249845feafc9f5cfa1349e24a47d3426c48b194051f4351ec518935f96f51863f2ac5e9dbd69e139baafef01492eae79ea18f1ffd6d369cd593a9a9a
7
- data.tar.gz: fc8c75f49fba47c371442c8dd089d0185f125ee0b6316d569e6121d2c0dab98b0e5c64d182334cc674bd2289a2f2620e9f6d3a17139f791acacf06097fc420a7
6
+ metadata.gz: 9c76fd67f78cacde387d8b817ec6b2ff9707dc39fb31d1419498af347c8aee1bf12d4d533af79c0ad90efb44ae80517096a9578e803e6fd2fe937380eca8478b
7
+ data.tar.gz: 3d44c01a03c35f692ba70d5091a41ca03d9c7e3e9fdd37e0a87b984196e155c37534462b39d396e970462a2522fa6fdde9d60b525147689ccc1184c28e8cb42f
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_vpago (2.3.9)
4
+ spree_vpago (2.3.10)
5
5
  faraday
6
6
  google-cloud-firestore
7
7
  spree_api (>= 4.5)
@@ -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
 
@@ -60,6 +60,12 @@ module Spree
60
60
  else
61
61
  render json: { status: :pending }, status: :ok
62
62
  end
63
+ rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
64
+ VpagoLogger.error(
65
+ label: 'Spree::VpagoPaymentsController#check_transaction gateway_timeout',
66
+ data: vpago_log_context(error_class: e.class.name, error_message: e.message)
67
+ )
68
+ render json: { status: :pending }, status: :ok
63
69
  end
64
70
 
65
71
  # POST
@@ -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
@@ -102,7 +102,7 @@ module Vpago
102
102
  # override this method if you want flexibility
103
103
  # for example, host per payment method or tenant
104
104
  def payment_host
105
- ENV.fetch('DEFAULT_URL_HOST')
105
+ ENV.fetch('PAYMENT_BASE_URL')
106
106
  end
107
107
  end
108
108
  end
@@ -50,7 +50,7 @@ module Vpago
50
50
 
51
51
  def process_acleda_gateway
52
52
  data = {
53
- href: "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/acleda_redirects?payment_number=#{@payment.number}"
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('DEFAULT_URL_HOST', nil)}/payway_v2_card_popups?payment_number=#{@payment.number}"
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('DEFAULT_URL_HOST', nil)
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('DEFAULT_URL_HOST', nil)}/payway_card_popups?payment_number=#{@payment.number}"
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('DEFAULT_URL_HOST', nil)}/wing_redirects?payment_number=#{@payment.number}"
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('DEFAULT_URL_HOST', nil)
172
+ request.headers['Referer'] = ENV.fetch('PAYMENT_BASE_URL', nil)
173
173
  end
174
174
  end
175
175
 
@@ -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"
@@ -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: "តើអ្នកប្រាកដជាធ្វើបច្ចុប្បន្នភាពការបញ្ជាទិញនេះដើម្បីបញ្ចប់"
@@ -1,7 +1,7 @@
1
1
  module SpreeVpago
2
2
  module_function
3
3
 
4
- VERSION = '2.3.9'.freeze
4
+ VERSION = '2.3.10'.freeze
5
5
 
6
6
  def version
7
7
  Gem::Version.new VERSION
@@ -0,0 +1,6 @@
1
+ module Vpago
2
+ module HttpTimeouts
3
+ OPEN_TIMEOUT = 5
4
+ TIMEOUT = 15
5
+ end
6
+ end
@@ -28,6 +28,11 @@ module Vpago
28
28
  elsif checker.failed?
29
29
  mark_payment_as_failed(checker.error_message)
30
30
  end
31
+ rescue Faraday::TimeoutError, Faraday::ConnectionFailed => e
32
+ VpagoLogger.error(
33
+ label: 'Vpago::PaywayV2::PaymentRequestUpdater#process_payment_status gateway_timeout',
34
+ data: { payment_number: @payment.number, error_class: e.class.name, error_message: e.message }
35
+ )
31
36
  end
32
37
 
33
38
  def mark_payment_as_success(checker)
@@ -37,6 +37,8 @@ module Vpago
37
37
  def check_remote_status
38
38
  conn = Faraday::Connection.new do |faraday|
39
39
  faraday.request :url_encoded
40
+ faraday.options.open_timeout = Vpago::HttpTimeouts::OPEN_TIMEOUT
41
+ faraday.options.timeout = Vpago::HttpTimeouts::TIMEOUT
40
42
  end
41
43
 
42
44
  data = {
@@ -52,6 +52,8 @@ module Vpago
52
52
  def check_remote_status
53
53
  conn = Faraday::Connection.new do |faraday|
54
54
  faraday.request :url_encoded
55
+ faraday.options.open_timeout = Vpago::HttpTimeouts::OPEN_TIMEOUT
56
+ faraday.options.timeout = Vpago::HttpTimeouts::TIMEOUT
55
57
  end
56
58
 
57
59
  data = {
@@ -100,7 +100,7 @@ module Vpago
100
100
  end
101
101
 
102
102
  def fetch_access_token
103
- response = Faraday.post(
103
+ response = Faraday.new(request: { open_timeout: Vpago::HttpTimeouts::OPEN_TIMEOUT, timeout: Vpago::HttpTimeouts::TIMEOUT }).post(
104
104
  access_token_url,
105
105
  URI.encode_www_form(
106
106
  grant_type: 'client_credentials',
@@ -2,7 +2,7 @@ module Vpago
2
2
  module TrueMoney
3
3
  class TransactionStatus < Base
4
4
  def call
5
- @response = Faraday.get(check_transaction_url, nil, default_headers)
5
+ @response = Faraday.new(request: { open_timeout: Vpago::HttpTimeouts::OPEN_TIMEOUT, timeout: Vpago::HttpTimeouts::TIMEOUT }).get(check_transaction_url, nil, default_headers)
6
6
  end
7
7
 
8
8
  def success?
@@ -70,7 +70,8 @@ module Vpago
70
70
  private
71
71
 
72
72
  def fetch_access_token
73
- response = Faraday.post(access_token_url, { username: username, password: password }.to_json, { 'Content-Type' => CONTENT_TYPE_JSON })
73
+ response = Faraday.new(request: { open_timeout: Vpago::HttpTimeouts::OPEN_TIMEOUT, timeout: Vpago::HttpTimeouts::TIMEOUT })
74
+ .post(access_token_url, { username: username, password: password }.to_json, { 'Content-Type' => CONTENT_TYPE_JSON })
74
75
 
75
76
  raise "Access Token Error: #{response.status} - #{response.body}" unless response.success?
76
77
 
@@ -78,7 +79,7 @@ module Vpago
78
79
  end
79
80
 
80
81
  def post(url, body)
81
- response = Faraday.post(url, body.to_json, default_headers)
82
+ response = Faraday.new(request: { open_timeout: Vpago::HttpTimeouts::OPEN_TIMEOUT, timeout: Vpago::HttpTimeouts::TIMEOUT }).post(url, body.to_json, default_headers)
82
83
  parse_json(response.body)
83
84
  end
84
85
  end
@@ -33,7 +33,7 @@ module Vpago
33
33
  end
34
34
 
35
35
  def return_url
36
- "#{ENV.fetch('DEFAULT_URL_HOST', nil)}/webhook/wings/#{payment_number}/return?app_checkout=#{app_checkout}"
36
+ "#{ENV.fetch('PAYMENT_BASE_URL', nil)}/webhook/wings/#{payment_number}/return?app_checkout=#{app_checkout}"
37
37
  end
38
38
 
39
39
  def app_checkout
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.3.9
4
+ version: 2.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - You
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-07-29 00:00:00.000000000 Z
11
+ date: 2026-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -401,6 +401,7 @@ files:
401
401
  - lib/vpago/acleda_v2/base.rb
402
402
  - lib/vpago/acleda_v2/checkout.rb
403
403
  - lib/vpago/acleda_v2/transaction_status.rb
404
+ - lib/vpago/http_timeouts.rb
404
405
  - lib/vpago/payment_amount_calculator.rb
405
406
  - lib/vpago/payment_request_updater.rb
406
407
  - lib/vpago/payment_status_marker.rb