gmo 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -91,4 +91,78 @@ describe "GMO::Payment::ShopAndSiteAPI" do
91
91
  end
92
92
  end
93
93
 
94
+ describe "#trade_brandtoken" do
95
+
96
+ it "got data", :vcr do
97
+ order_id = generate_id
98
+ result = @shop_api.entry_tran_brandtoken({
99
+ :order_id => order_id,
100
+ :job_cd => "AUTH",
101
+ :amount => 100
102
+ })
103
+ access_id = result["AccessID"]
104
+ access_pass = result["AccessPass"]
105
+ member_id = generate_id
106
+ result = @service.exec_tran_brandtoken({
107
+ :order_id => order_id,
108
+ :access_id => access_id,
109
+ :access_pass => access_pass,
110
+ :token_type => :apple_pay,
111
+ :token => 'base64encodedtoken',
112
+ :member_id => member_id
113
+ })
114
+ result = @service.trade_brandtoken({
115
+ :order_id => order_id,
116
+ :member_id => member_id
117
+ })
118
+ result["TokenSeq"].nil?.should_not be true
119
+ result["CardNoToken"].nil?.should_not be true
120
+ result["Forward"].nil?.should_not be true
121
+ end
122
+
123
+ it "got error if missing options", :vcr do
124
+ lambda {
125
+ result = @service.trade_brandtoken()
126
+ }.should raise_error('Required order_id, member_id were not provided.')
127
+ end
128
+ end
129
+
130
+ describe "#exec_tran_brandtoken" do
131
+
132
+ it "got data", :vcr do
133
+ order_id = generate_id
134
+ result = @shop_api.entry_tran_brandtoken({
135
+ :order_id => order_id,
136
+ :job_cd => "AUTH",
137
+ :amount => 100
138
+ })
139
+ access_id = result["AccessID"]
140
+ access_pass = result["AccessPass"]
141
+ member_id = generate_id
142
+ result = @service.exec_tran_brandtoken({
143
+ :order_id => order_id,
144
+ :access_id => access_id,
145
+ :access_pass => access_pass,
146
+ :token_type => :apple_pay,
147
+ :token => 'base64encodedtoken',
148
+ :member_id => member_id
149
+ })
150
+ result["Status"].nil?.should_not be true
151
+ result["OrderID"].nil?.should_not be true
152
+ result["Forward"].nil?.should_not be true
153
+ result["Approve"].nil?.should_not be true
154
+ result["TranID"].nil?.should_not be true
155
+ result["TranDate"].nil?.should_not be true
156
+ result["ClientField1"].nil?.should_not be true
157
+ result["ClientField2"].nil?.should_not be true
158
+ result["ClientField3"].nil?.should_not be true
159
+ end
160
+
161
+ it "got error if missing options", :vcr do
162
+ lambda {
163
+ result = @service.exec_tran_brandtoken()
164
+ }.should raise_error('Required access_id, access_pass, member_id, order_id were not provided.')
165
+ end
166
+ end
167
+
94
168
  end
@@ -9,6 +9,13 @@ describe "GMO::Payment::ShopAPI" do
9
9
  end
10
10
 
11
11
  before(:each) do
12
+ @shop_site ||= GMO::Payment::ShopAndSiteAPI.new({
13
+ :site_id => SPEC_CONF["site_id"],
14
+ :site_pass => SPEC_CONF["site_pass"],
15
+ :shop_id => SPEC_CONF["shop_id"],
16
+ :shop_pass => SPEC_CONF["shop_pass"],
17
+ :host => SPEC_CONF["host"]
18
+ })
12
19
  @service ||= GMO::Payment::ShopAPI.new({
13
20
  :shop_id => SPEC_CONF["shop_id"],
14
21
  :shop_pass => SPEC_CONF["shop_pass"],
@@ -108,6 +115,25 @@ describe "GMO::Payment::ShopAPI" do
108
115
  end
109
116
  end
110
117
 
118
+ describe "#entry_tran_brandtoken" do
119
+ it "gets data about a transaction", :vcr do
120
+ order_id = @order_id
121
+ result = @service.entry_tran_brandtoken({
122
+ :order_id => order_id,
123
+ :job_cd => "AUTH",
124
+ :amount => 100
125
+ })
126
+ result["AccessID"].nil?.should_not be true
127
+ result["AccessPass"].nil?.should_not be true
128
+ end
129
+
130
+ it "got error if missing options", :vcr do
131
+ lambda {
132
+ result = @service.entry_tran_brandtoken()
133
+ }.should raise_error('Required order_id, job_cd, amount were not provided.')
134
+ end
135
+ end
136
+
111
137
  describe "#exec_tran" do
112
138
  it "gets data about a transaction", :vcr do
113
139
  order_id = generate_id
@@ -149,6 +175,27 @@ describe "GMO::Payment::ShopAPI" do
149
175
  }.should raise_error("Required access_id, access_pass, order_id, card_no, expire were not provided.")
150
176
  end
151
177
 
178
+ it "doesn't require card info if token is present", :vcr do
179
+ lambda {
180
+ order_id = generate_id
181
+ result = @service.entry_tran({
182
+ :order_id => order_id,
183
+ :job_cd => "AUTH",
184
+ :amount => 100
185
+ })
186
+ access_id = result["AccessID"]
187
+ access_pass = result["AccessPass"]
188
+ result = @service.exec_tran({
189
+ :order_id => order_id,
190
+ :access_id => access_id,
191
+ :access_pass => access_pass,
192
+ :method => 1,
193
+ :pay_times => 1,
194
+ :token => "onetimetokenfromgmo"
195
+ })
196
+ }.should_not raise_error("Required card_no, expire were not provided.")
197
+ end
198
+
152
199
  context "parameter contains Japanese characters" do
153
200
  before { require "kconv" unless defined?(Kconv) }
154
201
 
@@ -299,6 +346,77 @@ describe "GMO::Payment::ShopAPI" do
299
346
  end
300
347
  end
301
348
 
349
+ describe "#exec_tran_brandtoken" do
350
+ it "gets data about a transaction", :vcr do
351
+ order_id = generate_id
352
+ client_field_1 = "client_field1"
353
+ result = @service.entry_tran_brandtoken({
354
+ :order_id => order_id,
355
+ :job_cd => "AUTH",
356
+ :amount => 100
357
+ })
358
+ access_id = result["AccessID"]
359
+ access_pass = result["AccessPass"]
360
+ result = @service.exec_tran_brandtoken({
361
+ :order_id => order_id,
362
+ :access_id => access_id,
363
+ :access_pass => access_pass,
364
+ :token_type => :apple_pay,
365
+ :token => 'base64encodedtoken',
366
+ :client_field_1 => client_field_1
367
+ })
368
+ result["Status"].nil?.should_not be true
369
+ result["OrderID"].nil?.should_not be true
370
+ result["Forward"].nil?.should_not be true
371
+ result["Approve"].nil?.should_not be true
372
+ result["TranID"].nil?.should_not be true
373
+ result["TranDate"].nil?.should_not be true
374
+ (result["ClientField1"] == client_field_1).should be true
375
+ result["ClientField2"].nil?.should_not be true
376
+ result["ClientField3"].nil?.should_not be true
377
+ end
378
+
379
+ it "got error if missing options", :vcr do
380
+ lambda {
381
+ result = @service.exec_tran_brandtoken()
382
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
383
+ end
384
+
385
+ context "parameter contains Japanese characters" do
386
+ before { require "kconv" unless defined?(Kconv) }
387
+
388
+ it "should correctly handle Japanese", :vcr do
389
+ order_id = generate_id
390
+ client_field_1 = "〜−¢£¬−‖①ほげほげhogehoge"
391
+ result = @service.entry_tran_brandtoken({
392
+ :order_id => order_id,
393
+ :job_cd => "AUTH",
394
+ :amount => 100
395
+ })
396
+ access_id = result["AccessID"]
397
+ access_pass = result["AccessPass"]
398
+ result = @service.exec_tran_brandtoken({
399
+ :order_id => order_id,
400
+ :access_id => access_id,
401
+ :access_pass => access_pass,
402
+ :token_type => :apple_pay,
403
+ :token => 'base64encodedtoken',
404
+ :client_field_1 => client_field_1
405
+ })
406
+ result["Status"].nil?.should_not be true
407
+ result["OrderID"].nil?.should_not be true
408
+ result["Forward"].nil?.should_not be true
409
+ result["Approve"].nil?.should_not be true
410
+ result["TranID"].nil?.should_not be true
411
+ result["TranDate"].nil?.should_not be true
412
+ (result["ClientField1"] == client_field_1).should be true
413
+ (result["ClientField1"].encoding.to_s == "UTF-8").should be true
414
+ result["ClientField2"].nil?.should_not be true
415
+ result["ClientField3"].nil?.should_not be true
416
+ end
417
+ end
418
+ end
419
+
302
420
  describe "#alter_tran" do
303
421
  it "gets data about order", :vcr do
304
422
  order_id = generate_id
@@ -413,6 +531,166 @@ describe "GMO::Payment::ShopAPI" do
413
531
  end
414
532
  end
415
533
 
534
+ describe "#change_tran_brandtoken" do
535
+ it "gets data about order", :vcr do
536
+ order_id = generate_id
537
+ result = @service.entry_tran_brandtoken({
538
+ :order_id => order_id,
539
+ :job_cd => "AUTH",
540
+ :amount => 100
541
+ })
542
+ access_id = result["AccessID"]
543
+ access_pass = result["AccessPass"]
544
+ @service.exec_tran_brandtoken({
545
+ :order_id => order_id,
546
+ :access_id => access_id,
547
+ :access_pass => access_pass,
548
+ :token_type => :apple_pay,
549
+ :token => 'base64encodedtoken'
550
+ })
551
+ result = @service.change_tran_brandtoken({
552
+ :order_id => order_id,
553
+ :access_id => access_id,
554
+ :access_pass => access_pass,
555
+ :job_cd => "CAPTURE",
556
+ :amount => 1500
557
+ })
558
+ result["AccessID"].nil?.should_not be true
559
+ result["AccessPass"].nil?.should_not be true
560
+ result["Status"].nil?.should_not be true
561
+ result["Forward"].nil?.should_not be true
562
+ result["Approve"].nil?.should_not be true
563
+ result["TranID"].nil?.should_not be true
564
+ result["TranDate"].nil?.should_not be true
565
+ end
566
+
567
+ it "got error if missing options", :vcr do
568
+ lambda {
569
+ result = @service.change_tran_brandtoken()
570
+ }.should raise_error('Required access_id, access_pass, order_id, job_cd, amount were not provided.')
571
+ end
572
+ end
573
+
574
+ describe "#void_tran_brandtoken" do
575
+ it "gets data about order", :vcr do
576
+ order_id = generate_id
577
+ result = @service.entry_tran_brandtoken({
578
+ :order_id => order_id,
579
+ :job_cd => "AUTH",
580
+ :amount => 100
581
+ })
582
+ access_id = result["AccessID"]
583
+ access_pass = result["AccessPass"]
584
+ @service.exec_tran_brandtoken({
585
+ :order_id => order_id,
586
+ :access_id => access_id,
587
+ :access_pass => access_pass,
588
+ :token_type => :apple_pay,
589
+ :token => 'base64encodedtoken'
590
+ })
591
+ result = @service.void_tran_brandtoken({
592
+ :order_id => order_id,
593
+ :access_id => access_id,
594
+ :access_pass => access_pass
595
+ })
596
+ result["AccessID"].nil?.should_not be true
597
+ result["AccessPass"].nil?.should_not be true
598
+ result["Status"].nil?.should_not be true
599
+ result["Forward"].nil?.should_not be true
600
+ result["Approve"].nil?.should_not be true
601
+ result["TranID"].nil?.should_not be true
602
+ result["TranDate"].nil?.should_not be true
603
+ end
604
+
605
+ it "got error if missing options", :vcr do
606
+ lambda {
607
+ result = @service.void_tran_brandtoken()
608
+ }.should raise_error('Required access_id, access_pass, order_id were not provided.')
609
+ end
610
+ end
611
+
612
+ describe "#sales_tran_brandtoken" do
613
+ it "gets data about a transaction", :vcr do
614
+ order_id = generate_id
615
+ result = @service.entry_tran_brandtoken({
616
+ :order_id => order_id,
617
+ :job_cd => "AUTH",
618
+ :amount => 1000
619
+ })
620
+ access_id = result["AccessID"]
621
+ access_pass = result["AccessPass"]
622
+ @service.exec_tran_brandtoken({
623
+ :order_id => order_id,
624
+ :access_id => access_id,
625
+ :access_pass => access_pass,
626
+ :token_type => :apple_pay,
627
+ :token => 'base64encodedtoken'
628
+ })
629
+ member_id = generate_id
630
+ @shop_site.trade_brandtoken({
631
+ :member_id => member_id,
632
+ :order_id => order_id
633
+ })
634
+ result = @service.sales_tran_brandtoken({
635
+ :access_id => access_id,
636
+ :access_pass => access_pass,
637
+ :order_id => order_id,
638
+ :amount => 1000
639
+ })
640
+ result["AccessID"].nil?.should_not be true
641
+ result["AccessPass"].nil?.should_not be true
642
+ result["Status"].nil?.should_not be true
643
+ result["Forward"].nil?.should_not be true
644
+ result["Approve"].nil?.should_not be true
645
+ result["TranID"].nil?.should_not be true
646
+ result["TranDate"].nil?.should_not be true
647
+ end
648
+
649
+ it "got error if missing options", :vcr do
650
+ lambda {
651
+ result = @service.sales_tran_brandtoken()
652
+ }.should raise_error('Required access_id, access_pass, order_id, amount were not provided.')
653
+ end
654
+ end
655
+
656
+ describe "#refund_tran_brandtoken" do
657
+ it "gets data about a transaction", :vcr do
658
+ order_id = generate_id
659
+ result = @service.entry_tran_brandtoken({
660
+ :order_id => order_id,
661
+ :job_cd => "CAPTURE",
662
+ :amount => 1000
663
+ })
664
+ access_id = result["AccessID"]
665
+ access_pass = result["AccessPass"]
666
+ @service.exec_tran_brandtoken({
667
+ :order_id => order_id,
668
+ :access_id => access_id,
669
+ :access_pass => access_pass,
670
+ :token_type => :apple_pay,
671
+ :token => 'base64encodedtoken'
672
+ })
673
+ result = @service.refund_tran_brandtoken({
674
+ :access_id => access_id,
675
+ :access_pass => access_pass,
676
+ :order_id => order_id,
677
+ :amount => 1000
678
+ })
679
+ result["AccessID"].nil?.should_not be true
680
+ result["AccessPass"].nil?.should_not be true
681
+ result["Status"].nil?.should_not be true
682
+ result["Forward"].nil?.should_not be true
683
+ result["Approve"].nil?.should_not be true
684
+ result["TranID"].nil?.should_not be true
685
+ result["TranDate"].nil?.should_not be true
686
+ end
687
+
688
+ it "got error if missing options", :vcr do
689
+ lambda {
690
+ result = @service.refund_tran_brandtoken()
691
+ }.should raise_error('Required access_id, access_pass, order_id, amount were not provided.')
692
+ end
693
+ end
416
694
 
417
695
  describe "#search_trade" do
418
696
  it "gets data about order", :vcr do
@@ -7,6 +7,13 @@ describe "GMO::Payment::SiteAPI" do
7
7
  end
8
8
 
9
9
  before(:each) do
10
+ @shop_site ||= GMO::Payment::ShopAndSiteAPI.new({
11
+ :site_id => SPEC_CONF["site_id"],
12
+ :site_pass => SPEC_CONF["site_pass"],
13
+ :shop_id => SPEC_CONF["shop_id"],
14
+ :shop_pass => SPEC_CONF["shop_pass"],
15
+ :host => SPEC_CONF["host"]
16
+ })
10
17
  @service ||= GMO::Payment::SiteAPI.new({
11
18
  :site_id => SPEC_CONF["site_id"],
12
19
  :site_pass => SPEC_CONF["site_pass"],
@@ -200,4 +207,80 @@ describe "GMO::Payment::SiteAPI" do
200
207
  end
201
208
  end
202
209
 
203
- end
210
+ describe "#search_card_detail_by_member_id" do
211
+ it "gets data about card detail", :vcr do
212
+ member_id = generate_id
213
+ seq_mode = 0
214
+ result = @service.search_card_detail_by_member_id({
215
+ :member_id => member_id,
216
+ :seq_mode => seq_mode
217
+ })
218
+ result["CardNo"].nil?.should_not be_truthy
219
+ result["Brand"].nil?.should_not be_truthy
220
+ result["DomesticFlag"].nil?.should_not be_truthy
221
+ result["IssuerCode"].nil?.should_not be_truthy
222
+ result["DebitPrepaidFlag"].nil?.should_not be_truthy
223
+ result["DebitPrepaidIssuerName"].nil?.should_not be_truthy
224
+ result["ForwardFinal"].nil?.should_not be_truthy
225
+ end
226
+
227
+ it "got error if missing options", :vcr do
228
+ lambda {
229
+ result = @service.search_card_detail_by_member_id()
230
+ }.should raise_error("Required member_id, seq_mode were not provided.")
231
+ end
232
+ end
233
+
234
+ describe "#search_brandtoken" do
235
+ it "gets data about a brandtoken", :vcr do
236
+ order_id = generate_id
237
+ member_id = generate_id
238
+ @shop_site.trade_brandtoken({
239
+ :order_id => order_id,
240
+ :member_id => member_id
241
+ })
242
+
243
+ result = @service.search_brandtoken({
244
+ :member_id => member_id,
245
+ :seq_mode => 0
246
+ })
247
+ result["TokenSeq"].nil?.should_not be true
248
+ result["DefaultFlag"].nil?.should_not be true
249
+ result["CardName"].nil?.should_not be true
250
+ result["CardNoToken"].nil?.should_not be true
251
+ result["Expire"].nil?.should_not be true
252
+ result["HolderName"].nil?.should_not be true
253
+ result["DeleteFlag"].nil?.should_not be true
254
+ end
255
+
256
+ it "got error if missing options", :vcr do
257
+ lambda {
258
+ result = @service.search_brandtoken()
259
+ }.should raise_error("Required member_id, seq_mode were not provided.")
260
+ end
261
+ end
262
+
263
+ describe "#delete_brandtoken" do
264
+ it "gets data about a brandtoken", :vcr do
265
+ order_id = generate_id
266
+ member_id = generate_id
267
+ @shop_site.trade_brandtoken({
268
+ :order_id => order_id,
269
+ :member_id => member_id
270
+ })
271
+
272
+ result = @service.delete_brandtoken({
273
+ :member_id => member_id,
274
+ :seq_mode => 0,
275
+ :token_seq => 0
276
+ })
277
+ result["TokenSeq"].nil?.should_not be true
278
+ end
279
+
280
+ it "got error if missing options", :vcr do
281
+ lambda {
282
+ result = @service.delete_brandtoken()
283
+ }.should raise_error('Required member_id, seq_mode, token_seq were not provided.')
284
+ end
285
+ end
286
+ end