gmo 0.3.0 → 0.4.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.
Files changed (44) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +20 -1
  3. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_deposit_gets_data_about_a_deposit.yml +38 -0
  4. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  5. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_account_gets_data_about_an_account.yml +38 -0
  6. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_deposit_gets_data_about_a_deposit.yml +38 -0
  7. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  8. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_delete_account_gets_data_about_an_account.yml +38 -0
  9. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_account_gets_data_about_an_account.yml +38 -0
  10. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_balance_gets_data_about_balance.yml +38 -0
  11. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_deposit_gets_data_about_a_deposit.yml +38 -0
  12. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  13. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_update_account_gets_data_about_an_account.yml +38 -0
  14. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_brandtoken_gets_data_about_order.yml +108 -0
  15. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_brandtoken_gets_data_about_a_transaction.yml +38 -0
  16. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_gets_data_about_a_transaction.yml +73 -0
  17. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_parameter_contains_Japanese_characters_should_correctly_handle_Japanese.yml +73 -0
  18. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_doesn_t_require_card_info_if_token_is_present.yml +69 -0
  19. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_refund_tran_brandtoken_gets_data_about_a_transaction.yml +108 -0
  20. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_sales_tran_brandtoken_gets_data_about_a_transaction.yml +143 -0
  21. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_void_tran_brandtoken_gets_data_about_order.yml +108 -0
  22. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_exec_tran_brandtoken_got_data.yml +73 -0
  23. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_trade_brandtoken_got_data.yml +108 -0
  24. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_delete_brandtoken_gets_data_about_a_brandtoken.yml +73 -0
  25. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_brandtoken_gets_data_about_a_brandtoken.yml +74 -0
  26. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_card_detail_by_member_id_gets_data_about_card_detail.yml +36 -0
  27. data/lib/gmo.rb +6 -1
  28. data/lib/gmo/const.rb +1159 -1
  29. data/lib/gmo/errors.rb +20 -2
  30. data/lib/gmo/remittance_api.rb +329 -0
  31. data/lib/gmo/shop_and_site_api.rb +73 -0
  32. data/lib/gmo/shop_api.rb +223 -2
  33. data/lib/gmo/site_api.rb +64 -0
  34. data/lib/gmo/version.rb +1 -1
  35. data/spec/gmo/{error_spec.rb → errors_spec.rb} +11 -2
  36. data/spec/gmo/remittance_api_spec.rb +504 -0
  37. data/spec/gmo/shop_and_site_api_spec.rb +74 -0
  38. data/spec/gmo/shop_api_spec.rb +278 -0
  39. data/spec/gmo/site_api_spec.rb +84 -1
  40. data/spec/support/config.example.yml +5 -0
  41. data/spec/support/config.yml +5 -0
  42. data/spec/support/config_loader.rb +1 -1
  43. data/spec/support/vcr.rb +9 -2
  44. metadata +30 -4
@@ -50,7 +50,6 @@ module GMO
50
50
  post_request name, options
51
51
  end
52
52
 
53
-
54
53
  # 【コンビニ払い】
55
54
  # 2.1.2.1. 取引登録
56
55
  # これ以降の決済取引で必要となる取引IDと取引パスワードの発行を行い、取引を開始します。
@@ -81,6 +80,31 @@ module GMO
81
80
  post_request name, options
82
81
  end
83
82
 
83
+ ### @params ###
84
+ # OrderID
85
+ # JobCd
86
+ # Amount
87
+ # ItemCode
88
+ # Tax
89
+ ### @return ###
90
+ # AccessID
91
+ # AccessPass
92
+ ### example ###
93
+ # gmo.entry_tran_brandtoken({
94
+ # order_id: "ord12345",
95
+ # job_cd: "AUTH",
96
+ # item_code: "1000001",
97
+ # tax: "0001001",
98
+ # amount: 100
99
+ # })
100
+ # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744"}
101
+ def entry_tran_brandtoken(options = {})
102
+ name = "EntryTranBrandtoken.idPass"
103
+ required = [:order_id, :job_cd, :amount]
104
+ assert_required_options(required, options)
105
+ post_request name, options
106
+ end
107
+
84
108
  ## 2.2.2.2.決済実行
85
109
  # 指定されたサイトに会員を登録します。
86
110
  # return
@@ -145,7 +169,11 @@ module GMO
145
169
  # "ClientField3" => options[:client_field_3],
146
170
  # "ClientFieldFlag" => client_field_flg
147
171
  # }
148
- required = [:access_id, :access_pass, :order_id, :card_no, :expire]
172
+ if options[:token].nil?
173
+ required = [:access_id, :access_pass, :order_id, :card_no, :expire]
174
+ else
175
+ required = [:access_id, :access_pass, :token]
176
+ end
149
177
  assert_required_options(required, options)
150
178
  post_request name, options
151
179
  end
@@ -179,6 +207,50 @@ module GMO
179
207
  post_request name, options
180
208
  end
181
209
 
210
+ ### @params ###
211
+ # AccessID
212
+ # AccessPass
213
+ # OrderID
214
+ # TokenType
215
+ # Token
216
+ # MemberID
217
+ # SeqMode
218
+ # TokenSeq
219
+ # ClientField1
220
+ # ClientField2
221
+ # ClientField3
222
+ ### @return ###
223
+ # Status
224
+ # OrderID
225
+ # Forward
226
+ # Approve
227
+ # TranID
228
+ # TranDate
229
+ # ClientField1
230
+ # ClientField2
231
+ # ClientField3
232
+ ### example ###
233
+ # gmo.exec_tran_brandtoken({
234
+ # order_id: "597ae8c36120b23a3c00014e",
235
+ # access_id: "139f8ec33a07c55f406937c52ce4473d",
236
+ # access_pass: "2689b204d2c17192fa35f9269fa7e744",
237
+ # token_type: :apple_pay,
238
+ # token: <Base64 encoded payment data>,
239
+ # seq_mode: "1",
240
+ # token_seq: 1001,
241
+ # client_field_1: "Custom field value 1",
242
+ # client_field_2: "Custom field value 2",
243
+ # client_field_3: "Custom field value 3"
244
+ # })
245
+ # => {"Status"=>"CAPTURE", "OrderID"=>"597ae8c36120b23a3c00014e", "Forward"=>"2a99663", "Approve"=>"5487394", "TranID"=>"1707281634111111111111771216", "TranDate"=>"20170728163453", "ClientField1"=>"Custom field value 1", "ClientField2"=>"Custom field value 2", "ClientField3"=>"Custom field value 3"}
246
+ def exec_tran_brandtoken(options = {})
247
+ name = "ExecTranBrandtoken.idPass"
248
+ options[:token_type] = GMO::Const::TOKEN_TYPES_MAP[options[:token_type]]
249
+ required = [:access_id, :access_pass, :order_id]
250
+ assert_required_options(required, options)
251
+ post_request name, options
252
+ end
253
+
182
254
  ## 2.14.2.1.決済変更
183
255
  # 仮売上の決済に対して実売上を行います。尚、実行時に仮売上時との金額チェックを行います。
184
256
  # /payment/AlterTran.idPass
@@ -233,6 +305,123 @@ module GMO
233
305
  post_request name, options
234
306
  end
235
307
 
308
+ ### @params ###
309
+ # AccessID
310
+ # AccessPass
311
+ # OrderID
312
+ # JobCd
313
+ # Amount
314
+ # Tax
315
+ ### @return ###
316
+ # AccessID
317
+ # AccessPass
318
+ # Status
319
+ # Forward
320
+ # Approve
321
+ # TranID
322
+ # TranDate
323
+ ### example ###
324
+ # gmo.change_tran_brandtoken({
325
+ # access_id: "21170701482c86c3b88ff72b83bfd363",
326
+ # access_pass: "51f36feba120de1e6e29532e5a3a5e3e",
327
+ # order_id: "ord10001",
328
+ # job_cd: "CAPTURE",
329
+ # amount: 2000
330
+ # })
331
+ # => {"AccessID"=>"21170701482c86c3b88ff72b83bfd363", "AccessPass"=>"51f36feba120de1e6e29532e5a3a5e3e", "Status"=>"CAPTURE", "Forward"=>"2a99663", "Approve"=>"5538477", "TranID"=>"1707311633111111111111771224", "TranDate"=>"20170731163343"}
332
+ def change_tran_brandtoken(options = {})
333
+ name = "ChangeTranBrandtoken.idPass"
334
+ required = [:access_id, :access_pass, :order_id, :job_cd, :amount]
335
+ assert_required_options(required, options)
336
+ post_request name, options
337
+ end
338
+
339
+ ### @params ###
340
+ # AccessID
341
+ # AccessPass
342
+ # OrderID
343
+ ### @return ###
344
+ # AccessID
345
+ # AccessPass
346
+ # Status
347
+ # Forward
348
+ # Approve
349
+ # TranID
350
+ # TranDate
351
+ ### example ###
352
+ # gmo.void_tran_brandtoken({
353
+ # access_id: "139f8ec33a07c55f406937c52ce4473d",
354
+ # access_pass: "2689b204d2c17192fa35f9269fa7e744",
355
+ # order_id: "597ae8c36120b23a3c00014e"
356
+ # })
357
+ # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744", "Status"=>"VOID", "Forward"=>"2a99663", "Approve"=>"5537590", "TranID"=>"1707311610111111111111771219", "TranDate"=>"20170731161007"}
358
+ def void_tran_brandtoken(options = {})
359
+ name = "VoidTranBrandtoken.idPass"
360
+ required = [:access_id, :access_pass, :order_id]
361
+ assert_required_options(required, options)
362
+ post_request name, options
363
+ end
364
+
365
+ ### @params ###
366
+ # AccessID
367
+ # AccessPass
368
+ # OrderID
369
+ # Amount
370
+ # Tax
371
+ ### @return ###
372
+ # AccessID
373
+ # AccessPass
374
+ # Status
375
+ # Forward
376
+ # Approve
377
+ # TranID
378
+ # TranDate
379
+ ### example ###
380
+ # gmo.sales_tran_brandtoken({
381
+ # access_id: "139f8ec33a07c55f406937c52ce4473d",
382
+ # access_pass: "2689b204d2c17192fa35f9269fa7e744",
383
+ # order_id: "597ae8c36120b23a3c00014e",
384
+ # amount: 1000,
385
+ # tax: "0001001"
386
+ # })
387
+ # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744", "Status"=>"SALES", "Forward"=>"2a99663", "Approve"=>"5537883", "TranID"=>"1707311620111111111111771220", "TranDate"=>"20170731162256"}
388
+ def sales_tran_brandtoken(options = {})
389
+ name = "SalesTranBrandtoken.idPass"
390
+ required = [:access_id, :access_pass, :order_id, :amount]
391
+ assert_required_options(required, options)
392
+ post_request name, options
393
+ end
394
+
395
+ ### @params ###
396
+ # AccessID
397
+ # AccessPass
398
+ # OrderID
399
+ # Amount
400
+ # Tax
401
+ ### @return ###
402
+ # AccessID
403
+ # AccessPass
404
+ # Status
405
+ # Forward
406
+ # Approve
407
+ # TranID
408
+ # TranDate
409
+ ### example ###
410
+ # gmo.refund_tran_brandtoken({
411
+ # access_id: "139f8ec33a07c55f406937c52ce4473d",
412
+ # access_pass: "2689b204d2c17192fa35f9269fa7e744",
413
+ # order_id: "597ae8c36120b23a3c00014e",
414
+ # amount: 1000,
415
+ # tax: "0001001"
416
+ # })
417
+ # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744", "Status"=>"RETURN", "Forward"=>"2a99663", "Approve"=>"5537883", "TranID"=>"1707311620111111111111771220", "TranDate"=>"20170731162256"}
418
+ def refund_tran_brandtoken(options = {})
419
+ name = "RefundTranBrandtoken.idPass"
420
+ required = [:access_id, :access_pass, :order_id, :amount]
421
+ assert_required_options(required, options)
422
+ post_request name, options
423
+ end
424
+
236
425
  ## 2.16.2.1.取引状態参照
237
426
  # 指定したオーダーID の取引情報を取得します。
238
427
  def search_trade(options = {})
@@ -244,6 +433,38 @@ module GMO
244
433
 
245
434
  # 13.1.2.1.取引状態参照
246
435
  # 指定したオーダーIDの取引情報を取得します。
436
+ ### @params ###
437
+ # OrderID
438
+ # PayType
439
+ ### @return ###
440
+ # OrderID
441
+ # Status
442
+ # ProcessDate
443
+ # JobCd
444
+ # AccessID
445
+ # AccessPass
446
+ # ItemCode
447
+ # Amount
448
+ # Tax
449
+ # SiteID
450
+ # MemberID
451
+ # CardNoToken
452
+ # Expire
453
+ # Method
454
+ # PayTimes
455
+ # Forward
456
+ # TranID
457
+ # Approve
458
+ # ClientField1
459
+ # ClientField2
460
+ # ClientField3
461
+ # PayType
462
+ ### example ###
463
+ # gmo.search_trade_multi({
464
+ # order_id: '598066176120b2235300020b',
465
+ # pay_type: 27
466
+ # })
467
+ # => {"OrderID"=>"598066176120b2235300020b", "Status"=>"CAPTURE", "ProcessDate"=>"20170801202929", "JobCd"=>"CAPTURE", "AccessID"=>"228fc5bc02da46943300c12706d325a2", "AccessPass"=>"090a50ec2f77d92184a18018f07906e5", "ItemCode"=>"0000990", "Amount"=>"557", "Tax"=>"0", "SiteID"=>"", "MemberID"=>"", "CardNoToken"=>"************1111", "Expire"=>"2212", "Method"=>"1", "PayTimes"=>"", "Forward"=>"2a99663", "TranID"=>"1708012029111111111111771228", "Approve"=>"5689128", "ClientField1"=>"", "ClientField2"=>"", "ClientField3"=>"", "PayType"=>"27"}
247
468
  def search_trade_multi(options = {})
248
469
  name = "SearchTradeMulti.idPass"
249
470
  required = [:order_id, :pay_type]
@@ -26,6 +26,15 @@ module GMO
26
26
 
27
27
  ## 2.3.2.1.会員登録
28
28
  # 指定されたサイトに会員を登録します。
29
+ ### @params ###
30
+ # MemberID
31
+ ### @return ###
32
+ # MemberID
33
+ ### example ###
34
+ # gmo.save_member({
35
+ # member_id: 'mem10001'
36
+ # })
37
+ # => {"MemberID"=>"mem10001"}
29
38
  def save_member(options = {})
30
39
  name = "SaveMember.idPass"
31
40
  required = [:member_id]
@@ -92,6 +101,51 @@ module GMO
92
101
  post_request name, options
93
102
  end
94
103
 
104
+ ### @params ###
105
+ # MemberID
106
+ # SeqMode
107
+ # TokenSeq
108
+ ### @return ###
109
+ # TokenSeq
110
+ # DefaultFlag
111
+ # CardName
112
+ # CardNoToken
113
+ # Expire
114
+ # HolderName
115
+ # DeleteFlag
116
+ ### example ###
117
+ # gmo.search_brandtoken({
118
+ # member_id: '598066176120b2235300020b',
119
+ # seq_mode: 0
120
+ # })
121
+ # => {"TokenSeq"=>"0", "DefaultFlag"=>"0", "CardName"=>"", "CardNoToken"=>"*************111", "Expire"=>"2212", "HolderName"=>"", "DeleteFlag"=>"0"}
122
+ def search_brandtoken(options = {})
123
+ name = "SearchBrandtoken.idPass"
124
+ required = [:member_id, :seq_mode]
125
+ assert_required_options(required, options)
126
+ post_request name, options
127
+ end
128
+
129
+ ### @params ###
130
+ # MemberID
131
+ # SeqMode
132
+ # TokenSeq
133
+ ### @return ###
134
+ # TokenSeq
135
+ ### example ###
136
+ # gmo.delete_brandtoken({
137
+ # member_id: '598066176120b2235300020b',
138
+ # seq_mode: 0,
139
+ # token_seq: 0
140
+ # })
141
+ # => {"TokenSeq"=>"0"}
142
+ def delete_brandtoken(options = {})
143
+ name = "DeleteBrandtoken.idPass"
144
+ required = [:member_id, :seq_mode, :token_seq]
145
+ assert_required_options(required, options)
146
+ post_request name, options
147
+ end
148
+
95
149
  ## 2.11.2.3. 決済実行
96
150
  # お客様が選択したカード登録連番のカード情報を取得します。
97
151
  # カード情報が本人認証サービスに対応していない場合は、カード会社との通信を行い決済を実行します。その際の出力パラメータは「2.10.2.3決済実行」の出力パラメータと同じになります。
@@ -103,6 +157,16 @@ module GMO
103
157
  post_request name, options
104
158
  end
105
159
 
160
+ ## 2.19.2.1.カード属性照会(サイトID+会員ID(+カード登録連番モード・カード登録連番)を指定して呼び出す場合)
161
+ # 指定したクレジットカードの属性情報を取得します。
162
+ # /payment/SearchCardDetail.idPass
163
+ def search_card_detail_by_member_id(options = {})
164
+ name = "SearchCardDetail.idPass"
165
+ required = [:member_id, :seq_mode]
166
+ assert_required_options(required, options)
167
+ post_request name, options
168
+ end
169
+
106
170
  private
107
171
 
108
172
  def api_call(name, args = {}, verb = "post", options = {})
@@ -1,3 +1,3 @@
1
1
  module GMO
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -16,10 +16,19 @@ describe GMO::Payment::APIError do
16
16
  it "is a GMO::Payment::Error" do
17
17
  GMO::Payment::APIError.new({}).should be_a(GMO::Payment::Error)
18
18
  end
19
+
20
+ context 'with error messages' do
21
+ let(:response) { {
22
+ "ErrCode" => "BA1|E01",
23
+ "ErrInfo" => "BA1040001|E01170001|100"
24
+ } }
25
+ subject { GMO::Payment::APIError.new(response) }
26
+ it { expect(subject.message).to eq "ErrCode=BA1|E01&ErrInfo=BA1040001|E01170001|100&ErrMessage=Bank ID is not specified|Card Number not specified|Card number Required check error" }
27
+ end
19
28
  end
20
29
 
21
30
  describe GMO::Payment::ServerError do
22
31
  it "is a GMO::Payment::Error" do
23
- GMO::Payment::ServerError.new(nil, nil).should be_a(GMO::Payment::Error)
32
+ GMO::Payment::ServerError.new(nil, nil).should be_a(GMO::Payment::Error)
24
33
  end
25
- end
34
+ end
@@ -0,0 +1,504 @@
1
+ # Encoding: UTF-8
2
+
3
+ require "spec_helper"
4
+
5
+ describe "GMO::Payment::RemittanceAPI" do
6
+
7
+ before(:each) do
8
+ @service ||= GMO::Payment::RemittanceAPI.new({
9
+ :shop_id => SPEC_CONF["remittance"]["shop_id"],
10
+ :shop_pass => SPEC_CONF["remittance"]["shop_pass"],
11
+ :host => SPEC_CONF["remittance"]["host"]
12
+ })
13
+ end
14
+
15
+ it "should raise an ArgumentError if no options passed" do
16
+ lambda {
17
+ service = GMO::Payment::RemittanceAPI.new()
18
+ }.should raise_error(ArgumentError)
19
+ end
20
+
21
+ it "has an attr_reader for shop_id" do
22
+ @service.shop_id.should == SPEC_CONF["remittance"]["shop_id"]
23
+ end
24
+
25
+ it "has an attr_reader for shop_pass" do
26
+ @service.shop_pass.should == SPEC_CONF["remittance"]["shop_pass"]
27
+ end
28
+
29
+ it "has an attr_reader for host" do
30
+ @service.host.should == SPEC_CONF["remittance"]["host"]
31
+ end
32
+
33
+ describe "#create_account" do
34
+ let(:do_api_call) {
35
+ @service.create_account({
36
+ :bank_id => "bank00001",
37
+ :bank_code => "0001",
38
+ :branch_code => "813",
39
+ :account_type => :normal,
40
+ :account_name => "An Yutzy",
41
+ :account_number => "0012345",
42
+ :branch_code_jp => "00567",
43
+ :account_number_jp => "01234567",
44
+ :free => "foobar"
45
+ })
46
+ }
47
+
48
+ it "gets data about an account", :vcr do
49
+ result = do_api_call
50
+ result["Bank_ID"].nil?.should_not be_truthy
51
+ result["Method"].nil?.should_not be_truthy
52
+ end
53
+
54
+ context 'with all required options' do
55
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
56
+ before { allow(GMO).to receive(:make_request) { response } }
57
+
58
+ it "makes request with correct parameters", :vcr do
59
+ path = "/api/AccountRegistration.idPass"
60
+ args = {
61
+ "Method" => 1,
62
+ "Bank_ID" => "bank00001",
63
+ "Bank_Code" => "0001",
64
+ "Branch_Code" => "813",
65
+ "Account_Type" => 1,
66
+ "Account_Name" => "An Yutzy",
67
+ "Account_Number" => "0012345",
68
+ "Branch_Code_Jpbank" => "00567",
69
+ "Account_Number_Jpbank" => "01234567",
70
+ "Free" => "foobar",
71
+ "Shop_ID" => @service.shop_id,
72
+ "Shop_Pass" => @service.shop_pass
73
+ }
74
+ verb = "post"
75
+ options = { :host => @service.host }
76
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
77
+ end
78
+
79
+ after { do_api_call }
80
+ end
81
+
82
+ it "got error if missing options", :vcr do
83
+ lambda {
84
+ result = @service.create_account()
85
+ }.should raise_error("Required bank_id, bank_code, branch_code, account_type, account_name, account_number were not provided.")
86
+ end
87
+ end
88
+
89
+ describe "#update_account" do
90
+ let(:do_api_call) {
91
+ @service.update_account({
92
+ :bank_id => "bank00001",
93
+ :bank_code => "0001",
94
+ :branch_code => "813",
95
+ :account_type => :normal,
96
+ :account_name => "An Yutzy",
97
+ :account_number => "0012345",
98
+ :branch_code_jp => "00567",
99
+ :account_number_jp => "01234567",
100
+ :free => "foobar"
101
+ })
102
+ }
103
+
104
+ it "gets data about an account", :vcr do
105
+ result = do_api_call
106
+ result["Bank_ID"].nil?.should_not be_truthy
107
+ result["Method"].nil?.should_not be_truthy
108
+ end
109
+
110
+ context 'with all required options' do
111
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
112
+ before { allow(GMO).to receive(:make_request) { response } }
113
+
114
+ it "makes request with correct parameters", :vcr do
115
+ path = "/api/AccountRegistration.idPass"
116
+ args = {
117
+ "Method" => 2,
118
+ "Bank_ID" => "bank00001",
119
+ "Bank_Code" => "0001",
120
+ "Branch_Code" => "813",
121
+ "Account_Type" => 1,
122
+ "Account_Name" => "An Yutzy",
123
+ "Account_Number" => "0012345",
124
+ "Branch_Code_Jpbank" => "00567",
125
+ "Account_Number_Jpbank" => "01234567",
126
+ "Free" => "foobar",
127
+ "Shop_ID" => @service.shop_id,
128
+ "Shop_Pass" => @service.shop_pass
129
+ }
130
+ verb = "post"
131
+ options = { :host => @service.host }
132
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
133
+ end
134
+
135
+ after { do_api_call }
136
+ end
137
+
138
+ it "got error if missing options", :vcr do
139
+ lambda {
140
+ result = @service.create_account()
141
+ }.should raise_error("Required bank_id, bank_code, branch_code, account_type, account_name, account_number were not provided.")
142
+ end
143
+ end
144
+
145
+ describe "#delete_account" do
146
+ let(:do_api_call) { @service.delete_account(bank_id: "bank00001") }
147
+
148
+ it "gets data about an account", :vcr do
149
+ result = do_api_call
150
+ result["Bank_ID"].nil?.should_not be_truthy
151
+ result["Method"].nil?.should_not be_truthy
152
+ end
153
+
154
+ context 'with all required options' do
155
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
156
+ before { allow(GMO).to receive(:make_request) { response } }
157
+
158
+ it "makes request with correct parameters", :vcr do
159
+ path = "/api/AccountRegistration.idPass"
160
+ args = {
161
+ "Method" => 3,
162
+ "Bank_ID" => "bank00001",
163
+ "Shop_ID" => @service.shop_id,
164
+ "Shop_Pass" => @service.shop_pass
165
+ }
166
+ verb = "post"
167
+ options = { :host => @service.host }
168
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
169
+ end
170
+
171
+ after { do_api_call }
172
+ end
173
+
174
+ it "got error if missing options", :vcr do
175
+ lambda {
176
+ result = @service.delete_account()
177
+ }.should raise_error("Required bank_id were not provided.")
178
+ end
179
+ end
180
+
181
+ describe "#search_account" do
182
+ let(:do_api_call) { @service.search_account(:bank_id => "bank00001") }
183
+
184
+ it "gets data about an account", :vcr do
185
+ result = do_api_call
186
+ result["Bank_ID"].nil?.should_not be_truthy
187
+ result["Delete_Flag"].nil?.should_not be_truthy
188
+ result["Bank_Name"].nil?.should_not be_truthy
189
+ result["Bank_Code"].nil?.should_not be_truthy
190
+ result["Branch_Name"].nil?.should_not be_truthy
191
+ result["Branch_Code"].nil?.should_not be_truthy
192
+ result["Account_Type"].nil?.should_not be_truthy
193
+ result["Account_Number"].nil?.should_not be_truthy
194
+ result["Account_Name"].nil?.should_not be_truthy
195
+ result["Free"].nil?.should_not be_truthy
196
+ result["Branch_Code_Jpbank"].nil?.should_not be_truthy
197
+ result["Account_Number_Jpbank"].nil?.should_not be_truthy
198
+ end
199
+
200
+ context 'with all required options' do
201
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
202
+ before { allow(GMO).to receive(:make_request) { response } }
203
+
204
+ it "makes request with correct parameters", :vcr do
205
+ path = "/api/AccountSearch.idPass"
206
+ args = {
207
+ "Bank_ID" => "bank00001",
208
+ "Shop_ID" => @service.shop_id,
209
+ "Shop_Pass" => @service.shop_pass
210
+ }
211
+ verb = "post"
212
+ options = { :host => @service.host }
213
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
214
+ end
215
+
216
+ after { do_api_call }
217
+ end
218
+
219
+ it "got error if missing options", :vcr do
220
+ lambda {
221
+ result = @service.search_account()
222
+ }.should raise_error("Required bank_id were not provided.")
223
+ end
224
+ end
225
+
226
+ describe "#create_deposit" do
227
+ let(:do_api_call) {
228
+ @service.create_deposit({
229
+ :bank_id => "bank00001",
230
+ :deposit_id => "dep00001",
231
+ :amount => "1000"
232
+ })
233
+ }
234
+
235
+ it "gets data about a deposit", :vcr do
236
+ result = do_api_call
237
+ result["Bank_ID"].nil?.should_not be_truthy
238
+ result["Deposit_ID"].nil?.should_not be_truthy
239
+ result["Method"].nil?.should_not be_truthy
240
+ result["Amount"].nil?.should_not be_truthy
241
+ result["Bank_Fee"].nil?.should_not be_truthy
242
+ end
243
+
244
+ context 'with all required options' do
245
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
246
+ before { allow(GMO).to receive(:make_request) { response } }
247
+
248
+ it "makes request with correct parameters", :vcr do
249
+ path = "/api/DepositRegistration.idPass"
250
+ args = {
251
+ "Method" => 1,
252
+ "Bank_ID" => "bank00001",
253
+ "Deposit_ID" => "dep00001",
254
+ "Amount" => "1000",
255
+ "Shop_ID" => @service.shop_id,
256
+ "Shop_Pass" => @service.shop_pass
257
+ }
258
+ verb = "post"
259
+ options = { :host => @service.host }
260
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
261
+ end
262
+
263
+ after { do_api_call }
264
+ end
265
+
266
+ it "got error if missing options", :vcr do
267
+ lambda {
268
+ result = @service.create_deposit()
269
+ }.should raise_error("Required bank_id, deposit_id, amount were not provided.")
270
+ end
271
+ end
272
+
273
+ describe "#cancel_deposit" do
274
+ let(:do_api_call) {
275
+ @service.cancel_deposit({
276
+ :bank_id => "bank00001",
277
+ :deposit_id => "dep00001",
278
+ })
279
+ }
280
+
281
+ it "gets data about a deposit", :vcr do
282
+ result = do_api_call
283
+ result["Bank_ID"].nil?.should_not be_truthy
284
+ result["Deposit_ID"].nil?.should_not be_truthy
285
+ result["Method"].nil?.should_not be_truthy
286
+ end
287
+
288
+ context 'with all required options' do
289
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
290
+ before { allow(GMO).to receive(:make_request) { response } }
291
+
292
+ it "makes request with correct parameters", :vcr do
293
+ path = "/api/DepositRegistration.idPass"
294
+ args = {
295
+ "Method" => 2,
296
+ "Bank_ID" => "bank00001",
297
+ "Deposit_ID" => "dep00001",
298
+ "Shop_ID" => @service.shop_id,
299
+ "Shop_Pass" => @service.shop_pass
300
+ }
301
+ verb = "post"
302
+ options = { :host => @service.host }
303
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
304
+ end
305
+
306
+ after { do_api_call }
307
+ end
308
+
309
+ it "got error if missing options", :vcr do
310
+ lambda {
311
+ result = @service.cancel_deposit()
312
+ }.should raise_error("Required bank_id, deposit_id were not provided.")
313
+ end
314
+ end
315
+
316
+ describe "#search_deposit" do
317
+ let(:do_api_call) { @service.search_deposit(:deposit_id => "dep00001") }
318
+
319
+ it "gets data about a deposit", :vcr do
320
+ result = do_api_call
321
+ result["Bank_ID"].nil?.should_not be_truthy
322
+ result["Deposit_ID"].nil?.should_not be_truthy
323
+ result["Bank_Name"].nil?.should_not be_truthy
324
+ result["Bank_Code"].nil?.should_not be_truthy
325
+ result["Branch_Name"].nil?.should_not be_truthy
326
+ result["Branch_Code"].nil?.should_not be_truthy
327
+ result["Account_Type"].nil?.should_not be_truthy
328
+ result["Account_Number"].nil?.should_not be_truthy
329
+ result["Account_Name"].nil?.should_not be_truthy
330
+ result["Free"].nil?.should_not be_truthy
331
+ result["Amount"].nil?.should_not be_truthy
332
+ result["Bank_Fee"].nil?.should_not be_truthy
333
+ result["Result"].nil?.should_not be_truthy
334
+ result["Branch_Code_Jpbank"].nil?.should_not be_truthy
335
+ result["Account_Number_Jpbank"].nil?.should_not be_truthy
336
+ result["Deposit_Date"].nil?.should_not be_truthy
337
+ result["Result_Detail"].nil?.should_not be_truthy
338
+ end
339
+
340
+ context 'with all required options' do
341
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
342
+ before { allow(GMO).to receive(:make_request) { response } }
343
+
344
+ it "makes request with correct parameters", :vcr do
345
+ path = "/api/DepositSearch.idPass"
346
+ args = {
347
+ "Deposit_ID" => "dep00001",
348
+ "Shop_ID" => @service.shop_id,
349
+ "Shop_Pass" => @service.shop_pass
350
+ }
351
+ verb = "post"
352
+ options = { :host => @service.host }
353
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
354
+ end
355
+
356
+ after { do_api_call }
357
+ end
358
+
359
+ it "got error if missing options", :vcr do
360
+ lambda {
361
+ result = @service.search_deposit()
362
+ }.should raise_error("Required deposit_id were not provided.")
363
+ end
364
+ end
365
+
366
+ describe "#search_balance" do
367
+ let(:do_api_call) { @service.search_balance }
368
+ it "gets data about balance", :vcr do
369
+ result = do_api_call
370
+ result["Shop_ID"].nil?.should_not be_truthy
371
+ result["Balance"].nil?.should_not be_truthy
372
+ result["Balance_Forecast"].nil?.should_not be_truthy
373
+ end
374
+ end
375
+
376
+ describe "#create_mail_deposit" do
377
+ let(:do_api_call) {
378
+ @service.create_mail_deposit({
379
+ :deposit_id => "dep00001",
380
+ :deposit_email => "anyutzy@demo.com",
381
+ :amount => 1000,
382
+ :deposit_account_name => "An Yutzy",
383
+ :expire => 5,
384
+ :deposit_shop_email => "anyutzy@demo.com"
385
+ })
386
+ }
387
+
388
+ it "gets data about a mail deposit", :vcr do
389
+ result = do_api_call
390
+ result["Deposit_ID"].nil?.should_not be_truthy
391
+ result["Method"].nil?.should_not be_truthy
392
+ result["Amount"].nil?.should_not be_truthy
393
+ result["Expire"].nil?.should_not be_truthy
394
+ end
395
+
396
+ context 'with all required options' do
397
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
398
+ before { allow(GMO).to receive(:make_request) { response } }
399
+
400
+ it "makes request with correct parameters", :vcr do
401
+ path = "/api/MailDepositRegistration.idPass"
402
+ args = {
403
+ "Deposit_ID" => "dep00001",
404
+ "Mail_Address" => "anyutzy@demo.com",
405
+ "Amount" => 1000,
406
+ "Mail_Deposit_Account_Name" => "An Yutzy",
407
+ "Expire" => 5,
408
+ "Shop_Mail_Address" => "anyutzy@demo.com",
409
+ "Method" => 1,
410
+ "Shop_ID" => @service.shop_id,
411
+ "Shop_Pass" => @service.shop_pass
412
+ }
413
+ verb = "post"
414
+ options = { :host => @service.host }
415
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
416
+ end
417
+
418
+ after { do_api_call }
419
+ end
420
+
421
+ it "got error if missing options", :vcr do
422
+ lambda {
423
+ result = @service.create_mail_deposit()
424
+ }.should raise_error("Required deposit_id, deposit_email, amount, deposit_account_name, expire, deposit_shop_email were not provided.")
425
+ end
426
+ end
427
+
428
+ describe "#cancel_mail_deposit" do
429
+ let(:do_api_call) { @service.cancel_mail_deposit(deposit_id: "dep00001") }
430
+
431
+ it "gets data about a mail deposit", :vcr do
432
+ result = do_api_call
433
+ result["Deposit_ID"].nil?.should_not be_truthy
434
+ result["Method"].nil?.should_not be_truthy
435
+ end
436
+
437
+ context 'with all required options' do
438
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
439
+ before { allow(GMO).to receive(:make_request) { response } }
440
+
441
+ it "makes request with correct parameters", :vcr do
442
+ path = "/api/MailDepositRegistration.idPass"
443
+ args = {
444
+ "Deposit_ID" => "dep00001",
445
+ "Method" => 2,
446
+ "Shop_ID" => @service.shop_id,
447
+ "Shop_Pass" => @service.shop_pass
448
+ }
449
+ verb = "post"
450
+ options = { :host => @service.host }
451
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
452
+ end
453
+
454
+ after { do_api_call }
455
+ end
456
+
457
+ it "got error if missing options", :vcr do
458
+ lambda {
459
+ result = @service.cancel_mail_deposit()
460
+ }.should raise_error("Required deposit_id were not provided.")
461
+ end
462
+ end
463
+
464
+ describe "#search_mail_deposit" do
465
+ let(:do_api_call) { @service.search_mail_deposit(deposit_id: "dep00001") }
466
+
467
+ it "gets data about a mail deposit", :vcr do
468
+ result = do_api_call
469
+ result["Deposit_ID"].nil?.should_not be_truthy
470
+ result["Mail_Address"].nil?.should_not be_truthy
471
+ result["Shop_Mail_Address"].nil?.should_not be_truthy
472
+ result["Account_Name"].nil?.should_not be_truthy
473
+ result["Amount"].nil?.should_not be_truthy
474
+ result["Expire"].nil?.should_not be_truthy
475
+ result["Status"].nil?.should_not be_truthy
476
+ end
477
+
478
+ context 'with all required options' do
479
+ let(:response) { OpenStruct.new(status: 200, body: nil ) }
480
+ before { allow(GMO).to receive(:make_request) { response } }
481
+
482
+ it "makes request with correct parameters", :vcr do
483
+ path = "/api/MailDepositSearch.idPass"
484
+ args = {
485
+ "Deposit_ID" => "dep00001",
486
+ "Shop_ID" => @service.shop_id,
487
+ "Shop_Pass" => @service.shop_pass
488
+ }
489
+ verb = "post"
490
+ options = { :host => @service.host }
491
+ expect(GMO).to receive(:make_request).with(path, args, verb, options)
492
+ end
493
+
494
+ after { do_api_call }
495
+ end
496
+
497
+ it "got error if missing options", :vcr do
498
+ lambda {
499
+ result = @service.search_mail_deposit()
500
+ }.should raise_error("Required deposit_id were not provided.")
501
+ end
502
+ end
503
+
504
+ end