gmo 0.2.1 → 0.2.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 0.2.2
4
+ * Changed POST data encoding to Shift-JIS #2 (Thanks @keichan34)
5
+
3
6
  ## 0.2.1
4
7
  * Fix handling of ClientField options on GMO::Payment::ShopAPI#exec_tran
5
8
 
@@ -3,9 +3,9 @@ GMO
3
3
  [![Gem Version](https://badge.fury.io/rb/gmo.png)](https://rubygems.org/gems/gmo)
4
4
  [![Build Status](https://travis-ci.org/t-k/gmo-payment-ruby.png)](https://travis-ci.org/t-k/gmo-payment-ruby)
5
5
 
6
- GMO is a Ruby client library for the GMO Payment Platform, supporting the PG Multi Payment API, exec transactions, register users, and so on.
6
+ RubyからGMOペイメント(PGマルチペイメントサービス)のAPIを扱うためのGemです。
7
7
 
8
- Installation
8
+ インストール方法
9
9
  ---
10
10
 
11
11
  Install GMO as a gem:
@@ -20,18 +20,12 @@ gem "gmo"
20
20
  ```
21
21
  and run bundle install to install the dependency.
22
22
 
23
- Overview
24
- ---
25
-
26
23
  TODO
27
24
  ---
28
25
  * add supported APIs
29
26
  * improve docs
30
27
 
31
- Issues
32
- ---
33
-
34
- Usage
28
+ 使い方
35
29
  ---
36
30
  ```ruby
37
31
  require 'gmo'
@@ -45,8 +39,8 @@ option = {
45
39
  }
46
40
  result = gmo.entry_tran(option)
47
41
  ```
48
- More documentation available <a href="https://github.com/t-k/gmo-payment-ruby/wiki/_pages">on the wiki</a>.
42
+ その他、詳細な使い方は<a href="https://github.com/t-k/gmo-payment-ruby/wiki/_pages">wiki</a>で説明しています。
49
43
 
50
- Authors and Contributors
44
+ Contributors
51
45
  ---
52
- * [Tatsuo Kaniwa](https://github.com/t-k) - Creator of the project
46
+ Patches contributed by [those people](https://github.com/t-k/gmo-payment-ruby/contributors).
data/README.md CHANGED
@@ -20,17 +20,11 @@ gem "gmo"
20
20
  ```
21
21
  and run bundle install to install the dependency.
22
22
 
23
- Overview
24
- ---
25
-
26
23
  TODO
27
24
  ---
28
25
  * add supported APIs
29
26
  * improve docs
30
27
 
31
- Issues
32
- ---
33
-
34
28
  Usage
35
29
  ---
36
30
  ```ruby
@@ -47,6 +41,6 @@ result = gmo.entry_tran(option)
47
41
  ```
48
42
  More documentation available <a href="https://github.com/t-k/gmo-payment-ruby/wiki/_pages">on the wiki</a>.
49
43
 
50
- Authors and Contributors
44
+ Contributors
51
45
  ---
52
- * [Tatsuo Kaniwa](https://github.com/t-k) - Creator of the project
46
+ Patches contributed by [those people](https://github.com/t-k/gmo-payment-ruby/contributors).
@@ -0,0 +1,71 @@
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=1366160239&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
+ - Wed, 17 Apr 2013 01:10:13 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=68334b323b78058c0ecbbaa996b80ca1&AccessPass=8499e4c83fbd277577f6ce2d95e86868
32
+ http_version:
33
+ recorded_at: Wed, 17 Apr 2013 00:57:19 GMT
34
+ - request:
35
+ method: post
36
+ uri: https://<HOST>/payment/ExecTran.idPass
37
+ body:
38
+ encoding: UTF-8
39
+ string: OrderID=1366160239&AccessID=68334b323b78058c0ecbbaa996b80ca1&AccessPass=8499e4c83fbd277577f6ce2d95e86868&Method=1&PayTimes=1&CardNo=4111111111111111&Expire=1405&ClientField1=%81%60%81%7C%81%91%81%92%81%CA%81%7C%81a%87%40%82%D9%82%B0%82%D9%82%B0hogehoge&ClientFieldFlag=1&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
+ - Wed, 17 Apr 2013 01:10:13 GMT
54
+ Connection:
55
+ - close
56
+ Content-Type:
57
+ - text/plain;charset=Windows-31J
58
+ Transfer-Encoding:
59
+ - chunked
60
+ body:
61
+ encoding: ASCII-8BIT
62
+ string: !binary |-
63
+ QUNTPTAmT3JkZXJJRD0xMzY2MTYwMjM5JkZvcndhcmQ9MmE5OTY2MiZNZXRo
64
+ b2Q9MSZQYXlUaW1lcz0mQXBwcm92ZT02NjgzMTg3JlRyYW5JRD0xMzA0MTcx
65
+ MDA3MTExMTExMTExMTExMTk2MjM4JlRyYW5EYXRlPTIwMTMwNDE3MTAxMDE0
66
+ JkNoZWNrU3RyaW5nPWRjODI2ZjFiMWJjNzFiZWRhMzgzNzRkNDRkMzdlMWQz
67
+ JkNsaWVudEZpZWxkMT2BYIF8gZGBkoHKgXyBYYdAgtmCsILZgrBob2dlaG9n
68
+ ZSZDbGllbnRGaWVsZDI9JkNsaWVudEZpZWxkMz0=
69
+ http_version:
70
+ recorded_at: Wed, 17 Apr 2013 00:57:20 GMT
71
+ recorded_with: VCR 2.4.0
data/lib/gmo.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  require 'cgi'
2
2
  require 'rack/utils'
3
3
  require 'multi_json'
4
+ require 'nkf'
4
5
 
5
6
  require "gmo/const"
6
7
  require 'gmo/errors'
@@ -40,7 +41,9 @@ module GMO
40
41
  raise GMO::Payment::ServerError.new(result.body, error_detail)
41
42
  end
42
43
  # Parse the body as Query string
43
- body = response = Rack::Utils.parse_nested_query(result.body.to_s)
44
+ response = Rack::Utils.parse_nested_query(result.body.to_s)
45
+ # converting to UTF-8
46
+ body = response = Hash[response.map { |k,v| [k, NKF.nkf('-w',v)] }]
44
47
  # Check for errors if provided a error_checking_block
45
48
  yield(body) if error_checking_block
46
49
  # Return result
@@ -50,7 +50,9 @@ module GMO
50
50
  def self.encode_params(param_hash)
51
51
  ((param_hash || {}).collect do |key_and_value|
52
52
  key_and_value[1] = MultiJson.dump(key_and_value[1]) if key_and_value[1].class != String
53
- "#{key_and_value[0].to_s}=#{CGI.escape key_and_value[1]}"
53
+ # converting to Shift-JIS
54
+ sjis_value = NKF.nkf('-s', key_and_value[1])
55
+ "#{key_and_value[0].to_s}=#{CGI.escape sjis_value}"
54
56
  end).join("&")
55
57
  end
56
58
 
@@ -1,3 +1,3 @@
1
1
  module GMO
2
- VERSION = "0.2.1"
2
+ VERSION = "0.2.2"
3
3
  end
@@ -111,6 +111,45 @@ describe "GMO::Payment::ShopAPI" do
111
111
  result = @service.exec_tran()
112
112
  }.should raise_error("Required access_id, access_pass, order_id, card_no, expire were not provided.")
113
113
  end
114
+
115
+ context "parameter contains Japanese characters" do
116
+ before { require "kconv" unless defined?(Kconv) }
117
+
118
+ it "should correctly handle Japanese", :vcr do
119
+ order_id = generate_id
120
+ client_field_1 = "〜−¢£¬−‖①ほげほげhogehoge"
121
+ result = @service.entry_tran({
122
+ :order_id => order_id,
123
+ :job_cd => "AUTH",
124
+ :amount => 100
125
+ })
126
+ access_id = result["AccessID"]
127
+ access_pass = result["AccessPass"]
128
+ result = @service.exec_tran({
129
+ :order_id => order_id,
130
+ :access_id => access_id,
131
+ :access_pass => access_pass,
132
+ :method => 1,
133
+ :pay_times => 1,
134
+ :card_no => "4111111111111111",
135
+ :expire => "1405",
136
+ :client_field_1 => client_field_1
137
+ })
138
+ result["ACS"].nil?.should_not be_true
139
+ result["OrderID"].nil?.should_not be_true
140
+ result["Forward"].nil?.should_not be_true
141
+ result["Method"].nil?.should_not be_true
142
+ result["PayTimes"].nil?.should_not be_true
143
+ result["Approve"].nil?.should_not be_true
144
+ result["TranID"].nil?.should_not be_true
145
+ result["TranDate"].nil?.should_not be_true
146
+ result["CheckString"].nil?.should_not be_true
147
+ result["ClientField1"].nil?.should_not be_true
148
+ (result["ClientField1"] == client_field_1).should be_true
149
+ (result["ClientField1"].encoding.to_s == "UTF-8").should be_true
150
+ result["ClientField3"].nil?.should_not be_true
151
+ end
152
+ end
114
153
  end
115
154
 
116
155
  describe "#exec_tran_cvs" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gmo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.2.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,14 +9,14 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-11 00:00:00.000000000 Z
12
+ date: 2013-04-19 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rack
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - '>='
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
21
  version: '0'
22
22
  type: :runtime
@@ -24,7 +24,7 @@ dependencies:
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - '>='
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
30
  - !ruby/object:Gem::Dependency
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - '>='
35
+ - - ! '>='
36
36
  - !ruby/object:Gem::Version
37
37
  version: '0'
38
38
  type: :runtime
@@ -40,7 +40,7 @@ dependencies:
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - '>='
43
+ - - ! '>='
44
44
  - !ruby/object:Gem::Version
45
45
  version: '0'
46
46
  - !ruby/object:Gem::Dependency
@@ -48,7 +48,7 @@ dependencies:
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
51
- - - '>='
51
+ - - ! '>='
52
52
  - !ruby/object:Gem::Version
53
53
  version: '0'
54
54
  type: :development
@@ -56,7 +56,7 @@ dependencies:
56
56
  version_requirements: !ruby/object:Gem::Requirement
57
57
  none: false
58
58
  requirements:
59
- - - '>='
59
+ - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
- - - '>='
67
+ - - ! '>='
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  type: :development
@@ -72,7 +72,7 @@ dependencies:
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
- - - '>='
75
+ - - ! '>='
76
76
  - !ruby/object:Gem::Version
77
77
  version: '0'
78
78
  - !ruby/object:Gem::Dependency
@@ -80,7 +80,7 @@ dependencies:
80
80
  requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
82
  requirements:
83
- - - '>='
83
+ - - ! '>='
84
84
  - !ruby/object:Gem::Version
85
85
  version: '0'
86
86
  type: :development
@@ -88,7 +88,7 @@ dependencies:
88
88
  version_requirements: !ruby/object:Gem::Requirement
89
89
  none: false
90
90
  requirements:
91
- - - '>='
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  - !ruby/object:Gem::Dependency
@@ -96,7 +96,7 @@ dependencies:
96
96
  requirement: !ruby/object:Gem::Requirement
97
97
  none: false
98
98
  requirements:
99
- - - '>='
99
+ - - ! '>='
100
100
  - !ruby/object:Gem::Version
101
101
  version: '0'
102
102
  type: :development
@@ -104,7 +104,7 @@ dependencies:
104
104
  version_requirements: !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
- - - '>='
107
+ - - ! '>='
108
108
  - !ruby/object:Gem::Version
109
109
  version: '0'
110
110
  description: Ruby client library for the GMO Payment Platform.
@@ -135,6 +135,7 @@ files:
135
135
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_cvs_gets_data_about_a_transaction.yml
136
136
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_gets_data_about_a_transaction.yml
137
137
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_got_error_if_missing_options.yml
138
+ - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_parameter_contains_Japanese_characters_should_correctly_handle_Japanese.yml
138
139
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_gets_data_about_order.yml
139
140
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_got_error_if_missing_options.yml
140
141
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_multi_gets_data_about_order.yml
@@ -183,26 +184,26 @@ require_paths:
183
184
  required_ruby_version: !ruby/object:Gem::Requirement
184
185
  none: false
185
186
  requirements:
186
- - - '>='
187
+ - - ! '>='
187
188
  - !ruby/object:Gem::Version
188
189
  version: '0'
189
190
  segments:
190
191
  - 0
191
- hash: 3518760350246848399
192
+ hash: -4347558908987678094
192
193
  required_rubygems_version: !ruby/object:Gem::Requirement
193
194
  none: false
194
195
  requirements:
195
- - - '>='
196
+ - - ! '>='
196
197
  - !ruby/object:Gem::Version
197
198
  version: '0'
198
199
  segments:
199
200
  - 0
200
- hash: 3518760350246848399
201
+ hash: -4347558908987678094
201
202
  requirements: []
202
203
  rubyforge_project:
203
204
  rubygems_version: 1.8.25
204
205
  signing_key:
205
206
  specification_version: 3
206
- summary: 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
207
+ summary: ! 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
207
208
  test_files: []
208
209
  has_rdoc: