focas-client 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 437b2a6a29fd61f69fce24a4c4e4f64de74db25597c14167fd3c024390e03718
4
- data.tar.gz: 234ee05500b4d9a592abbb09e9ccade6c64acb34dc2484d3c8002a0020e37353
3
+ metadata.gz: b083e5b0da2910143a54d9374252cbad5a5fa17d3a9c3f617ac77c980ec42b7a
4
+ data.tar.gz: a1067fbb7afca792242235e6bfae1b8d8e1884650d931028499b27ce20e68754
5
5
  SHA512:
6
- metadata.gz: e080feab65aac91830754c283fdc952a7f2357763de5d39ac604dfcaffcdc7c6593d56c3affe25f0a1999ff38a4075e671577040c18d00016dee3a41d80963d4
7
- data.tar.gz: 93f76018b8144b04276f3cfcce33d463a4cd497e844b0eb2128199f66aef20a42319b899f27da5be108933f654f1c09d09091fbd07d69ec9b7792b58d71eea55
6
+ metadata.gz: d436deb7ebeabd939351d52e678105f89c167a764ceb1fee1090645208232280727b004f6a2e4c5df72b9e7a52280eb3c967e45ab76f3ae0dafead32cb16e0be
7
+ data.tar.gz: 319c8d978c1202c7c3bff17b743619c1a50e64980f7f454094938c9e0616f12eb9235c2dd2a866cd2a0c4478c211fbb11f6db3a24282f91ca86257c5862b2619
data/CHANGELOG.md CHANGED
@@ -1 +1 @@
1
- ## 0.1.0 (開發中)
1
+ ## 0.1.2 (開發中)
data/Gemfile.lock CHANGED
@@ -1,22 +1,22 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- focas-client (0.1.0)
4
+ focas-client (0.1.2)
5
5
  activesupport (>= 4.0)
6
6
 
7
7
  GEM
8
8
  remote: https://rubygems.org/
9
9
  specs:
10
- activesupport (7.0.4.2)
10
+ activesupport (7.0.4.3)
11
11
  concurrent-ruby (~> 1.0, >= 1.0.2)
12
12
  i18n (>= 1.6, < 2)
13
13
  minitest (>= 5.1)
14
14
  tzinfo (~> 2.0)
15
15
  concurrent-ruby (1.2.2)
16
16
  diff-lcs (1.5.0)
17
- i18n (1.12.0)
17
+ i18n (1.13.0)
18
18
  concurrent-ruby (~> 1.0)
19
- minitest (5.17.0)
19
+ minitest (5.18.0)
20
20
  rake (12.3.3)
21
21
  rspec (3.12.0)
22
22
  rspec-core (~> 3.12.0)
data/README.md CHANGED
@@ -29,27 +29,16 @@ $ rails generate focas:install
29
29
  設定 `config/initializers/focas.rb`:
30
30
 
31
31
  ```yml
32
- - config.production_mode # 0: 開發環境 / 1: 正式站,預設為 0
33
- - config.marchant_id # 商店 ID
34
- - config.hash_key
35
- - config.hash_iv
32
+ - config.production_mode # 0: 開發環境 / 1: 正式站,預設為 0
33
+ - config.mer_id = '' # 通常是統編
34
+ - config.marchant_id = '' # 商店 ID
35
+ - config.terminal_id = '' # 付費終端機 ID
36
+ - config.customize = 1 # 使用客製頁面1
37
+ - config.auto_cap = 1 # 自動請款
38
+ - config.encode_type = 'UTF-8' # 編碼一定要用 UTF-8,避免亂碼
39
+ - config.currency = 901 # 交易幣別,901 新台幣
36
40
  ```
37
41
 
38
- ## Usage
39
-
40
- TODO: Write usage instructions here
41
-
42
- ## Development
43
-
44
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
45
-
46
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
47
-
48
- ## Contributing
49
-
50
- Bug reports and pull requests are welcome on GitHub at https://github.com/pct/focas-client.
51
-
52
-
53
42
  ## License
54
43
 
55
44
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/lib/focas/config.rb CHANGED
@@ -65,7 +65,7 @@ module Focas
65
65
  enCodeType: 'encode_type', # *[必] 網頁編碼格式(預設為 BIG5),所以必傳 "UTF-8"
66
66
  timeoutDate: 'timeout_date', # 設定交易逾時日期(yyyymmdd),固定長度 8 位
67
67
  timeoutTime: 'timeout_time', # 設定交易逾時起始時間(HHMMSS),固定長度 6 位
68
- timeoutSecs: 'timeout_secs', # 設定交易逾時秒數,固定長度 3 位 (最大值為 600 秒)
68
+ timeoutSecs: 'timeout_secs', # 設定交易逾時秒數,固定長度 3 位 (最大值為 600 秒),先不設定,使用 600 會錯
69
69
  Currency: 'currency', # 交易幣別,固定長度 3 位 (901)
70
70
  lagSelect: 'lag_select', # 語言選擇,固定長度 1 位 (0: 繁 / 1: 簡 / 2: 英 / 3: 日 )
71
71
  threeDSAuthInd: 'three_ds_auth_ind', # 3D 交易驗證類型,若該特店設定支援 3D 交易,前端未帶此欄位,則預設為 0101 (0101 表示支付類交易驗證(PA)的 Payment transaction。 0204 表示非支付類交易驗證(NPA)的 Add card。0205 表示非支付類交易驗證(NPA)的 Maintain card。 註:綁卡驗證應使用 0204 或 0205)
data/lib/focas/payment.rb CHANGED
@@ -45,19 +45,11 @@ module Focas
45
45
  @response['Status'] == 'SUCCESS'
46
46
  end
47
47
 
48
- def gen_payment_params
49
- {
50
- merID: Config.options[:merID], # merID (統一編號)
51
- MerchantID: Config.options[:MerchantID], # 商店 ID
52
- TerminalID: Config.options[:TerminalID], # 終端機
53
- }
54
- end
55
-
56
48
  private
57
49
 
58
50
  def set_trade_info
59
51
  options = Config.options
60
- @trade_info = options.transform_keys(&:to_sym)
52
+ @trade_info = options.transform_keys(&:to_sym).to_h
61
53
 
62
54
  individual_trade_info = {
63
55
  lidm: @lidm, # 商店訂單編號,如:用途_日期時間戳記_流水號
@@ -67,7 +59,10 @@ module Focas
67
59
  AuthResURL: @auth_res_url,
68
60
  }
69
61
 
70
- @trade_info.merge!(individual_trade_info)
62
+ individual_trade_info.merge!(options[:trade_info]) if options[:trade_info]
63
+
64
+ # 同是 hash 再來 merge
65
+ @trade_info = (options.to_h.merge!(individual_trade_info)).transform_keys(&:to_sym)
71
66
  end
72
67
  end
73
68
  end
data/lib/focas/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Focas
4
- VERSION = '0.1.0'
4
+ VERSION = '0.1.2'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- focas.configure do |config|
3
+ Focas.configure do |config|
4
4
  # ========
5
5
  # 必要參數
6
6
  # ========
@@ -47,8 +47,8 @@ focas.configure do |config|
47
47
  # *[必] 網頁編碼格式(預設為 BIG5),所以必傳 "UTF-8"
48
48
  config.encode_type = 'UTF-8'
49
49
 
50
- # 設定交易逾時秒數,固定長度 3 位 (最大值為 600 秒)
51
- config.timeout_secs = 600
50
+ # 設定交易逾時秒數,固定長度 3 位 (最大值為 600 秒),先不設定,使用 600 會錯
51
+ #config.timeout_secs = 600
52
52
 
53
53
  # 交易幣別,固定長度 3 位 (901)
54
54
  config.currency = 901
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: focas-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Lin (pct)
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-28 00:00:00.000000000 Z
11
+ date: 2023-05-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport