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 +4 -4
- data/badges/coverage.json +1 -1
- data/changelog.md +22 -0
- data/lib/zai_payment/client.rb +13 -2
- data/lib/zai_payment/config.rb +4 -3
- data/lib/zai_payment/version.rb +1 -1
- data/readme.md +5 -0
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: bd5b738eff97b239ed278c2a96ce7b6e10383ca9401089648a9d390e2d29495f
|
|
4
|
+
data.tar.gz: 74831747ccf4bd3c901474d5ba082cac2297f801249fd5d02e8b923821d8c3b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5a66826701b65f29051a6b1244201bc3201b5b333e9253f184c46fb0494110dafd15fe53a4b02081c6e7f58f3e373a30ad82b17b9deacf4d25c43d9373499de7
|
|
7
|
+
data.tar.gz: '096136afbb0dbe39d25960c73f9d1c16649614dd657b74d24fb9dc54ad5f025683640fbe283fa890e2d48d33e152ad3e55bea7426e7bb07361eee1742d4c13f7'
|
data/badges/coverage.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"schemaVersion": 1, "label": "coverage", "message": "96.
|
|
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
|
data/lib/zai_payment/client.rb
CHANGED
|
@@ -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
|
|
97
|
-
faraday
|
|
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
|
data/lib/zai_payment/config.rb
CHANGED
|
@@ -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!
|
data/lib/zai_payment/version.rb
CHANGED
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
|
|