gmo 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 0b7edafdd7655d6094971db8e84dcdadf7bd5125
4
+ data.tar.gz: 813cf2bad542ee8bc0f86b6ea87bcd0c14648841
5
+ SHA512:
6
+ metadata.gz: 82c2b085b33c3154c1454359af93d5d83ab2de536ffdcb1f1374ca120dec63df0ea9286d055d25acecffb5f539e016ceb9ac22ec7c9ac48e845b04c70517de18
7
+ data.tar.gz: 57e53b65d3dfad549c72d0a9e9f448b4fc626a0546bff8f9c9ec51f7a9392af9e2402a46af74089f14d0910f29f1345dba29e01b80bb8c988240a8a46d8e9aa8
@@ -5,8 +5,14 @@ rvm:
5
5
  - rbx-18mode
6
6
  - rbx-19mode
7
7
  - ruby-head
8
- - jruby-19mode
9
- - jruby-18mode
10
- - jruby-head
11
8
  - 1.8.7
12
9
  - 2.0.0
10
+ - jruby-18mode
11
+ - jruby-19mode
12
+ - jruby-head
13
+ matrix:
14
+ allow_failures:
15
+ - rvm: ruby-head
16
+ - rvm: jruby-18mode
17
+ - rvm: jruby-19mode
18
+ - rvm: jruby-head
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.3
4
+ * Added module GMO::JSON to blur the differences between the different MultiJson
5
+ * Added test for ShopAndSiteAPI#trade_card
6
+ * Fix typo and comment #4, #3 (Thanks @toshiwo, @fukayatsu)
7
+
3
8
  ## 0.2.2
4
9
  * Changed POST data encoding to Shift-JIS #2 (Thanks @keichan34)
5
10
 
@@ -0,0 +1,127 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://<HOST>/payment/EntryTran.idPass
6
+ body:
7
+ encoding: UTF-8
8
+ string: OrderID=1371958258&JobCd=AUTH&Amount=100&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>
9
+ headers:
10
+ Accept-Encoding:
11
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
12
+ Accept:
13
+ - '*/*'
14
+ User-Agent:
15
+ - Ruby
16
+ response:
17
+ status:
18
+ code: 200
19
+ message: OK
20
+ headers:
21
+ Date:
22
+ - Sun, 23 Jun 2013 03:30:58 GMT
23
+ Connection:
24
+ - close
25
+ Content-Type:
26
+ - text/plain;charset=Windows-31J
27
+ Transfer-Encoding:
28
+ - chunked
29
+ body:
30
+ encoding: UTF-8
31
+ string: AccessID=1da06187345d613ce206f4cd05bc5322&AccessPass=45a21e63323c3795d26e22338eaa6b7f
32
+ http_version:
33
+ recorded_at: Sun, 23 Jun 2013 03:30:59 GMT
34
+ - request:
35
+ method: post
36
+ uri: https://<HOST>/payment/ExecTran.idPass
37
+ body:
38
+ encoding: UTF-8
39
+ string: OrderID=1371958258&AccessID=1da06187345d613ce206f4cd05bc5322&AccessPass=45a21e63323c3795d26e22338eaa6b7f&Method=1&PayTimes=1&CardNo=4111111111111111&Expire=1405&ClientFieldFlag=0&DeviceCategory=0&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>
40
+ headers:
41
+ Accept-Encoding:
42
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
43
+ Accept:
44
+ - '*/*'
45
+ User-Agent:
46
+ - Ruby
47
+ response:
48
+ status:
49
+ code: 200
50
+ message: OK
51
+ headers:
52
+ Date:
53
+ - Sun, 23 Jun 2013 03:30:59 GMT
54
+ Connection:
55
+ - close
56
+ Content-Type:
57
+ - text/plain;charset=Windows-31J
58
+ Transfer-Encoding:
59
+ - chunked
60
+ body:
61
+ encoding: UTF-8
62
+ string: ACS=0&OrderID=1371958258&Forward=2a99662&Method=1&PayTimes=&Approve=7214787&TranID=1306231226111111111111199359&TranDate=20130623123059&CheckString=74f54b788565f291e65f67c606f90ca2
63
+ http_version:
64
+ recorded_at: Sun, 23 Jun 2013 03:30:59 GMT
65
+ - request:
66
+ method: post
67
+ uri: https://<HOST>/payment/SaveMember.idPass
68
+ body:
69
+ encoding: UTF-8
70
+ string: MemberID=1371958259&MemberName=John+Smith&SiteID=<SITE_ID>&SitePass=<SITE_PASS>
71
+ headers:
72
+ Accept-Encoding:
73
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
74
+ Accept:
75
+ - '*/*'
76
+ User-Agent:
77
+ - Ruby
78
+ response:
79
+ status:
80
+ code: 200
81
+ message: OK
82
+ headers:
83
+ Date:
84
+ - Sun, 23 Jun 2013 03:30:59 GMT
85
+ Connection:
86
+ - close
87
+ Content-Type:
88
+ - text/plain;charset=Windows-31J
89
+ Transfer-Encoding:
90
+ - chunked
91
+ body:
92
+ encoding: UTF-8
93
+ string: MemberID=1371958259
94
+ http_version:
95
+ recorded_at: Sun, 23 Jun 2013 03:30:59 GMT
96
+ - request:
97
+ method: post
98
+ uri: https://<HOST>/payment/TradedCard.idPass
99
+ body:
100
+ encoding: UTF-8
101
+ string: OrderID=1371958258&MemberID=1371958259&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>&SiteID=<SITE_ID>&SitePass=<SITE_PASS>
102
+ headers:
103
+ Accept-Encoding:
104
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
105
+ Accept:
106
+ - '*/*'
107
+ User-Agent:
108
+ - Ruby
109
+ response:
110
+ status:
111
+ code: 200
112
+ message: OK
113
+ headers:
114
+ Date:
115
+ - Sun, 23 Jun 2013 03:30:59 GMT
116
+ Connection:
117
+ - close
118
+ Content-Type:
119
+ - text/plain;charset=Windows-31J
120
+ Transfer-Encoding:
121
+ - chunked
122
+ body:
123
+ encoding: UTF-8
124
+ string: CardSeq=0&CardNo=************1111&Forward=2a99662
125
+ http_version:
126
+ recorded_at: Sun, 23 Jun 2013 03:31:00 GMT
127
+ recorded_with: VCR 2.4.0
data/lib/gmo.rb CHANGED
@@ -1,6 +1,5 @@
1
1
  require 'cgi'
2
2
  require 'rack/utils'
3
- require 'multi_json'
4
3
  require 'nkf'
5
4
 
6
5
  require "gmo/const"
@@ -64,7 +63,7 @@ module GMO
64
63
  # gmo.post_request("EntryTran.idPass", {:foo => "bar"})
65
64
  # POST /EntryTran.idPass with params foo=bar
66
65
  def post_request(name, args = {}, options = {})
67
- args = assciate_options_to_gmo_params args
66
+ args = associate_options_to_gmo_params args
68
67
  api_call(name, args, "post", options)
69
68
  end
70
69
  alias :post! :post_request
@@ -76,7 +75,7 @@ module GMO
76
75
  raise ArgumentError, "Required #{missing.join(', ')} were not provided." unless missing.empty?
77
76
  end
78
77
 
79
- def assciate_options_to_gmo_params(options)
78
+ def associate_options_to_gmo_params(options)
80
79
  Hash[options.map { |k, v| [GMO::Const::INPUT_PARAMS[k], v] }]
81
80
  end
82
81
 
@@ -1,3 +1,5 @@
1
+ require "gmo/json"
2
+
1
3
  module GMO
2
4
  class Response
3
5
 
@@ -49,7 +51,7 @@ module GMO
49
51
 
50
52
  def self.encode_params(param_hash)
51
53
  ((param_hash || {}).collect do |key_and_value|
52
- key_and_value[1] = MultiJson.dump(key_and_value[1]) if key_and_value[1].class != String
54
+ key_and_value[1] = GMO::JSON.dump(key_and_value[1]) if key_and_value[1].class != String
53
55
  # converting to Shift-JIS
54
56
  sjis_value = NKF.nkf('-s', key_and_value[1])
55
57
  "#{key_and_value[0].to_s}=#{CGI.escape sjis_value}"
@@ -0,0 +1,14 @@
1
+ require "multi_json"
2
+ module GMO
3
+ module JSON
4
+
5
+ def self.dump(message)
6
+ if MultiJson.respond_to?(:dump)
7
+ MultiJson.dump(message)
8
+ else
9
+ MultiJson.encode(message)
10
+ end
11
+ end
12
+
13
+ end
14
+ end
@@ -79,9 +79,8 @@ module GMO
79
79
  end
80
80
 
81
81
  ## 2.9.2.1.カード参照
82
- # お客様が選択したカード登録連番のカード情報を取得します。
83
- # カード情報が本人認証サービスに対応していない場合は、カード会社との通信を行い決済を実行します。その際の出力パラメータは「2.10.2.3決済実行」の出力パラメータと同じになります。
84
- # /payment/ExecTran.idPass
82
+ # 指定した会員のカード情報を参照します。
83
+ # /payment/SearchCard.idPass
85
84
  def search_card(options = {})
86
85
  name = "SearchCard.idPass"
87
86
  required = [:member_id, :card_seq, :seq_mode]
@@ -1,3 +1,3 @@
1
1
  module GMO
2
- VERSION = "0.2.2"
2
+ VERSION = "0.2.3"
3
3
  end
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+ describe "GMO::JSON" do
3
+
4
+ describe ".dump" do
5
+ it "should work" do
6
+ [
7
+ [
8
+ {:foo => {:bar => 'baz'}},
9
+ {'foo' => {'bar' => 'baz'}},
10
+ ],
11
+ [
12
+ [{:foo => {:bar => 'baz'}}],
13
+ [{'foo' => {'bar' => 'baz'}}],
14
+ ],
15
+ [
16
+ {:foo => [{:bar => 'baz'}]},
17
+ {'foo' => [{'bar' => 'baz'}]},
18
+ ],
19
+ [
20
+ {1 => {2 => {3 => 'bar'}}},
21
+ {'1' => {'2' => {'3' => 'bar'}}}
22
+ ]
23
+ ].each do |example, expected|
24
+ dumped_json = GMO::JSON.dump(example)
25
+ expect(MultiJson.load(dumped_json)).to eq expected
26
+ end
27
+ end
28
+ end
29
+
30
+ end
@@ -10,6 +10,16 @@ describe "GMO::Payment::ShopAndSiteAPI" do
10
10
  :site_pass => SPEC_CONF["site_pass"],
11
11
  :host => SPEC_CONF["host"]
12
12
  })
13
+ @shop_api ||= GMO::Payment::ShopAPI.new({
14
+ :shop_id => SPEC_CONF["shop_id"],
15
+ :shop_pass => SPEC_CONF["shop_pass"],
16
+ :host => SPEC_CONF["host"]
17
+ })
18
+ @site_api ||= GMO::Payment::SiteAPI.new({
19
+ :site_id => SPEC_CONF["site_id"],
20
+ :site_pass => SPEC_CONF["site_pass"],
21
+ :host => SPEC_CONF["host"]
22
+ })
13
23
  end
14
24
 
15
25
  it "should raise an ArgumentError if no options passed" do
@@ -40,6 +50,40 @@ describe "GMO::Payment::ShopAndSiteAPI" do
40
50
 
41
51
  describe "#trade_card" do
42
52
 
53
+ it "got data", :vcr do
54
+ order_id = generate_id
55
+ result = @shop_api.entry_tran({
56
+ :order_id => order_id,
57
+ :job_cd => "AUTH",
58
+ :amount => 100
59
+ })
60
+ access_id = result["AccessID"]
61
+ access_pass = result["AccessPass"]
62
+ card_no = "4111111111111111"
63
+ result = @shop_api.exec_tran({
64
+ :order_id => order_id,
65
+ :access_id => access_id,
66
+ :access_pass => access_pass,
67
+ :method => 1,
68
+ :pay_times => 1,
69
+ :card_no => card_no,
70
+ :expire => "1405"
71
+ })
72
+ member_id = generate_id
73
+ member_name = "John Smith"
74
+ result = @site_api.save_member({
75
+ :member_id => member_id,
76
+ :member_name => member_name
77
+ })
78
+ result = @service.trade_card({
79
+ :order_id => order_id,
80
+ :member_id => member_id
81
+ })
82
+ result["CardSeq"].nil?.should_not be_true
83
+ result["CardNo"].nil?.should_not be_true
84
+ result["Forward"].nil?.should_not be_true
85
+ end
86
+
43
87
  it "got error if missing options", :vcr do
44
88
  lambda {
45
89
  result = @service.trade_card()
@@ -5,7 +5,9 @@ rescue LoadError
5
5
  end
6
6
  # load the library
7
7
  require "simplecov"
8
- SimpleCov.start
8
+ SimpleCov.start :test_frameworks do
9
+ add_filter "/vendor/bundle/"
10
+ end
9
11
  require 'gmo'
10
12
  require 'rspec'
11
13
  require 'vcr'
@@ -13,6 +15,10 @@ require 'support/config_loader'
13
15
  require 'support/factory'
14
16
  require 'support/vcr'
15
17
 
18
+ if RUBY_VERSION < '1.9.0'
19
+ require 'support/encoding'
20
+ end
21
+
16
22
  RSpec.configure do |config|
17
23
  config.mock_with :rspec
18
24
  config.treat_symbols_as_metadata_keys_with_true_values = true
@@ -0,0 +1,33 @@
1
+ require 'kconv'
2
+
3
+ class String
4
+ @encoding = nil
5
+
6
+ def encoding
7
+ if @encoding != nil then
8
+ return @encoding
9
+ else
10
+ case Kconv.guess(self)
11
+ when Kconv::JIS
12
+ return "ISO-2022-JP"
13
+ when Kconv::SJIS
14
+ return "Shift_JIS"
15
+ when Kconv::EUC
16
+ return "EUC-JP"
17
+ when Kconv::ASCII
18
+ return "ASCII"
19
+ when Kconv::UTF8
20
+ return "UTF-8"
21
+ when Kconv::UTF16
22
+ return "UTF-16BE"
23
+ when Kconv::UNKNOWN
24
+ return nil
25
+ when Kconv::BINARY
26
+ return nil
27
+ else
28
+ return nil
29
+ end
30
+ end
31
+ end
32
+
33
+ end
metadata CHANGED
@@ -1,110 +1,97 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
5
- prerelease:
4
+ version: 0.2.3
6
5
  platform: ruby
7
6
  authors:
8
7
  - Tatsuo Kaniwa
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-04-19 00:00:00.000000000 Z
11
+ date: 2013-06-23 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rack
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: multi_json
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rspec
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rake
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - '>='
68
60
  - !ruby/object:Gem::Version
69
61
  version: '0'
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - '>='
76
67
  - !ruby/object:Gem::Version
77
68
  version: '0'
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: vcr
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - '>='
84
74
  - !ruby/object:Gem::Version
85
75
  version: '0'
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - '>='
92
81
  - !ruby/object:Gem::Version
93
82
  version: '0'
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: webmock
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - '>='
100
88
  - !ruby/object:Gem::Version
101
89
  version: '0'
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - '>='
108
95
  - !ruby/object:Gem::Version
109
96
  version: '0'
110
97
  description: Ruby client library for the GMO Payment Platform.
@@ -116,6 +103,7 @@ extra_rdoc_files:
116
103
  - README.md
117
104
  files:
118
105
  - .gitignore
106
+ - .travis.yml
119
107
  - CHANGELOG.md
120
108
  - Gemfile
121
109
  - LICENSE
@@ -140,6 +128,7 @@ files:
140
128
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_got_error_if_missing_options.yml
141
129
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_multi_gets_data_about_order.yml
142
130
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_multi_got_error_if_missing_options.yml
131
+ - fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_trade_card_got_data.yml
143
132
  - fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_trade_card_got_error_if_missing_options.yml
144
133
  - fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_delete_card_gets_data_about_a_card.yml
145
134
  - fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_delete_member_gets_data_about_a_member.yml
@@ -153,6 +142,7 @@ files:
153
142
  - lib/gmo/const.rb
154
143
  - lib/gmo/errors.rb
155
144
  - lib/gmo/http_services.rb
145
+ - lib/gmo/json.rb
156
146
  - lib/gmo/shop_and_site_api.rb
157
147
  - lib/gmo/shop_api.rb
158
148
  - lib/gmo/site_api.rb
@@ -160,6 +150,7 @@ files:
160
150
  - spec/gmo/api_spec.rb
161
151
  - spec/gmo/error_spec.rb
162
152
  - spec/gmo/http_service_spec.rb
153
+ - spec/gmo/json_spec.rb
163
154
  - spec/gmo/shop_and_site_api_spec.rb
164
155
  - spec/gmo/shop_api_spec.rb
165
156
  - spec/gmo/site_api_spec.rb
@@ -167,12 +158,13 @@ files:
167
158
  - spec/support/config.example.yml
168
159
  - spec/support/config.yml
169
160
  - spec/support/config_loader.rb
161
+ - spec/support/encoding.rb
170
162
  - spec/support/factory.rb
171
163
  - spec/support/vcr.rb
172
- - travis.yml
173
164
  homepage: https://github.com/t-k/gmo-payment-ruby
174
165
  licenses:
175
166
  - MIT
167
+ metadata: {}
176
168
  post_install_message:
177
169
  rdoc_options:
178
170
  - --line-numbers
@@ -182,28 +174,20 @@ rdoc_options:
182
174
  require_paths:
183
175
  - lib
184
176
  required_ruby_version: !ruby/object:Gem::Requirement
185
- none: false
186
177
  requirements:
187
- - - ! '>='
178
+ - - '>='
188
179
  - !ruby/object:Gem::Version
189
180
  version: '0'
190
- segments:
191
- - 0
192
- hash: -4347558908987678094
193
181
  required_rubygems_version: !ruby/object:Gem::Requirement
194
- none: false
195
182
  requirements:
196
- - - ! '>='
183
+ - - '>='
197
184
  - !ruby/object:Gem::Version
198
185
  version: '0'
199
- segments:
200
- - 0
201
- hash: -4347558908987678094
202
186
  requirements: []
203
187
  rubyforge_project:
204
- rubygems_version: 1.8.25
188
+ rubygems_version: 2.0.3
205
189
  signing_key:
206
- specification_version: 3
207
- summary: ! 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
190
+ specification_version: 4
191
+ summary: 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
208
192
  test_files: []
209
193
  has_rdoc: