cetustek 0.10.0 → 0.11.0

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: 90bc8844eac9b3eb305d59f5550be7bf6e552b0fffafe74b0e71e6afc31c55ef
4
- data.tar.gz: a9337fd9f37f80a3ec6532a319c4eac87ce1db79a475d7e237e3f2b59567a850
3
+ metadata.gz: c6a6aca36dc760878fe11e9107416c7296ef5fa7835d1e223f3cab8248970fb7
4
+ data.tar.gz: 96fb067d26a7cb40e0b429a8a9f502fa486bc5bc2efcded04bb136bcba4b99c1
5
5
  SHA512:
6
- metadata.gz: 57e5c7e15f119c182c8d0f38ef0c98ce40c682bc0262ed7043a09ed8c379a2603ae88d581bef8bcdc9e0f0a95cc5be85e6a6dc502f7c883bb7f6e74c9ebd8fa3
7
- data.tar.gz: c267be5d85ea54c917d932453a910bfcca464b4e5441ad4f2c98aec3e4b2f567712e65617e6250186ebd6164ec39f4157ad12014cfce6445847afe7c8db1b926
6
+ metadata.gz: 4cdf8f6a063bb979aecd5d974dd1482329582359831bf0cbb20f46c50987dbbb677e675dd3507c3bbd69883277103760900dc12b55c3650f3215b1e3ab3dc408
7
+ data.tar.gz: 6240dd9f19af70f835d4323a5fad194a77ef8be409f503013887095c1bd25ece1331507030443ae8a7ea571aa97c6a47eb6982e0142a2605f467afbd47977564
data/CHANGELOG.md CHANGED
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.11.0] - 2026-08-24
9
+
10
+ ### Added
11
+
12
+ - `config.transport` — `:httpi` (預設,維持現有行為) 或 `:faraday`。設成其他值
13
+ 在 `Cetustek.configure` 當下就 raise `ArgumentError`。
14
+
15
+ ### Fixed
16
+
17
+ - 沙盒端點 `invoice.cetustek.com.tw` 的 `certificate verify failed`:savon 預設
18
+ 的 HTTPI 首選 adapter 是 httpclient,而 httpclient 只認 gem 內附的
19
+ `cacert.pem`,裡面沒有該端點憑證鏈的根 Certum Trusted Root CA。只要 bundle
20
+ 裡有 httpclient,沙盒開票就會全數失敗。`config.transport = :faraday` 改走
21
+ Faraday 的 `net_http`,讀系統信任庫。production (`www.ei.com.tw`) 不受影響。
22
+ Faraday 路徑不能傳 `open_timeout`/`read_timeout`(savon 2.17 的
23
+ `FaradayMigrationHint::OPTIONS` 會 raise),改由 `client.faraday.options`
24
+ 設定,兩條路徑的 300 秒逾時一致。
25
+
8
26
  ## [0.10.0] - 2026-08-07
9
27
 
10
28
  延續 0.9.0 的 code review:統一驗證力度與查詢介面,讓四個查詢類別與
data/README.md CHANGED
@@ -50,9 +50,33 @@ Cetustek.configure do |config|
50
50
  # Only the order id, invoice number and result code are logged (never the
51
51
  # response body); the request XML is logged at debug level on failure.
52
52
  config.logger = Rails.logger
53
+
54
+ # Optional. :httpi (default, savon's own HTTP stack) or :faraday.
55
+ # See "SSL on the sandbox endpoint" below — if sandbox calls fail with
56
+ # `certificate verify failed`, set this to :faraday.
57
+ config.transport = :faraday
53
58
  end
54
59
  ```
55
60
 
61
+ ### SSL on the sandbox endpoint (`certificate verify failed`)
62
+
63
+ The sandbox endpoint `invoice.cetustek.com.tw` chains to **Certum Trusted Root
64
+ CA**. Savon's default HTTP stack is HTTPI, whose first-choice adapter is
65
+ `httpclient` — and `httpclient` ignores the system trust store, trusting only
66
+ the `cacert.pem` bundled inside the gem, which does not include that root. So
67
+ if anything in your bundle pulls in `httpclient` (plenty of gems do), every
68
+ sandbox call fails with:
69
+
70
+ ```
71
+ SSL_connect ... certificate verify failed (unable to get local issuer certificate)
72
+ ```
73
+
74
+ Production (`www.ei.com.tw`, Sectigo/USERTrust) is unaffected.
75
+
76
+ Fix it with `config.transport = :faraday`, which goes through Faraday's
77
+ `net_http` adapter and reads the system trust store. The 300s open/read
78
+ timeouts are applied either way.
79
+
56
80
  ## Usage
57
81
 
58
82
  ### Issue an Invoice
@@ -2,11 +2,26 @@
2
2
 
3
3
  module Cetustek
4
4
  class Configuration
5
+ # HTTPI (savon 的預設) 第一順位是 httpclient,而 httpclient 只認 gem 內附的
6
+ # cacert.pem,裡面沒有 Certum Trusted Root CA — 也就是 sandbox 端點
7
+ # invoice.cetustek.com.tw 憑證鏈的根。只要環境裡有 httpclient,沙盒開票就會
8
+ # 全數 certificate verify failed。改用 :faraday 走 net_http,讀系統信任庫。
9
+ TRANSPORTS = %i[httpi faraday].freeze
10
+
5
11
  # logger is opt-in: nil means this gem writes nothing anywhere.
6
12
  attr_accessor :environment, :site_id, :username, :password, :logger
13
+ attr_reader :transport
7
14
 
8
15
  def initialize
9
16
  @environment = :sandbox
17
+ @transport = :httpi
18
+ end
19
+
20
+ def transport=(value)
21
+ raise ArgumentError, "transport must be one of #{TRANSPORTS.join(', ')}, got #{value.inspect}" \
22
+ unless TRANSPORTS.include?(value)
23
+
24
+ @transport = value
10
25
  end
11
26
 
12
27
  def url
data/lib/cetustek/soap.rb CHANGED
@@ -6,8 +6,26 @@ module Cetustek
6
6
  # Shared SOAP plumbing: every operation hits the same WSDL and authenticates
7
7
  # with 網站代碼+APIPassword (source) and the 租賃者統編 (rentid).
8
8
  module Soap
9
+ TIMEOUT = 300
10
+
9
11
  def soap_client
10
- Savon.client(wsdl: Cetustek.config.url, open_timeout: 300, read_timeout: 300)
12
+ return httpi_client unless Cetustek.config.transport == :faraday
13
+
14
+ faraday_client
15
+ end
16
+
17
+ def httpi_client
18
+ Savon.client(wsdl: Cetustek.config.url, open_timeout: TIMEOUT, read_timeout: TIMEOUT)
19
+ end
20
+
21
+ # savon 2.17 的 FaradayMigrationHint::OPTIONS 會讓 open_timeout/read_timeout
22
+ # 在 transport: :faraday 下直接 raise,逾時改由 faraday 連線自己設。
23
+ def faraday_client
24
+ require 'faraday'
25
+ Savon.client(wsdl: Cetustek.config.url, transport: :faraday).tap do |client|
26
+ client.faraday.options.open_timeout = TIMEOUT
27
+ client.faraday.options.read_timeout = TIMEOUT
28
+ end
11
29
  end
12
30
 
13
31
  def source
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Cetustek
4
- VERSION = "0.10.0"
4
+ VERSION = "0.11.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cetustek
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zac