gmo 0.1.0 → 0.2.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.
data/.gitignore CHANGED
@@ -5,4 +5,6 @@ Gemfile.lock
5
5
  *.rbc
6
6
  *~
7
7
  .yardoc/
8
- .DS_Store
8
+ /coverage
9
+
10
+ .DS_Store
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ # CHANGELOG
2
+
3
+ ## 0.2.0
4
+
5
+ * Use https scheme for rubygems source
6
+ * Add support for required fields validation
7
+ * Adds pay-by-Konbini support (Thanks @keichan34)
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
- source :rubygems
1
+ source 'https://rubygems.org/'
2
2
 
3
3
  group :development do
4
4
  gem "yard"
data/README.ja.md CHANGED
@@ -25,8 +25,7 @@ Overview
25
25
 
26
26
  TODO
27
27
  ---
28
- * add tests
29
- * set production server
28
+ * add supported APIs
30
29
  * improve docs
31
30
 
32
31
  Issues
@@ -37,7 +36,7 @@ Usage
37
36
  ```ruby
38
37
  require 'gmo'
39
38
  # setup
40
- gmo = GMO::Payment::ShopAPI.new({:shop_id => "SHOP_ID", :shop_pass => "SHOP_PASS"})
39
+ gmo = GMO::Payment::ShopAPI.new({:shop_id => "SHOP_ID", :shop_pass => "SHOP_PASS", :host => "foo.mul-pay.jp"})
41
40
  #
42
41
  option = {
43
42
  :order_id => 1,
@@ -46,6 +45,7 @@ option = {
46
45
  }
47
46
  result = gmo.entry_tran(option)
48
47
  ```
48
+ More documentation available <a href="https://github.com/t-k/gmo-payment-ruby/wiki/_pages">on the wiki</a>.
49
49
 
50
50
  Authors and Contributors
51
51
  ---
data/README.md CHANGED
@@ -25,8 +25,7 @@ Overview
25
25
 
26
26
  TODO
27
27
  ---
28
- * add tests
29
- * set production server
28
+ * add supported APIs
30
29
  * improve docs
31
30
 
32
31
  Issues
@@ -37,7 +36,7 @@ Usage
37
36
  ```ruby
38
37
  require 'gmo'
39
38
  # setup
40
- gmo = GMO::Payment::ShopAPI.new({:shop_id => "SHOP_ID", :shop_pass => "SHOP_PASS"})
39
+ gmo = GMO::Payment::ShopAPI.new({:shop_id => "SHOP_ID", :shop_pass => "SHOP_PASS", :host => "foo.mul-pay.jp"})
41
40
  #
42
41
  option = {
43
42
  :order_id => 1,
@@ -46,6 +45,7 @@ option = {
46
45
  }
47
46
  result = gmo.entry_tran(option)
48
47
  ```
48
+ More documentation available <a href="https://github.com/t-k/gmo-payment-ruby/wiki/_pages">on the wiki</a>.
49
49
 
50
50
  Authors and Contributors
51
51
  ---
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://<HOST>/payment/EntryTranCvs.idPass
6
+ body:
7
+ encoding: UTF-8
8
+ string: OrderID=1362106772&Amount=100&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Fri, 01 Mar 2013 02:59:32 GMT
21
+ Connection:
22
+ - close
23
+ Content-Type:
24
+ - text/plain;charset=Windows-31J
25
+ Transfer-Encoding:
26
+ - chunked
27
+ body:
28
+ encoding: US-ASCII
29
+ string: AccessID=3618be802c7ac572414274731e50cb6c&AccessPass=4099664bd4b110800e09805539d1d7b5
30
+ http_version:
31
+ recorded_at: Fri, 01 Mar 2013 02:59:33 GMT
32
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,32 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://<HOST>/payment/EntryTranCvs.idPass
6
+ body:
7
+ encoding: UTF-8
8
+ string: OrderID=null&JobCd=null&Amount=null&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>
9
+ headers:
10
+ Accept:
11
+ - ! '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Fri, 01 Mar 2013 02:59:33 GMT
21
+ Connection:
22
+ - close
23
+ Content-Type:
24
+ - text/plain;charset=Windows-31J
25
+ Transfer-Encoding:
26
+ - chunked
27
+ body:
28
+ encoding: US-ASCII
29
+ string: ErrCode=E01|E01&ErrInfo=E01050002|E01060006
30
+ http_version:
31
+ recorded_at: Fri, 01 Mar 2013 02:59:33 GMT
32
+ recorded_with: VCR 2.4.0
@@ -0,0 +1,63 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://<HOST>/payment/EntryTranCvs.idPass
6
+ body:
7
+ encoding: UTF-8
8
+ string: OrderID=1362106772&Amount=100&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>
9
+ headers:
10
+ Accept:
11
+ - '*/*'
12
+ User-Agent:
13
+ - Ruby
14
+ response:
15
+ status:
16
+ code: 200
17
+ message: OK
18
+ headers:
19
+ Date:
20
+ - Fri, 01 Mar 2013 02:59:32 GMT
21
+ Connection:
22
+ - close
23
+ Content-Type:
24
+ - text/plain;charset=Windows-31J
25
+ Transfer-Encoding:
26
+ - chunked
27
+ body:
28
+ encoding: US-ASCII
29
+ string: AccessID=3618be802c7ac572414274731e50cb6c&AccessPass=4099664bd4b110800e09805539d1d7b5
30
+ http_version:
31
+ recorded_at: Fri, 01 Mar 2013 02:59:33 GMT
32
+ - request:
33
+ method: post
34
+ uri: https://<HOST>/payment/ExecTranCvs.idPass
35
+ body:
36
+ encoding: UTF-8
37
+ string: OrderID=1365660033&AccessID=3618be802c7ac572414274731e50cb6c&AccessPass=4099664bd4b110800e09805539d1d7b5&Convenience=00001&CustomerName=%E3%82%B3%E3%83%B3%E3%83%93%E3%83%8B%E5%A4%AA%E9%83%8E&CustomerKana=%E3%82%B3%E3%83%B3%E3%83%93%E3%83%8B%E3%82%BF%E3%83%AD%E3%82%A6&TelNo=0300000001&ReceiptsDisp11=RSpec+Helpdesk&ReceiptsDisp12=RSpec+hotline&ReceiptsDisp13=00%3A00-00%3A15&ClientField1=client_field1&ShopID=<SHOP_ID>&ShopPass=<SHOP_PASS>
38
+ headers:
39
+ Accept-Encoding:
40
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
41
+ Accept:
42
+ - '*/*'
43
+ User-Agent:
44
+ - Ruby
45
+ response:
46
+ status:
47
+ code: 200
48
+ message: OK
49
+ headers:
50
+ Date:
51
+ - Thu, 11 Apr 2013 06:00:33 GMT
52
+ Connection:
53
+ - close
54
+ Content-Type:
55
+ - text/plain;charset=Windows-31J
56
+ Transfer-Encoding:
57
+ - chunked
58
+ body:
59
+ encoding: US-ASCII
60
+ string: OrderID=1365660033&Convenience=00001&ConfNo=conf-123123123&ReceiptNo=receipt-123123&PaymentTerm=21000101000001&TranDate=20130301120312&ClientField1=client_field1&CheckString=md5&ClientField2=null&ClientField3=null
61
+ http_version:
62
+ recorded_at: Thu, 11 Apr 2013 06:00:33 GMT
63
+ recorded_with: VCR 2.4.0
data/lib/gmo.rb CHANGED
@@ -2,6 +2,7 @@ require 'cgi'
2
2
  require 'rack/utils'
3
3
  require 'multi_json'
4
4
 
5
+ require "gmo/const"
5
6
  require 'gmo/errors'
6
7
  require 'gmo/http_services'
7
8
  require 'gmo/shop_api'
@@ -60,12 +61,22 @@ module GMO
60
61
  # gmo.post_request("EntryTran.idPass", {:foo => "bar"})
61
62
  # POST /EntryTran.idPass with params foo=bar
62
63
  def post_request(name, args = {}, options = {})
64
+ args = assciate_options_to_gmo_params args
63
65
  api_call(name, args, "post", options)
64
66
  end
65
67
  alias :post! :post_request
66
68
 
67
69
  private
68
70
 
71
+ def assert_required_options(required, options)
72
+ missing = required.select { |param| options[param].nil? }
73
+ raise ArgumentError, "Required #{missing.join(', ')} were not provided." unless missing.empty?
74
+ end
75
+
76
+ def assciate_options_to_gmo_params(options)
77
+ Hash[options.map { |k, v| [GMO::Const::INPUT_PARAMS[k], v] }]
78
+ end
79
+
69
80
  def api_call(*args)
70
81
  raise "Called abstract method: api_call"
71
82
  end
data/lib/gmo/const.rb ADDED
@@ -0,0 +1,107 @@
1
+ module GMO
2
+ module Const
3
+ INPUT_PARAMS = {
4
+ :access_id => "AccessID",
5
+ :access_pass => "AccessPass",
6
+ :address_1 => "Address1",
7
+ :address_2 => "Address2",
8
+ :address_3 => "Address3",
9
+ :address_4 => "Address4",
10
+ :address_5 => "Address5",
11
+ :address_6 => "Address6",
12
+ :amount => "Amount",
13
+ :cancel_amount => "CancelAmount",
14
+ :cancel_tax => "CancelTax",
15
+ :card_name => "CardName",
16
+ :card_no => "CardNo",
17
+ :card_pass => "CardPass",
18
+ :card_seq => "CardSeq",
19
+ :client_field_1 => "ClientField1",
20
+ :client_field_2 => "ClientField2",
21
+ :client_field_3 => "ClientField3",
22
+ :client_field_flg => "ClientFieldFlag",
23
+ :commodity => "Commodity",
24
+ :confirm_base_date => "ConfirmBaseDate",
25
+ :continuance_month => "ContinuanceMonth",
26
+ :convenience => "Convenience",
27
+ :create_member => "CreateMember",
28
+ :currency => "Currency",
29
+ :customer_kana => "CustomerKana",
30
+ :customer_name => "CustomerName",
31
+ :default_flag => "DefaultFlag",
32
+ :device_category => "DeviceCategory",
33
+ :docomo_disp_1 => "DocomoDisp1",
34
+ :docomo_disp_2 => "DocomoDisp2",
35
+ :eddy_add_info_1 => "EdyAddInfo1",
36
+ :eddy_add_info_2 => "EdyAddInfo2",
37
+ :expire => "Expire",
38
+ :first_month_free_flag => "FirstMonthFreeFlag",
39
+ :holder_name => "HolderName",
40
+ :http_accept => "HttpAccept",
41
+ :http_user_agent => "HttpUserAgent",
42
+ :http_ua => "HttpUserAgent",
43
+ :inquiry_data => "InquiryData",
44
+ :inquiry_id => "InquiryID",
45
+ :item_code => "ItemCode",
46
+ :item_name => "ItemName",
47
+ :job_cd => "JobCd",
48
+ :last_month_free_flag => "LastMonthFreeFlag",
49
+ :locale => "Locale",
50
+ :md => "MD",
51
+ :mail_address => "MailAddress",
52
+ :member_id => "MemberID",
53
+ :member_name => "MemberName",
54
+ :member_no => "MemberNo",
55
+ :method => "Method",
56
+ :order_id => "OrderID",
57
+ :pin => "PIN",
58
+ :pa_res => "PaRes",
59
+ :pay_times => "PayTimes",
60
+ :pay_type => "PayType",
61
+ :payment_term_day => "PaymentTermDay",
62
+ :payment_term_sec => "PaymentTermSec",
63
+ :receipts_disp_1 => "ReceiptsDisp1",
64
+ :receipts_disp_2 => "ReceiptsDisp2",
65
+ :receipts_disp_3 => "ReceiptsDisp3",
66
+ :receipts_disp_4 => "ReceiptsDisp4",
67
+ :receipts_disp_5 => "ReceiptsDisp5",
68
+ :receipts_disp_6 => "ReceiptsDisp6",
69
+ :receipts_disp_7 => "ReceiptsDisp7",
70
+ :receipts_disp_8 => "ReceiptsDisp8",
71
+ :receipts_disp_9 => "ReceiptsDisp9",
72
+ :receipts_disp_10 => "ReceiptsDisp10",
73
+ :receipts_disp_11 => "ReceiptsDisp11",
74
+ :receipts_disp_12 => "ReceiptsDisp12",
75
+ :receipts_disp_13 => "ReceiptsDisp13",
76
+ :redirect_url => "RedirectURL",
77
+ :register_disp_1 => "RegisterDisp1",
78
+ :register_disp_2 => "RegisterDisp2",
79
+ :register_disp_3 => "RegisterDisp3",
80
+ :register_disp_4 => "RegisterDisp4",
81
+ :register_disp_5 => "RegisterDisp5",
82
+ :register_disp_6 => "RegisterDisp6",
83
+ :register_disp_7 => "RegisterDisp7",
84
+ :register_disp_8 => "RegisterDisp8",
85
+ :reserve_no => "ReserveNo",
86
+ :ret_url => "RetURL",
87
+ :security_code => "SecurityCode",
88
+ :seq_mode => "SeqMode",
89
+ :service_name => "ServiceName",
90
+ :service_tel => "ServiceTel",
91
+ :shop_id => "ShopID",
92
+ :shop_mail_address => "ShopMailAddress",
93
+ :shop_pass => "ShopPass",
94
+ :site_id => "SiteID",
95
+ :site_pass => "SitePass",
96
+ :suica_add_info_1 => "SuicaAddInfo1",
97
+ :suica_add_info_2 => "SuicaAddInfo2",
98
+ :suica_add_info_3 => "SuicaAddInfo3",
99
+ :suica_add_info_4 => "SuicaAddInfo4",
100
+ :tax => "Tax",
101
+ :td_flag => "TdFlag",
102
+ :td_tenant_name => "TdTenantName",
103
+ :tel_no => "TelNo",
104
+ :token => "Token"
105
+ }
106
+ end
107
+ end
@@ -23,15 +23,9 @@ module GMO
23
23
  # Forward
24
24
  def trade_card(options = {})
25
25
  name = "TradedCard.idPass"
26
- args = {
27
- "OrderID" => options[:order_id],
28
- "MemberID" => options[:member_id],
29
- "SeqMode" => options[:seq_mode] || "0",
30
- "DefaultFlag" => options[:default_flag] || "0",
31
- "HolderName" => options[:holder_name]
32
- }
33
- args.delete("HolderName") if options[:holder_name].nil?
34
- post_request name, args
26
+ required = [:order_id, :member_id]
27
+ assert_required_options(required, options)
28
+ post_request name, options
35
29
  end
36
30
 
37
31
  private
data/lib/gmo/shop_api.rb CHANGED
@@ -44,12 +44,21 @@ module GMO
44
44
  # {"AccessID"=>"a41d83f1f4c908baeda04e6dc03e300c", "AccessPass"=>"d72eca02e28c88f98b9341a33ba46d5d"}
45
45
  def entry_tran(options = {})
46
46
  name = "EntryTran.idPass"
47
- args = {
48
- "OrderID" => options[:order_id],
49
- "JobCd" => options[:job_cd],
50
- "Amount" => options[:amount]
51
- }
52
- post_request name, args
47
+ required = [:order_id, :job_cd]
48
+ required << :amount if options[:job_cd] && options[:job_cd] != "CHECK"
49
+ assert_required_options(required, options)
50
+ post_request name, options
51
+ end
52
+
53
+
54
+ # 【コンビニ払い】
55
+ # 2.1.2.1. 取引登録
56
+ # これ以降の決済取引で必要となる取引IDと取引パスワードの発行を行い、取引を開始します。
57
+ def entry_tran_cvs(options = {})
58
+ name = "EntryTranCvs.idPass"
59
+ required = [:order_id, :amount]
60
+ assert_required_options(required, options)
61
+ post_request name, options
53
62
  end
54
63
 
55
64
  ## 2.2.2.2.決済実行
@@ -94,27 +103,41 @@ module GMO
94
103
  def exec_tran(options = {})
95
104
  name = "ExecTran.idPass"
96
105
  if options[:client_field1] || options[:client_field2] || options[:client_field3]
97
- client_field_flg = "1"
106
+ options[:client_field_flg] = "1"
98
107
  else
99
- client_field_flg = "0"
108
+ options[:client_field_flg] = "0"
100
109
  end
101
- args = {
102
- "AccessID" => options[:access_id],
103
- "AccessPass" => options[:access_pass],
104
- "OrderID" => options[:order_id],
105
- "Method" => options[:method],
106
- "PayTimes" => options[:pay_times],
107
- "CardNo" => options[:card_no],
108
- "Expire" => options[:expire],
109
- "HttpAccept" => options[:http_accept],
110
- "HttpUserAgent" => options[:http_ua],
111
- "DeviceCategory" => "0",
112
- "ClientField1" => options[:client_field1],
113
- "ClientField2" => options[:client_field2],
114
- "ClientField3" => options[:client_field3],
115
- "ClientFieldFlag" => client_field_flg
116
- }
117
- post_request name, args
110
+ options[:device_category] = "0"
111
+
112
+ # args = {
113
+ # "AccessID" => options[:access_id],
114
+ # "AccessPass" => options[:access_pass],
115
+ # "OrderID" => options[:order_id],
116
+ # "Method" => options[:method],
117
+ # "PayTimes" => options[:pay_times],
118
+ # "CardNo" => options[:card_no],
119
+ # "Expire" => options[:expire],
120
+ # "HttpAccept" => options[:http_accept],
121
+ # "HttpUserAgent" => options[:http_ua],
122
+ # "DeviceCategory" => "0",
123
+ # "ClientField1" => options[:client_field1],
124
+ # "ClientField2" => options[:client_field2],
125
+ # "ClientField3" => options[:client_field3],
126
+ # "ClientFieldFlag" => client_field_flg
127
+ # }
128
+ required = [:access_id, :access_pass, :order_id, :card_no, :expire]
129
+ assert_required_options(required, options)
130
+ post_request name, options
131
+ end
132
+
133
+ # 【コンビニ払い】
134
+ # 2.1.2.2. 決済実行
135
+ # お客様が入力した情報で後続の決済センターと通信を行い決済を実施し、結果を返します。
136
+ def exec_tran_cvs(options = {})
137
+ name = "ExecTranCvs.idPass"
138
+ required = [:access_id, :access_pass, :order_id, :convenience, :customer_name, :tel_no, :receipts_disp_11, :receipts_disp_12, :receipts_disp_13]
139
+ assert_required_options(required, options)
140
+ post_request name, options
118
141
  end
119
142
 
120
143
  ## 2.14.2.1.決済変更
@@ -143,13 +166,9 @@ module GMO
143
166
  # {"AccessID"=>"381d84ae4e6fc37597482573a9569f10", "AccessPass"=>"cc0093ca8758c6616fa0ab9bf6a43e8d", "Forward"=>"2a99662", "Approve"=>"6284199", "TranID"=>"1302140555111111111111193536", "TranDate"=>"20130215110651"}
144
167
  def alter_tran(options = {})
145
168
  name = "AlterTran.idPass"
146
- args = {
147
- "AccessID" => options[:access_id],
148
- "AccessPass" => options[:access_pass],
149
- "JobCd" => options[:job_cd] || "SALES",
150
- "Amount" => options[:amount]
151
- }
152
- post_request name, args
169
+ required = [:access_id, :access_pass, :job_cd]
170
+ assert_required_options(required, options)
171
+ post_request name, options
153
172
  end
154
173
 
155
174
  ## 2.15.2.1.金額変更
@@ -170,34 +189,27 @@ module GMO
170
189
  # })
171
190
  def change_tran(options = {})
172
191
  name = "ChangeTran.idPass"
173
- args = {
174
- "AccessID" => options[:access_id],
175
- "AccessPass" => options[:access_pass],
176
- "JobCd" => options[:job_cd],
177
- "Amount" => options[:amount]
178
- }
179
- post_request name, args
192
+ required = [:access_id, :access_pass, :job_cd, :amount]
193
+ assert_required_options(required, options)
194
+ post_request name, options
180
195
  end
181
196
 
182
197
  ## 2.16.2.1.取引状態参照
183
198
  # 指定したオーダーID の取引情報を取得します。
184
199
  def search_trade(options = {})
185
200
  name = "SearchTrade.idPass"
186
- args = {
187
- "OrderID" => options[:order_id]
188
- }
189
- post_request name, args
201
+ required = [:order_id]
202
+ assert_required_options(required, options)
203
+ post_request name, options
190
204
  end
191
205
 
192
206
  # 13.1.2.1.取引状態参照
193
207
  # 指定したオーダーIDの取引情報を取得します。
194
208
  def search_trade_multi(options = {})
195
209
  name = "SearchTradeMulti.idPass"
196
- args = {
197
- "OrderID" => options[:order_id],
198
- "PayType" => options[:pay_type]
199
- }
200
- post_request name, args
210
+ required = [:order_id, :pay_type]
211
+ assert_required_options(required, options)
212
+ post_request name, options
201
213
  end
202
214
 
203
215
  private
@@ -215,4 +227,4 @@ module GMO
215
227
  end
216
228
 
217
229
  end
218
- end
230
+ end
data/lib/gmo/site_api.rb CHANGED
@@ -28,67 +28,54 @@ module GMO
28
28
  # 指定されたサイトに会員を登録します。
29
29
  def save_member(options = {})
30
30
  name = "SaveMember.idPass"
31
- args = {
32
- "MemberID" => options[:member_id],
33
- "MemberName" => options[:member_name]
34
- }
35
- post_request name, args
31
+ required = [:member_id]
32
+ assert_required_options(required, options)
33
+ post_request name, options
36
34
  end
37
35
 
38
36
  ## 2.4.2.1.会員更新
39
37
  # 指定されたサイトに会員情報を更新します。
40
38
  def update_member(options = {})
41
39
  name = "UpdateMember.idPass"
42
- args = {
43
- "MemberID" => options[:member_id],
44
- "MemberName" => options[:member_name]
45
- }
46
- post_request name, args
40
+ required = [:member_id]
41
+ assert_required_options(required, options)
42
+ post_request name, options
47
43
  end
48
44
 
49
45
  ## 2.5.2.1.会員削除
50
46
  # 指定したサイトから会員情報を削除します。
51
47
  def delete_member(options = {})
52
48
  name = "DeleteMember.idPass"
53
- args = {
54
- "MemberID" => options[:member_id]
55
- }
56
- post_request name, args
49
+ required = [:member_id]
50
+ assert_required_options(required, options)
51
+ post_request name, options
57
52
  end
58
53
 
59
54
  ## 2.6.2.1.会員参照
60
55
  # 指定したサイトの会員情報を参照します。
61
56
  def search_member(options = {})
62
57
  name = "SearchMember.idPass"
63
- args = {
64
- "MemberID" => options[:member_id]
65
- }
66
- post_request name, args
58
+ required = [:member_id]
59
+ assert_required_options(required, options)
60
+ post_request name, options
67
61
  end
68
62
 
69
63
  ## 2.7.2.1.カード登録/更新
70
64
  # 指定した会員にカード情報を登録します。尚、サイトに設定されたショップ ID を使用してカード会社と通信を行い有効性の確認を行います。
71
65
  def save_card(options = {})
72
66
  name = "SaveCard.idPass"
73
- args = {
74
- "MemberID" => options[:member_id],
75
- "CardSeq" => options[:card_seq],
76
- "CardNo" => options[:card_no],
77
- "Expire" => options[:expire]
78
- }
79
- args.delete("CardSeq") if options[:card_seq].nil?
80
- post_request name, args
67
+ required = [:member_id, :card_no, :expire]
68
+ assert_required_options(required, options)
69
+ post_request name, options
81
70
  end
82
71
 
83
72
  ## 2.8.2.1.カード削除
84
73
  # 指定した会員のカード情報を削除します。
85
74
  def delete_card(options = {})
86
75
  name = "DeleteCard.idPass"
87
- args = {
88
- "MemberID" => options[:member_id],
89
- "CardSeq" => options[:card_seq]
90
- }
91
- post_request name, args
76
+ required = [:member_id, :card_seq]
77
+ assert_required_options(required, options)
78
+ post_request name, options
92
79
  end
93
80
 
94
81
  ## 2.9.2.1.カード参照
@@ -97,12 +84,9 @@ module GMO
97
84
  # /payment/ExecTran.idPass
98
85
  def search_card(options = {})
99
86
  name = "SearchCard.idPass"
100
- args = {
101
- "MemberID" => options[:member_id],
102
- "CardSeq" => options[:card_seq],
103
- "SeqMode" => options[:seq_mode]
104
- }
105
- post_request name, args
87
+ required = [:member_id, :card_seq, :seq_mode]
88
+ assert_required_options(required, options)
89
+ post_request name, options
106
90
  end
107
91
 
108
92
  ## 2.11.2.3. 決済実行
@@ -111,21 +95,9 @@ module GMO
111
95
  # /payment/ExecTran.idPass
112
96
  def exec_tran(options = {})
113
97
  name = "ExecTran.idPass"
114
- args = {
115
- "AccessID" => options[:access_id],
116
- "AccessPass" => options[:access_pass],
117
- "OrderID" => options[:order_id],
118
- "JobCd" => "SALES",
119
- "Method" => options[:method],
120
- "PayTimes" => options[:pay_times],
121
- "MemberID" => options[:member_id],
122
- "CardSeq" => options[:card_seq],
123
- "Amount" => options[:amount],
124
- "HttpAccept" => options[:http_accept],
125
- "HttpUserAgent" => options[:http_ua],
126
- "DeviceCategory" => "0"
127
- }
128
- post_request name, args
98
+ required = [:access_id, :access_pass, :order_id, :member_id, :card_seq]
99
+ assert_required_options(required, options)
100
+ post_request name, options
129
101
  end
130
102
 
131
103
  private
data/lib/gmo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module GMO
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,3 +1,5 @@
1
+ # Encoding: UTF-8
2
+
1
3
  require "spec_helper"
2
4
 
3
5
  describe "GMO::Payment::ShopAPI" do
@@ -47,7 +49,25 @@ describe "GMO::Payment::ShopAPI" do
47
49
  it "got error if missing options", :vcr do
48
50
  lambda {
49
51
  result = @service.entry_tran()
50
- }.should raise_error
52
+ }.should raise_error("Required order_id, job_cd were not provided.")
53
+ end
54
+ end
55
+
56
+ describe "#entry_tran_cvs" do
57
+ it "gets data about a transaction", :vcr do
58
+ order_id = @order_id
59
+ result = @service.entry_tran_cvs({
60
+ :order_id => order_id,
61
+ :amount => 100
62
+ })
63
+ result["AccessID"].nil?.should_not be_true
64
+ result["AccessPass"].nil?.should_not be_true
65
+ end
66
+
67
+ it "got error if missing options", :vcr do
68
+ lambda {
69
+ result = @service.entry_tran_cvs()
70
+ }.should raise_error("Required order_id, amount were not provided.")
51
71
  end
52
72
  end
53
73
 
@@ -89,7 +109,49 @@ describe "GMO::Payment::ShopAPI" do
89
109
  it "got error if missing options", :vcr do
90
110
  lambda {
91
111
  result = @service.exec_tran()
92
- }.should raise_error
112
+ }.should raise_error("Required access_id, access_pass, order_id, card_no, expire were not provided.")
113
+ end
114
+ end
115
+
116
+ describe "#exec_tran_cvs" do
117
+ it "gets data about a transaction", :vcr do
118
+ order_id = generate_id
119
+ client_field1 = "client_field1"
120
+ result = @service.entry_tran_cvs({
121
+ :order_id => order_id,
122
+ :amount => 100
123
+ })
124
+ access_id = result["AccessID"]
125
+ access_pass = result["AccessPass"]
126
+ result = @service.exec_tran_cvs({
127
+ :order_id => order_id,
128
+ :access_id => access_id,
129
+ :access_pass => access_pass,
130
+ :convenience => '00001',
131
+ :customer_name => 'コンビニ太郎',
132
+ :customer_kana => 'コンビニタロウ',
133
+ :tel_no => '0300000001',
134
+ :receipts_disp_11 => 'RSpec Helpdesk',
135
+ :receipts_disp_12 => 'RSpec hotline',
136
+ :receipts_disp_13 => '00:00-00:15',
137
+ :client_field_1 => client_field1
138
+ })
139
+ result["OrderID"].nil?.should_not be_true
140
+ result["Convenience"].nil?.should_not be_true
141
+ result["ConfNo"].nil?.should_not be_true
142
+ result["ReceiptNo"].nil?.should_not be_true
143
+ result["PaymentTerm"].nil?.should_not be_true
144
+ result["TranDate"].nil?.should_not be_true
145
+ result["CheckString"].nil?.should_not be_true
146
+ result["ClientField1"].nil?.should_not be_true
147
+ (result["ClientField1"] == client_field1).should be_true
148
+ result["ClientField3"].nil?.should_not be_true
149
+ end
150
+
151
+ it "got error if missing options", :vcr do
152
+ lambda {
153
+ result = @service.exec_tran_cvs()
154
+ }.should raise_error("Required access_id, access_pass, order_id, convenience, customer_name, tel_no, receipts_disp_11, receipts_disp_12, receipts_disp_13 were not provided.")
93
155
  end
94
156
  end
95
157
 
@@ -163,7 +225,7 @@ describe "GMO::Payment::ShopAPI" do
163
225
  it "got error if missing options", :vcr do
164
226
  lambda {
165
227
  result = @service.alter_tran()
166
- }.should raise_error
228
+ }.should raise_error("Required access_id, access_pass, job_cd were not provided.")
167
229
  end
168
230
  end
169
231
 
@@ -202,8 +264,8 @@ describe "GMO::Payment::ShopAPI" do
202
264
 
203
265
  it "got error if missing options", :vcr do
204
266
  lambda {
205
- result = @service.search_trade_multi()
206
- }.should raise_error
267
+ result = @service.change_tran()
268
+ }.should raise_error("Required access_id, access_pass, job_cd, amount were not provided.")
207
269
  end
208
270
  end
209
271
 
@@ -236,8 +298,8 @@ describe "GMO::Payment::ShopAPI" do
236
298
 
237
299
  it "got error if missing options", :vcr do
238
300
  lambda {
239
- result = @service.search_trade_multi()
240
- }.should raise_error
301
+ result = @service.search_trade()
302
+ }.should raise_error("Required order_id were not provided.")
241
303
  end
242
304
  end
243
305
 
@@ -272,8 +334,8 @@ describe "GMO::Payment::ShopAPI" do
272
334
  it "got error if missing options", :vcr do
273
335
  lambda {
274
336
  result = @service.search_trade_multi()
275
- }.should raise_error
337
+ }.should raise_error("Required order_id, pay_type were not provided.")
276
338
  end
277
339
  end
278
340
 
279
- end
341
+ end
@@ -41,6 +41,12 @@ describe "GMO::Payment::SiteAPI" do
41
41
  })
42
42
  result["MemberID"].nil?.should_not be_true
43
43
  end
44
+
45
+ it "got error if missing options", :vcr do
46
+ lambda {
47
+ result = @service.save_member()
48
+ }.should raise_error("Required member_id were not provided.")
49
+ end
44
50
  end
45
51
 
46
52
  describe "#update_member" do
@@ -53,6 +59,12 @@ describe "GMO::Payment::SiteAPI" do
53
59
  })
54
60
  result["MemberID"].nil?.should_not be_true
55
61
  end
62
+
63
+ it "got error if missing options", :vcr do
64
+ lambda {
65
+ result = @service.update_member()
66
+ }.should raise_error("Required member_id were not provided.")
67
+ end
56
68
  end
57
69
 
58
70
  describe "#delete_member" do
@@ -68,6 +80,12 @@ describe "GMO::Payment::SiteAPI" do
68
80
  })
69
81
  result["MemberID"].nil?.should_not be_true
70
82
  end
83
+
84
+ it "got error if missing options", :vcr do
85
+ lambda {
86
+ result = @service.delete_member()
87
+ }.should raise_error("Required member_id were not provided.")
88
+ end
71
89
  end
72
90
 
73
91
  describe "#search_member" do
@@ -89,6 +107,12 @@ describe "GMO::Payment::SiteAPI" do
89
107
  result["DeleteFlag"].nil?.should_not be_true
90
108
  (result["DeleteFlag"].to_i == 0).should be_true
91
109
  end
110
+
111
+ it "got error if missing options", :vcr do
112
+ lambda {
113
+ result = @service.search_member()
114
+ }.should raise_error("Required member_id were not provided.")
115
+ end
92
116
  end
93
117
 
94
118
  describe "#save_card" do
@@ -103,6 +127,12 @@ describe "GMO::Payment::SiteAPI" do
103
127
  })
104
128
  result["CardNo"].nil?.should_not be_true
105
129
  end
130
+
131
+ it "got error if missing options", :vcr do
132
+ lambda {
133
+ result = @service.save_card()
134
+ }.should raise_error("Required member_id, card_no, expire were not provided.")
135
+ end
106
136
  end
107
137
 
108
138
  describe "#delete_card" do
@@ -116,6 +146,12 @@ describe "GMO::Payment::SiteAPI" do
116
146
  result["CardSeq"].nil?.should_not be_true
117
147
  (result["CardSeq"].to_i == card_seq).should be_true
118
148
  end
149
+
150
+ it "got error if missing options", :vcr do
151
+ lambda {
152
+ result = @service.delete_card()
153
+ }.should raise_error("Required member_id, card_seq were not provided.")
154
+ end
119
155
  end
120
156
 
121
157
  describe "#search_card" do
@@ -146,6 +182,12 @@ describe "GMO::Payment::SiteAPI" do
146
182
  result["HolderName"].nil?.should_not be_true
147
183
  result["DeleteFlag"].nil?.should_not be_true
148
184
  end
185
+
186
+ it "got error if missing options", :vcr do
187
+ lambda {
188
+ result = @service.search_card()
189
+ }.should raise_error("Required member_id, card_seq, seq_mode were not provided.")
190
+ end
149
191
  end
150
192
 
151
193
  end
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.1.0
4
+ version: 0.2.0
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-03-01 00:00:00.000000000 Z
12
+ date: 2013-04-11 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.
@@ -116,6 +116,7 @@ extra_rdoc_files:
116
116
  - README.md
117
117
  files:
118
118
  - .gitignore
119
+ - CHANGELOG.md
119
120
  - Gemfile
120
121
  - LICENSE
121
122
  - README.ja.md
@@ -127,8 +128,11 @@ files:
127
128
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_alter_tran_got_error_if_missing_options.yml
128
129
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_gets_data_about_order.yml
129
130
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_got_error_if_missing_options.yml
131
+ - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_cvs_gets_data_about_a_transaction.yml
132
+ - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_cvs_got_error_if_missing_options.yml
130
133
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_gets_data_about_a_transaction.yml
131
134
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_got_error_if_missing_options.yml
135
+ - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_cvs_gets_data_about_a_transaction.yml
132
136
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_gets_data_about_a_transaction.yml
133
137
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_got_error_if_missing_options.yml
134
138
  - fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_search_trade_gets_data_about_order.yml
@@ -145,6 +149,7 @@ files:
145
149
  - fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_update_member_gets_data_about_a_transaction.yml
146
150
  - gmo.gemspec
147
151
  - lib/gmo.rb
152
+ - lib/gmo/const.rb
148
153
  - lib/gmo/errors.rb
149
154
  - lib/gmo/http_services.rb
150
155
  - lib/gmo/shop_and_site_api.rb
@@ -177,26 +182,26 @@ require_paths:
177
182
  required_ruby_version: !ruby/object:Gem::Requirement
178
183
  none: false
179
184
  requirements:
180
- - - ! '>='
185
+ - - '>='
181
186
  - !ruby/object:Gem::Version
182
187
  version: '0'
183
188
  segments:
184
189
  - 0
185
- hash: 3453064578904451494
190
+ hash: -4076184411211171372
186
191
  required_rubygems_version: !ruby/object:Gem::Requirement
187
192
  none: false
188
193
  requirements:
189
- - - ! '>='
194
+ - - '>='
190
195
  - !ruby/object:Gem::Version
191
196
  version: '0'
192
197
  segments:
193
198
  - 0
194
- hash: 3453064578904451494
199
+ hash: -4076184411211171372
195
200
  requirements: []
196
201
  rubyforge_project:
197
202
  rubygems_version: 1.8.25
198
203
  signing_key:
199
204
  specification_version: 3
200
- summary: ! 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
205
+ summary: 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
201
206
  test_files: []
202
207
  has_rdoc: