zai_payment 2.3.1 → 2.3.2

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: bd2bc88b008ee18d342d81dfbe7ee3680e2564b266d2fadd0f6d6f65140098b2
4
- data.tar.gz: 59158c3d8919b6ae9df07ddefc6f21162b51218bf47b7c3267e81a52b25172b4
3
+ metadata.gz: bd5b738eff97b239ed278c2a96ce7b6e10383ca9401089648a9d390e2d29495f
4
+ data.tar.gz: 74831747ccf4bd3c901474d5ba082cac2297f801249fd5d02e8b923821d8c3b2
5
5
  SHA512:
6
- metadata.gz: 19e4a3f16c002720a058dbd172a63f14231f99cb9d70735080ad400267e3490813062a5cdfb3ea3c538df71a48008d10bf47efa2284503a9beb2ecd1ee4f7e35
7
- data.tar.gz: c3efe64996d506e89b364a9867c7b349111061ff58ad222b9a8814479b1842985ebf0f8bb72c89cf469327ac3e24985c25f84ebb7aee9ae1cbc05d08bf46a070
6
+ metadata.gz: 5a66826701b65f29051a6b1244201bc3201b5b333e9253f184c46fb0494110dafd15fe53a4b02081c6e7f58f3e373a30ad82b17b9deacf4d25c43d9373499de7
7
+ data.tar.gz: '096136afbb0dbe39d25960c73f9d1c16649614dd657b74d24fb9dc54ad5f025683640fbe283fa890e2d48d33e152ad3e55bea7426e7bb07361eee1742d4c13f7'
data/badges/coverage.json CHANGED
@@ -1 +1 @@
1
- {"schemaVersion": 1, "label": "coverage", "message": "96.15%", "color": "brightgreen"}
1
+ {"schemaVersion": 1, "label": "coverage", "message": "96.2%", "color": "brightgreen"}
data/changelog.md CHANGED
@@ -1,4 +1,26 @@
1
1
  ## [Released]
2
+ ## [2.3.2] - 2025-10-29
3
+ ### Fixed
4
+ - **Timeout Error Handling**: Improved handling of timeout errors to prevent crashes
5
+ - Added explicit rescue for `Net::ReadTimeout` and `Net::OpenTimeout` errors
6
+ - Previously, these errors could sometimes bypass Faraday's error handling and crash the application
7
+ - Now properly converts all timeout errors to `Errors::TimeoutError` with descriptive messages
8
+ - Fixes issue: "Request timed out: Net::ReadTimeout with #<TCPSocket:(closed)>"
9
+
10
+ ### Changed
11
+ - **Increased Default Timeouts**: Adjusted default timeout values for better reliability
12
+ - Default `timeout` increased from 10 to 30 seconds (general request timeout)
13
+ - Added separate `read_timeout` configuration (default: 30 seconds)
14
+ - `open_timeout` remains at 10 seconds (connection establishment)
15
+ - Users can still customize timeouts via configuration:
16
+ ```ruby
17
+ ZaiPayment.configure do |config|
18
+ config.timeout = 60 # Custom general timeout
19
+ config.read_timeout = 60 # Custom read timeout
20
+ config.open_timeout = 15 # Custom open timeout
21
+ end
22
+ ```
23
+
2
24
  ## [2.3.1] - 2025-10-28
3
25
  ### Fixed
4
26
  - **Token Refresh Bug**: Fixed authentication token not being refreshed after expiration
@@ -61,6 +61,8 @@ module ZaiPayment
61
61
  Response.new(response)
62
62
  rescue Faraday::Error => e
63
63
  handle_faraday_error(e)
64
+ rescue Net::ReadTimeout, Net::OpenTimeout => e
65
+ handle_net_timeout_error(e)
64
66
  end
65
67
 
66
68
  def connection
@@ -93,8 +95,13 @@ module ZaiPayment
93
95
  end
94
96
 
95
97
  def apply_timeouts(faraday)
96
- faraday.options.timeout = config.timeout if config.timeout
97
- faraday.options.open_timeout = config.open_timeout if config.open_timeout
98
+ set_timeout_option(faraday, :timeout, config.timeout)
99
+ set_timeout_option(faraday, :open_timeout, config.open_timeout)
100
+ set_timeout_option(faraday, :read_timeout, config.read_timeout)
101
+ end
102
+
103
+ def set_timeout_option(faraday, option, value)
104
+ faraday.options.public_send("#{option}=", value) if value
98
105
  end
99
106
 
100
107
  def base_url
@@ -120,5 +127,9 @@ module ZaiPayment
120
127
  raise Errors::ApiError, "Request failed: #{error.message}"
121
128
  end
122
129
  end
130
+
131
+ def handle_net_timeout_error(error)
132
+ raise Errors::TimeoutError, "Request timed out: #{error.class.name} with #{error.message}"
133
+ end
123
134
  end
124
135
  end
@@ -3,15 +3,16 @@
3
3
  module ZaiPayment
4
4
  class Config
5
5
  attr_accessor :environment, :client_id, :client_secret, :scope,
6
- :timeout, :open_timeout
6
+ :timeout, :open_timeout, :read_timeout
7
7
 
8
8
  def initialize
9
9
  @environment = :prelive # or :production
10
10
  @client_id = nil
11
11
  @client_secret = nil
12
12
  @scope = nil
13
- @timeout = 10
14
- @open_timeout = 10
13
+ @timeout = 30 # General timeout - increased from 10 to 30 seconds
14
+ @open_timeout = 10 # Connection open timeout
15
+ @read_timeout = 30 # Read timeout - new separate configuration
15
16
  end
16
17
 
17
18
  def validate!
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ZaiPayment
4
- VERSION = '2.3.1'
4
+ VERSION = '2.3.2'
5
5
  end
data/readme.md CHANGED
@@ -53,6 +53,11 @@ ZaiPayment.configure do |c|
53
53
  c.client_id = ENV.fetch("ZAI_CLIENT_ID")
54
54
  c.client_secret = ENV.fetch("ZAI_CLIENT_SECRET")
55
55
  c.scope = ENV.fetch("ZAI_OAUTH_SCOPE")
56
+
57
+ # Optional: Configure timeout settings (defaults shown)
58
+ c.timeout = 30 # General request timeout in seconds
59
+ c.open_timeout = 10 # Connection open timeout in seconds
60
+ c.read_timeout = 30 # Read timeout in seconds
56
61
  end
57
62
  ```
58
63
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zai_payment
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.1
4
+ version: 2.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eddy Jaga