gmo 0.2.4 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +5 -5
  2. data/.travis.yml +9 -4
  3. data/CHANGELOG.md +42 -1
  4. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_deposit_gets_data_about_a_deposit.yml +38 -0
  5. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  6. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_account_gets_data_about_an_account.yml +38 -0
  7. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_deposit_gets_data_about_a_deposit.yml +38 -0
  8. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  9. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_delete_account_gets_data_about_an_account.yml +38 -0
  10. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_account_gets_data_about_an_account.yml +38 -0
  11. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_balance_gets_data_about_balance.yml +38 -0
  12. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_deposit_gets_data_about_a_deposit.yml +38 -0
  13. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  14. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_update_account_gets_data_about_an_account.yml +38 -0
  15. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_brandtoken_gets_data_about_order.yml +108 -0
  16. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_cvs_cancel_gets_data_about_a_transaction.yml +63 -0
  17. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_brandtoken_gets_data_about_a_transaction.yml +38 -0
  18. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_linepay_gets_data_about_a_transaction.yml +36 -0
  19. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_pay_easy_gets_data_about_a_transaction.yml +36 -0
  20. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_gets_data_about_a_transaction.yml +73 -0
  21. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_parameter_contains_Japanese_characters_should_correctly_handle_Japanese.yml +73 -0
  22. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_doesn_t_require_card_info_if_token_is_present.yml +69 -0
  23. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_linepay_gets_data_about_a_transaction.yml +69 -0
  24. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_pay_easy_gets_data_about_a_transaction.yml +69 -0
  25. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_refund_tran_brandtoken_gets_data_about_a_transaction.yml +108 -0
  26. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_sales_tran_brandtoken_gets_data_about_a_transaction.yml +143 -0
  27. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_void_tran_brandtoken_gets_data_about_order.yml +108 -0
  28. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_exec_tran_brandtoken_got_data.yml +73 -0
  29. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_trade_brandtoken_got_data.yml +108 -0
  30. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_delete_brandtoken_gets_data_about_a_brandtoken.yml +73 -0
  31. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_save_card_doesn_t_require_card_info_if_token_is_present.yml +36 -0
  32. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_brandtoken_gets_data_about_a_brandtoken.yml +74 -0
  33. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_card_detail_by_member_id_gets_data_about_card_detail.yml +36 -0
  34. data/gmo.gemspec +2 -2
  35. data/lib/gmo.rb +6 -1
  36. data/lib/gmo/const.rb +2297 -3
  37. data/lib/gmo/errors.rb +22 -4
  38. data/lib/gmo/http_services.rb +5 -5
  39. data/lib/gmo/remittance_api.rb +331 -0
  40. data/lib/gmo/shop_and_site_api.rb +79 -5
  41. data/lib/gmo/shop_api.rb +282 -10
  42. data/lib/gmo/site_api.rb +77 -7
  43. data/lib/gmo/version.rb +2 -2
  44. data/spec/gmo/{error_spec.rb → errors_spec.rb} +11 -2
  45. data/spec/gmo/remittance_api_spec.rb +506 -0
  46. data/spec/gmo/shop_and_site_api_spec.rb +87 -7
  47. data/spec/gmo/shop_api_spec.rb +509 -99
  48. data/spec/gmo/site_api_spec.rb +120 -23
  49. data/spec/support/config.example.yml +8 -1
  50. data/spec/support/config.yml +8 -1
  51. data/spec/support/config_loader.rb +1 -1
  52. data/spec/support/vcr.rb +12 -3
  53. metadata +40 -9
@@ -8,17 +8,23 @@ describe "GMO::Payment::ShopAndSiteAPI" do
8
8
  :shop_pass => SPEC_CONF["shop_pass"],
9
9
  :site_id => SPEC_CONF["site_id"],
10
10
  :site_pass => SPEC_CONF["site_pass"],
11
- :host => SPEC_CONF["host"]
11
+ :host => SPEC_CONF["host"],
12
+ :locale => :ja
13
+
12
14
  })
13
15
  @shop_api ||= GMO::Payment::ShopAPI.new({
14
16
  :shop_id => SPEC_CONF["shop_id"],
15
17
  :shop_pass => SPEC_CONF["shop_pass"],
16
- :host => SPEC_CONF["host"]
18
+ :host => SPEC_CONF["host"],
19
+ :locale => :ja
20
+
17
21
  })
18
22
  @site_api ||= GMO::Payment::SiteAPI.new({
19
23
  :site_id => SPEC_CONF["site_id"],
20
24
  :site_pass => SPEC_CONF["site_pass"],
21
- :host => SPEC_CONF["host"]
25
+ :host => SPEC_CONF["host"],
26
+ :locale => :ja
27
+
22
28
  })
23
29
  end
24
30
 
@@ -79,9 +85,9 @@ describe "GMO::Payment::ShopAndSiteAPI" do
79
85
  :order_id => order_id,
80
86
  :member_id => member_id
81
87
  })
82
- result["CardSeq"].nil?.should_not be_true
83
- result["CardNo"].nil?.should_not be_true
84
- result["Forward"].nil?.should_not be_true
88
+ result["CardSeq"].nil?.should_not be_truthy
89
+ result["CardNo"].nil?.should_not be_truthy
90
+ result["Forward"].nil?.should_not be_truthy
85
91
  end
86
92
 
87
93
  it "got error if missing options", :vcr do
@@ -91,4 +97,78 @@ describe "GMO::Payment::ShopAndSiteAPI" do
91
97
  end
92
98
  end
93
99
 
94
- end
100
+ describe "#trade_brandtoken" do
101
+
102
+ it "got data", :vcr do
103
+ order_id = generate_id
104
+ result = @shop_api.entry_tran_brandtoken({
105
+ :order_id => order_id,
106
+ :job_cd => "AUTH",
107
+ :amount => 100
108
+ })
109
+ access_id = result["AccessID"]
110
+ access_pass = result["AccessPass"]
111
+ member_id = generate_id
112
+ result = @service.exec_tran_brandtoken({
113
+ :order_id => order_id,
114
+ :access_id => access_id,
115
+ :access_pass => access_pass,
116
+ :token_type => :apple_pay,
117
+ :token => 'base64encodedtoken',
118
+ :member_id => member_id
119
+ })
120
+ result = @service.trade_brandtoken({
121
+ :order_id => order_id,
122
+ :member_id => member_id
123
+ })
124
+ result["TokenSeq"].nil?.should_not be true
125
+ result["CardNoToken"].nil?.should_not be true
126
+ result["Forward"].nil?.should_not be true
127
+ end
128
+
129
+ it "got error if missing options", :vcr do
130
+ lambda {
131
+ result = @service.trade_brandtoken()
132
+ }.should raise_error('Required order_id, member_id were not provided.')
133
+ end
134
+ end
135
+
136
+ describe "#exec_tran_brandtoken" do
137
+
138
+ it "got data", :vcr do
139
+ order_id = generate_id
140
+ result = @shop_api.entry_tran_brandtoken({
141
+ :order_id => order_id,
142
+ :job_cd => "AUTH",
143
+ :amount => 100
144
+ })
145
+ access_id = result["AccessID"]
146
+ access_pass = result["AccessPass"]
147
+ member_id = generate_id
148
+ result = @service.exec_tran_brandtoken({
149
+ :order_id => order_id,
150
+ :access_id => access_id,
151
+ :access_pass => access_pass,
152
+ :token_type => :apple_pay,
153
+ :token => 'base64encodedtoken',
154
+ :member_id => member_id
155
+ })
156
+ result["Status"].nil?.should_not be true
157
+ result["OrderID"].nil?.should_not be true
158
+ result["Forward"].nil?.should_not be true
159
+ result["Approve"].nil?.should_not be true
160
+ result["TranID"].nil?.should_not be true
161
+ result["TranDate"].nil?.should_not be true
162
+ result["ClientField1"].nil?.should_not be true
163
+ result["ClientField2"].nil?.should_not be true
164
+ result["ClientField3"].nil?.should_not be true
165
+ end
166
+
167
+ it "got error if missing options", :vcr do
168
+ lambda {
169
+ result = @service.exec_tran_brandtoken()
170
+ }.should raise_error('Required access_id, access_pass, member_id, order_id were not provided.')
171
+ end
172
+ end
173
+
174
+ end
@@ -9,10 +9,19 @@ 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
+ :locale => :ja
19
+ })
12
20
  @service ||= GMO::Payment::ShopAPI.new({
13
21
  :shop_id => SPEC_CONF["shop_id"],
14
22
  :shop_pass => SPEC_CONF["shop_pass"],
15
- :host => SPEC_CONF["host"]
23
+ :host => SPEC_CONF["host"],
24
+ :locale => :ja
16
25
  })
17
26
  end
18
27
 
@@ -42,8 +51,8 @@ describe "GMO::Payment::ShopAPI" do
42
51
  :job_cd => "AUTH",
43
52
  :amount => 100
44
53
  })
45
- result["AccessID"].nil?.should_not be_true
46
- result["AccessPass"].nil?.should_not be_true
54
+ result["AccessID"].nil?.should_not be_truthy
55
+ result["AccessPass"].nil?.should_not be_truthy
47
56
  end
48
57
 
49
58
  it "got error if missing options", :vcr do
@@ -60,8 +69,8 @@ describe "GMO::Payment::ShopAPI" do
60
69
  :order_id => order_id,
61
70
  :amount => 100
62
71
  })
63
- result["AccessID"].nil?.should_not be_true
64
- result["AccessPass"].nil?.should_not be_true
72
+ result["AccessID"].nil?.should_not be_truthy
73
+ result["AccessPass"].nil?.should_not be_truthy
65
74
  end
66
75
 
67
76
  it "got error if missing options", :vcr do
@@ -71,6 +80,62 @@ describe "GMO::Payment::ShopAPI" do
71
80
  end
72
81
  end
73
82
 
83
+ describe "#entry_tran_pay_easy" do
84
+ it "gets data about a transaction", :vcr do
85
+ order_id = @order_id
86
+ result = @service.entry_tran_pay_easy({
87
+ :order_id => order_id,
88
+ :amount => 100
89
+ })
90
+ result["AccessID"].nil?.should_not be_truthy
91
+ result["AccessPass"].nil?.should_not be_truthy
92
+ end
93
+
94
+ it "got error if missing options", :vcr do
95
+ lambda {
96
+ result = @service.entry_tran_pay_easy()
97
+ }.should raise_error("Required order_id, amount were not provided.")
98
+ end
99
+ end
100
+
101
+ describe "#entry_tran_linepay" do
102
+ it "gets data about a transaction", :vcr do
103
+ order_id = @order_id
104
+ result = @service.entry_tran_linepay({
105
+ :order_id => order_id,
106
+ :job_cd => 'CAPTURE',
107
+ :amount => 100
108
+ })
109
+ result["AccessID"].nil?.should_not be_truthy
110
+ result["AccessPass"].nil?.should_not be_truthy
111
+ end
112
+
113
+ it "got error if missing options", :vcr do
114
+ lambda {
115
+ result = @service.entry_tran_linepay()
116
+ }.should raise_error("Required order_id, job_cd, amount were not provided.")
117
+ end
118
+ end
119
+
120
+ describe "#entry_tran_brandtoken" do
121
+ it "gets data about a transaction", :vcr do
122
+ order_id = @order_id
123
+ result = @service.entry_tran_brandtoken({
124
+ :order_id => order_id,
125
+ :job_cd => "AUTH",
126
+ :amount => 100
127
+ })
128
+ result["AccessID"].nil?.should_not be true
129
+ result["AccessPass"].nil?.should_not be true
130
+ end
131
+
132
+ it "got error if missing options", :vcr do
133
+ lambda {
134
+ result = @service.entry_tran_brandtoken()
135
+ }.should raise_error('Required order_id, job_cd, amount were not provided.')
136
+ end
137
+ end
138
+
74
139
  describe "#exec_tran" do
75
140
  it "gets data about a transaction", :vcr do
76
141
  order_id = generate_id
@@ -92,18 +157,18 @@ describe "GMO::Payment::ShopAPI" do
92
157
  :expire => "1405",
93
158
  :client_field_1 => client_field_1
94
159
  })
95
- result["ACS"].nil?.should_not be_true
96
- result["OrderID"].nil?.should_not be_true
97
- result["Forward"].nil?.should_not be_true
98
- result["Method"].nil?.should_not be_true
99
- result["PayTimes"].nil?.should_not be_true
100
- result["Approve"].nil?.should_not be_true
101
- result["TranID"].nil?.should_not be_true
102
- result["TranDate"].nil?.should_not be_true
103
- result["CheckString"].nil?.should_not be_true
104
- result["ClientField1"].nil?.should_not be_true
105
- (result["ClientField1"] == client_field_1).should be_true
106
- result["ClientField3"].nil?.should_not be_true
160
+ result["ACS"].nil?.should_not be_truthy
161
+ result["OrderID"].nil?.should_not be_truthy
162
+ result["Forward"].nil?.should_not be_truthy
163
+ result["Method"].nil?.should_not be_truthy
164
+ result["PayTimes"].nil?.should_not be_truthy
165
+ result["Approve"].nil?.should_not be_truthy
166
+ result["TranID"].nil?.should_not be_truthy
167
+ result["TranDate"].nil?.should_not be_truthy
168
+ result["CheckString"].nil?.should_not be_truthy
169
+ result["ClientField1"].nil?.should_not be_truthy
170
+ (result["ClientField1"] == client_field_1).should be_truthy
171
+ result["ClientField3"].nil?.should_not be_truthy
107
172
  end
108
173
 
109
174
  it "got error if missing options", :vcr do
@@ -112,6 +177,27 @@ describe "GMO::Payment::ShopAPI" do
112
177
  }.should raise_error("Required access_id, access_pass, order_id, card_no, expire were not provided.")
113
178
  end
114
179
 
180
+ it "doesn't require card info if token is present", :vcr do
181
+ lambda {
182
+ order_id = generate_id
183
+ result = @service.entry_tran({
184
+ :order_id => order_id,
185
+ :job_cd => "AUTH",
186
+ :amount => 100
187
+ })
188
+ access_id = result["AccessID"]
189
+ access_pass = result["AccessPass"]
190
+ result = @service.exec_tran({
191
+ :order_id => order_id,
192
+ :access_id => access_id,
193
+ :access_pass => access_pass,
194
+ :method => 1,
195
+ :pay_times => 1,
196
+ :token => "onetimetokenfromgmo"
197
+ })
198
+ }.should_not raise_error("Required card_no, expire were not provided.")
199
+ end
200
+
115
201
  context "parameter contains Japanese characters" do
116
202
  before { require "kconv" unless defined?(Kconv) }
117
203
 
@@ -135,19 +221,19 @@ describe "GMO::Payment::ShopAPI" do
135
221
  :expire => "1405",
136
222
  :client_field_1 => client_field_1
137
223
  })
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
224
+ result["ACS"].nil?.should_not be_truthy
225
+ result["OrderID"].nil?.should_not be_truthy
226
+ result["Forward"].nil?.should_not be_truthy
227
+ result["Method"].nil?.should_not be_truthy
228
+ result["PayTimes"].nil?.should_not be_truthy
229
+ result["Approve"].nil?.should_not be_truthy
230
+ result["TranID"].nil?.should_not be_truthy
231
+ result["TranDate"].nil?.should_not be_truthy
232
+ result["CheckString"].nil?.should_not be_truthy
233
+ result["ClientField1"].nil?.should_not be_truthy
234
+ (result["ClientField1"] == client_field_1).should be_truthy
235
+ (result["ClientField1"].encoding.to_s == "UTF-8").should be_truthy
236
+ result["ClientField3"].nil?.should_not be_truthy
151
237
  end
152
238
  end
153
239
  end
@@ -175,22 +261,161 @@ describe "GMO::Payment::ShopAPI" do
175
261
  :receipts_disp_13 => '00:00-00:15',
176
262
  :client_field_1 => client_field_1
177
263
  })
178
- result["OrderID"].nil?.should_not be_true
179
- result["Convenience"].nil?.should_not be_true
180
- result["ConfNo"].nil?.should_not be_true
181
- result["ReceiptNo"].nil?.should_not be_true
182
- result["PaymentTerm"].nil?.should_not be_true
183
- result["TranDate"].nil?.should_not be_true
184
- result["CheckString"].nil?.should_not be_true
185
- result["ClientField1"].nil?.should_not be_true
186
- (result["ClientField1"] == client_field_1).should be_true
187
- result["ClientField3"].nil?.should_not be_true
264
+ result["OrderID"].nil?.should_not be_truthy
265
+ result["Convenience"].nil?.should_not be_truthy
266
+ result["ConfNo"].nil?.should_not be_truthy
267
+ result["ReceiptNo"].nil?.should_not be_truthy
268
+ result["PaymentTerm"].nil?.should_not be_truthy
269
+ result["TranDate"].nil?.should_not be_truthy
270
+ result["CheckString"].nil?.should_not be_truthy
271
+ result["ClientField1"].nil?.should_not be_truthy
272
+ (result["ClientField1"] == client_field_1).should be_truthy
273
+ result["ClientField3"].nil?.should_not be_truthy
188
274
  end
189
275
 
190
276
  it "got error if missing options", :vcr do
191
277
  lambda {
192
278
  result = @service.exec_tran_cvs()
193
- }.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.")
279
+ }.should raise_error(ArgumentError, "Required access_id, access_pass, order_id, convenience, customer_name, customer_kana, tel_no, receipts_disp_11, receipts_disp_12, receipts_disp_13 were not provided.")
280
+ end
281
+ end
282
+
283
+ describe "#exec_tran_pay_easy" do
284
+ it "gets data about a transaction", :vcr do
285
+ order_id = generate_id
286
+ result = @service.entry_tran_pay_easy({
287
+ :order_id => order_id,
288
+ :amount => 100
289
+ })
290
+ access_id = result["AccessID"]
291
+ access_pass = result["AccessPass"]
292
+ result = @service.exec_tran_pay_easy({
293
+ :order_id => order_id,
294
+ :access_id => access_id,
295
+ :access_pass => access_pass,
296
+ :customer_name => 'ペイ太郎',
297
+ :customer_kana => 'ペイタロウ',
298
+ :tel_no => '0300000001',
299
+ :receipts_disp_11 => 'RSpec Helpdesk',
300
+ :receipts_disp_12 => '0300000001',
301
+ :receipts_disp_13 => '00:00-00:15'
302
+ })
303
+ result["OrderID"].nil?.should_not be_truthy
304
+ result["CustID"].nil?.should_not be_truthy
305
+ result["BkCode"].nil?.should_not be_truthy
306
+ result["ConfNo"].nil?.should_not be_truthy
307
+ result["EncryptReceiptNo"].nil?.should_not be_truthy
308
+ result["PaymentTerm"].nil?.should_not be_truthy
309
+ result["TranDate"].nil?.should_not be_truthy
310
+ result["CheckString"].nil?.should_not be_truthy
311
+ end
312
+
313
+ it "got error if missing options", :vcr do
314
+ lambda {
315
+ result = @service.exec_tran_pay_easy()
316
+ }.should raise_error("Required access_id, access_pass, order_id, customer_name, customer_kana, tel_no, receipts_disp_11, receipts_disp_12, receipts_disp_13 were not provided.")
317
+ end
318
+ end
319
+
320
+ describe "#exec_tran_linepay" do
321
+ it "gets data about a transaction", :vcr do
322
+ order_id = generate_id
323
+ result = @service.entry_tran_linepay({
324
+ :order_id => order_id,
325
+ :job_cd => 'CAPTURE',
326
+ :amount => 100
327
+ })
328
+ access_id = result["AccessID"]
329
+ access_pass = result["AccessPass"]
330
+ result = @service.exec_tran_linepay({
331
+ :order_id => order_id,
332
+ :access_id => access_id,
333
+ :access_pass => access_pass,
334
+ :ret_url => 'https://example.com/path/to/return/success',
335
+ :error_rcv_url => 'https://example.com/path/to/return/failure',
336
+ :product_name => '購入する商品名'
337
+ })
338
+ result["Start"].nil?.should_not be_truthy
339
+ result["AccessID"].nil?.should_not be_truthy
340
+ result["Token"].nil?.should_not be_truthy
341
+ result["StartURL"].nil?.should_not be_truthy
342
+ end
343
+
344
+ it "got error if missing options", :vcr do
345
+ lambda {
346
+ result = @service.exec_tran_linepay()
347
+ }.should raise_error("Required access_id, access_pass, order_id, ret_url, error_rcv_url, product_name were not provided.")
348
+ end
349
+ end
350
+
351
+ describe "#exec_tran_brandtoken" do
352
+ it "gets data about a transaction", :vcr do
353
+ order_id = generate_id
354
+ client_field_1 = "client_field1"
355
+ result = @service.entry_tran_brandtoken({
356
+ :order_id => order_id,
357
+ :job_cd => "AUTH",
358
+ :amount => 100
359
+ })
360
+ access_id = result["AccessID"]
361
+ access_pass = result["AccessPass"]
362
+ result = @service.exec_tran_brandtoken({
363
+ :order_id => order_id,
364
+ :access_id => access_id,
365
+ :access_pass => access_pass,
366
+ :token_type => :apple_pay,
367
+ :token => 'base64encodedtoken',
368
+ :client_field_1 => client_field_1
369
+ })
370
+ result["Status"].nil?.should_not be true
371
+ result["OrderID"].nil?.should_not be true
372
+ result["Forward"].nil?.should_not be true
373
+ result["Approve"].nil?.should_not be true
374
+ result["TranID"].nil?.should_not be true
375
+ result["TranDate"].nil?.should_not be true
376
+ (result["ClientField1"] == client_field_1).should be true
377
+ result["ClientField2"].nil?.should_not be true
378
+ result["ClientField3"].nil?.should_not be true
379
+ end
380
+
381
+ it "got error if missing options", :vcr do
382
+ lambda {
383
+ result = @service.exec_tran_brandtoken()
384
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
385
+ end
386
+
387
+ context "parameter contains Japanese characters" do
388
+ before { require "kconv" unless defined?(Kconv) }
389
+
390
+ it "should correctly handle Japanese", :vcr do
391
+ order_id = generate_id
392
+ client_field_1 = "〜−¢£¬−‖①ほげほげhogehoge"
393
+ result = @service.entry_tran_brandtoken({
394
+ :order_id => order_id,
395
+ :job_cd => "AUTH",
396
+ :amount => 100
397
+ })
398
+ access_id = result["AccessID"]
399
+ access_pass = result["AccessPass"]
400
+ result = @service.exec_tran_brandtoken({
401
+ :order_id => order_id,
402
+ :access_id => access_id,
403
+ :access_pass => access_pass,
404
+ :token_type => :apple_pay,
405
+ :token => 'base64encodedtoken',
406
+ :client_field_1 => client_field_1
407
+ })
408
+ result["Status"].nil?.should_not be true
409
+ result["OrderID"].nil?.should_not be true
410
+ result["Forward"].nil?.should_not be true
411
+ result["Approve"].nil?.should_not be true
412
+ result["TranID"].nil?.should_not be true
413
+ result["TranDate"].nil?.should_not be true
414
+ (result["ClientField1"] == client_field_1).should be true
415
+ (result["ClientField1"].encoding.to_s == "UTF-8").should be true
416
+ result["ClientField2"].nil?.should_not be true
417
+ result["ClientField3"].nil?.should_not be true
418
+ end
194
419
  end
195
420
  end
196
421
 
@@ -219,13 +444,13 @@ describe "GMO::Payment::ShopAPI" do
219
444
  :job_cd => "RETURN",
220
445
  :amount => 100
221
446
  })
222
- result["AccessID"].nil?.should_not be_true
223
- result["AccessPass"].nil?.should_not be_true
224
- result["Forward"].nil?.should_not be_true
225
- result["Approve"].nil?.should_not be_true
226
- result["AccessPass"].nil?.should_not be_true
227
- result["TranID"].nil?.should_not be_true
228
- result["TranDate"].nil?.should_not be_true
447
+ result["AccessID"].nil?.should_not be_truthy
448
+ result["AccessPass"].nil?.should_not be_truthy
449
+ result["Forward"].nil?.should_not be_truthy
450
+ result["Approve"].nil?.should_not be_truthy
451
+ result["AccessPass"].nil?.should_not be_truthy
452
+ result["TranID"].nil?.should_not be_truthy
453
+ result["TranDate"].nil?.should_not be_truthy
229
454
  end
230
455
 
231
456
  it "change order auth to sale", :vcr do
@@ -252,13 +477,13 @@ describe "GMO::Payment::ShopAPI" do
252
477
  :job_cd => "SALES",
253
478
  :amount => 100
254
479
  })
255
- result["AccessID"].nil?.should_not be_true
256
- result["AccessPass"].nil?.should_not be_true
257
- result["Forward"].nil?.should_not be_true
258
- result["Approve"].nil?.should_not be_true
259
- result["AccessPass"].nil?.should_not be_true
260
- result["TranID"].nil?.should_not be_true
261
- result["TranDate"].nil?.should_not be_true
480
+ result["AccessID"].nil?.should_not be_truthy
481
+ result["AccessPass"].nil?.should_not be_truthy
482
+ result["Forward"].nil?.should_not be_truthy
483
+ result["Approve"].nil?.should_not be_truthy
484
+ result["AccessPass"].nil?.should_not be_truthy
485
+ result["TranID"].nil?.should_not be_truthy
486
+ result["TranDate"].nil?.should_not be_truthy
262
487
  end
263
488
 
264
489
  it "got error if missing options", :vcr do
@@ -293,12 +518,12 @@ describe "GMO::Payment::ShopAPI" do
293
518
  :job_cd => "AUTH",
294
519
  :amount => 1000
295
520
  })
296
- result["AccessID"].nil?.should_not be_true
297
- result["AccessPass"].nil?.should_not be_true
298
- result["Forward"].nil?.should_not be_true
299
- result["Approve"].nil?.should_not be_true
300
- result["TranID"].nil?.should_not be_true
301
- result["TranDate"].nil?.should_not be_true
521
+ result["AccessID"].nil?.should_not be_truthy
522
+ result["AccessPass"].nil?.should_not be_truthy
523
+ result["Forward"].nil?.should_not be_truthy
524
+ result["Approve"].nil?.should_not be_truthy
525
+ result["TranID"].nil?.should_not be_truthy
526
+ result["TranDate"].nil?.should_not be_truthy
302
527
  end
303
528
 
304
529
  it "got error if missing options", :vcr do
@@ -308,6 +533,192 @@ describe "GMO::Payment::ShopAPI" do
308
533
  end
309
534
  end
310
535
 
536
+ describe "#change_tran_brandtoken" do
537
+ it "gets data about order", :vcr do
538
+ order_id = generate_id
539
+ result = @service.entry_tran_brandtoken({
540
+ :order_id => order_id,
541
+ :job_cd => "AUTH",
542
+ :amount => 100
543
+ })
544
+ access_id = result["AccessID"]
545
+ access_pass = result["AccessPass"]
546
+ @service.exec_tran_brandtoken({
547
+ :order_id => order_id,
548
+ :access_id => access_id,
549
+ :access_pass => access_pass,
550
+ :token_type => :apple_pay,
551
+ :token => 'base64encodedtoken'
552
+ })
553
+ result = @service.change_tran_brandtoken({
554
+ :order_id => order_id,
555
+ :access_id => access_id,
556
+ :access_pass => access_pass,
557
+ :job_cd => "CAPTURE",
558
+ :amount => 1500
559
+ })
560
+ result["AccessID"].nil?.should_not be true
561
+ result["AccessPass"].nil?.should_not be true
562
+ result["Status"].nil?.should_not be true
563
+ result["Forward"].nil?.should_not be true
564
+ result["Approve"].nil?.should_not be true
565
+ result["TranID"].nil?.should_not be true
566
+ result["TranDate"].nil?.should_not be true
567
+ end
568
+
569
+ it "got error if missing options", :vcr do
570
+ lambda {
571
+ result = @service.change_tran_brandtoken()
572
+ }.should raise_error('Required access_id, access_pass, order_id, job_cd, amount were not provided.')
573
+ end
574
+ end
575
+
576
+ describe "#void_tran_brandtoken" do
577
+ it "gets data about order", :vcr do
578
+ order_id = generate_id
579
+ result = @service.entry_tran_brandtoken({
580
+ :order_id => order_id,
581
+ :job_cd => "AUTH",
582
+ :amount => 100
583
+ })
584
+ access_id = result["AccessID"]
585
+ access_pass = result["AccessPass"]
586
+ @service.exec_tran_brandtoken({
587
+ :order_id => order_id,
588
+ :access_id => access_id,
589
+ :access_pass => access_pass,
590
+ :token_type => :apple_pay,
591
+ :token => 'base64encodedtoken'
592
+ })
593
+ result = @service.void_tran_brandtoken({
594
+ :order_id => order_id,
595
+ :access_id => access_id,
596
+ :access_pass => access_pass
597
+ })
598
+ result["AccessID"].nil?.should_not be true
599
+ result["AccessPass"].nil?.should_not be true
600
+ result["Status"].nil?.should_not be true
601
+ result["Forward"].nil?.should_not be true
602
+ result["Approve"].nil?.should_not be true
603
+ result["TranID"].nil?.should_not be true
604
+ result["TranDate"].nil?.should_not be true
605
+ end
606
+
607
+ it "got error if missing options", :vcr do
608
+ lambda {
609
+ result = @service.void_tran_brandtoken()
610
+ }.should raise_error('Required access_id, access_pass, order_id were not provided.')
611
+ end
612
+ end
613
+
614
+ describe "#sales_tran_brandtoken" do
615
+ it "gets data about a transaction", :vcr do
616
+ order_id = generate_id
617
+ result = @service.entry_tran_brandtoken({
618
+ :order_id => order_id,
619
+ :job_cd => "AUTH",
620
+ :amount => 1000
621
+ })
622
+ access_id = result["AccessID"]
623
+ access_pass = result["AccessPass"]
624
+ @service.exec_tran_brandtoken({
625
+ :order_id => order_id,
626
+ :access_id => access_id,
627
+ :access_pass => access_pass,
628
+ :token_type => :apple_pay,
629
+ :token => 'base64encodedtoken'
630
+ })
631
+ member_id = generate_id
632
+ @shop_site.trade_brandtoken({
633
+ :member_id => member_id,
634
+ :order_id => order_id
635
+ })
636
+ result = @service.sales_tran_brandtoken({
637
+ :access_id => access_id,
638
+ :access_pass => access_pass,
639
+ :order_id => order_id,
640
+ :amount => 1000
641
+ })
642
+ result["AccessID"].nil?.should_not be true
643
+ result["AccessPass"].nil?.should_not be true
644
+ result["Status"].nil?.should_not be true
645
+ result["Forward"].nil?.should_not be true
646
+ result["Approve"].nil?.should_not be true
647
+ result["TranID"].nil?.should_not be true
648
+ result["TranDate"].nil?.should_not be true
649
+ end
650
+
651
+ it "got error if missing options", :vcr do
652
+ lambda {
653
+ result = @service.sales_tran_brandtoken()
654
+ }.should raise_error('Required access_id, access_pass, order_id, amount were not provided.')
655
+ end
656
+ end
657
+
658
+ describe "#refund_tran_brandtoken" do
659
+ it "gets data about a transaction", :vcr do
660
+ order_id = generate_id
661
+ result = @service.entry_tran_brandtoken({
662
+ :order_id => order_id,
663
+ :job_cd => "CAPTURE",
664
+ :amount => 1000
665
+ })
666
+ access_id = result["AccessID"]
667
+ access_pass = result["AccessPass"]
668
+ @service.exec_tran_brandtoken({
669
+ :order_id => order_id,
670
+ :access_id => access_id,
671
+ :access_pass => access_pass,
672
+ :token_type => :apple_pay,
673
+ :token => 'base64encodedtoken'
674
+ })
675
+ result = @service.refund_tran_brandtoken({
676
+ :access_id => access_id,
677
+ :access_pass => access_pass,
678
+ :order_id => order_id,
679
+ :amount => 1000
680
+ })
681
+ result["AccessID"].nil?.should_not be true
682
+ result["AccessPass"].nil?.should_not be true
683
+ result["Status"].nil?.should_not be true
684
+ result["Forward"].nil?.should_not be true
685
+ result["Approve"].nil?.should_not be true
686
+ result["TranID"].nil?.should_not be true
687
+ result["TranDate"].nil?.should_not be true
688
+ end
689
+
690
+ it "got error if missing options", :vcr do
691
+ lambda {
692
+ result = @service.refund_tran_brandtoken()
693
+ }.should raise_error('Required access_id, access_pass, order_id, amount were not provided.')
694
+ end
695
+ end
696
+
697
+ describe "#cvs_cancel" do
698
+ it "gets data about a transaction", :vcr do
699
+ order_id = generate_id
700
+ result = @service.entry_tran_cvs({
701
+ :order_id => order_id,
702
+ :amount => 100
703
+ })
704
+ access_id = result["AccessID"]
705
+ access_pass = result["AccessPass"]
706
+ result = @service.cvs_cancel({
707
+ :order_id => order_id,
708
+ :access_id => access_id,
709
+ :access_pass => access_pass,
710
+ })
711
+
712
+ result["OrderID"].nil?.should_not be_truthy
713
+ result["Status"].nil?.should_not be_truthy
714
+ end
715
+
716
+ it "got error if missing options", :vcr do
717
+ lambda {
718
+ result = @service.cvs_cancel()
719
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
720
+ end
721
+ end
311
722
 
312
723
  describe "#search_trade" do
313
724
  it "gets data about order", :vcr do
@@ -315,24 +726,24 @@ describe "GMO::Payment::ShopAPI" do
315
726
  result = @service.search_trade({
316
727
  :order_id => order_id
317
728
  })
318
- result["OrderID"].nil?.should_not be_true
319
- result["Status"].nil?.should_not be_true
320
- result["ProcessDate"].nil?.should_not be_true
321
- result["JobCd"].nil?.should_not be_true
322
- result["AccessID"].nil?.should_not be_true
323
- result["AccessPass"].nil?.should_not be_true
324
- result["ItemCode"].nil?.should_not be_true
325
- result["Amount"].nil?.should_not be_true
326
- result["Tax"].nil?.should_not be_true
327
- result["SiteID"].nil?.should_not be_true
328
- result["MemberID"].nil?.should_not be_true
329
- result["CardNo"].nil?.should_not be_true
330
- result["Expire"].nil?.should_not be_true
331
- result["Method"].nil?.should_not be_true
332
- result["PayTimes"].nil?.should_not be_true
333
- result["Forward"].nil?.should_not be_true
334
- result["TranID"].nil?.should_not be_true
335
- result["Approve"].nil?.should_not be_true
729
+ result["OrderID"].nil?.should_not be_truthy
730
+ result["Status"].nil?.should_not be_truthy
731
+ result["ProcessDate"].nil?.should_not be_truthy
732
+ result["JobCd"].nil?.should_not be_truthy
733
+ result["AccessID"].nil?.should_not be_truthy
734
+ result["AccessPass"].nil?.should_not be_truthy
735
+ result["ItemCode"].nil?.should_not be_truthy
736
+ result["Amount"].nil?.should_not be_truthy
737
+ result["Tax"].nil?.should_not be_truthy
738
+ result["SiteID"].nil?.should_not be_truthy
739
+ result["MemberID"].nil?.should_not be_truthy
740
+ result["CardNo"].nil?.should_not be_truthy
741
+ result["Expire"].nil?.should_not be_truthy
742
+ result["Method"].nil?.should_not be_truthy
743
+ result["PayTimes"].nil?.should_not be_truthy
744
+ result["Forward"].nil?.should_not be_truthy
745
+ result["TranID"].nil?.should_not be_truthy
746
+ result["Approve"].nil?.should_not be_truthy
336
747
  end
337
748
 
338
749
  it "got error if missing options", :vcr do
@@ -344,30 +755,29 @@ describe "GMO::Payment::ShopAPI" do
344
755
 
345
756
  describe "#search_trade_multi" do
346
757
  it "gets data about order", :vcr do
347
- client_field_1 = "client_field1"
348
758
  result = @service.search_trade_multi({
349
759
  :order_id => @order_id,
350
760
  :pay_type => "0"
351
761
  })
352
- result["Status"].nil?.should_not be_true
353
- result["ProcessDate"].nil?.should_not be_true
354
- result["JobCd"].nil?.should_not be_true
355
- result["AccessID"].nil?.should_not be_true
356
- result["AccessPass"].nil?.should_not be_true
357
- result["ItemCode"].nil?.should_not be_true
358
- result["Amount"].nil?.should_not be_true
359
- result["Tax"].nil?.should_not be_true
360
- result["SiteID"].nil?.should_not be_true
361
- result["MemberID"].nil?.should_not be_true
362
- result["CardNo"].nil?.should_not be_true
363
- result["Expire"].nil?.should_not be_true
364
- result["Method"].nil?.should_not be_true
365
- result["PayTimes"].nil?.should_not be_true
366
- result["Forward"].nil?.should_not be_true
367
- result["TranID"].nil?.should_not be_true
368
- result["Approve"].nil?.should_not be_true
369
- result["PayType"].nil?.should_not be_true
370
- result["PaymentTerm"].nil?.should_not be_true
762
+ result["Status"].nil?.should_not be_truthy
763
+ result["ProcessDate"].nil?.should_not be_truthy
764
+ result["JobCd"].nil?.should_not be_truthy
765
+ result["AccessID"].nil?.should_not be_truthy
766
+ result["AccessPass"].nil?.should_not be_truthy
767
+ result["ItemCode"].nil?.should_not be_truthy
768
+ result["Amount"].nil?.should_not be_truthy
769
+ result["Tax"].nil?.should_not be_truthy
770
+ result["SiteID"].nil?.should_not be_truthy
771
+ result["MemberID"].nil?.should_not be_truthy
772
+ result["CardNo"].nil?.should_not be_truthy
773
+ result["Expire"].nil?.should_not be_truthy
774
+ result["Method"].nil?.should_not be_truthy
775
+ result["PayTimes"].nil?.should_not be_truthy
776
+ result["Forward"].nil?.should_not be_truthy
777
+ result["TranID"].nil?.should_not be_truthy
778
+ result["Approve"].nil?.should_not be_truthy
779
+ result["PayType"].nil?.should_not be_truthy
780
+ result["PaymentTerm"].nil?.should_not be_truthy
371
781
  end
372
782
 
373
783
  it "got error if missing options", :vcr do