gmo 0.2.6 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +1 -0
  3. data/.travis.yml +5 -5
  4. data/CHANGELOG.md +43 -1
  5. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_deposit_gets_data_about_a_deposit.yml +38 -0
  6. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  7. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_account_gets_data_about_an_account.yml +38 -0
  8. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_deposit_gets_data_about_a_deposit.yml +38 -0
  9. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  10. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_delete_account_gets_data_about_an_account.yml +38 -0
  11. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_account_gets_data_about_an_account.yml +38 -0
  12. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_balance_gets_data_about_balance.yml +38 -0
  13. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_deposit_gets_data_about_a_deposit.yml +38 -0
  14. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_search_mail_deposit_gets_data_about_a_mail_deposit.yml +38 -0
  15. data/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_update_account_gets_data_about_an_account.yml +38 -0
  16. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_brandtoken_gets_data_about_order.yml +108 -0
  17. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_cvs_cancel_gets_data_about_a_transaction.yml +63 -0
  18. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_brandtoken_gets_data_about_a_transaction.yml +38 -0
  19. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_docomo_gets_data_about_a_transaction.yml +35 -0
  20. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_linepay_gets_data_about_a_transaction.yml +36 -0
  21. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_rakuten_id_gets_data_about_a_transaction.yml +35 -0
  22. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_gets_data_about_a_transaction.yml +73 -0
  23. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_brandtoken_parameter_contains_Japanese_characters_should_correctly_handle_Japanese.yml +73 -0
  24. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_docomo_gets_data_about_a_transaction.yml +67 -0
  25. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_doesn_t_require_card_info_if_token_is_present.yml +69 -0
  26. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_linepay_gets_data_about_a_transaction.yml +69 -0
  27. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_rakuten_id_gets_data_about_a_transaction.yml +67 -0
  28. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_refund_tran_brandtoken_gets_data_about_a_transaction.yml +108 -0
  29. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_sales_tran_brandtoken_gets_data_about_a_transaction.yml +143 -0
  30. data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_void_tran_brandtoken_gets_data_about_order.yml +108 -0
  31. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_exec_tran_brandtoken_got_data.yml +73 -0
  32. data/fixtures/vcr_cassettes/GMO_Payment_ShopAndSiteAPI/_trade_brandtoken_got_data.yml +108 -0
  33. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_delete_brandtoken_gets_data_about_a_brandtoken.yml +73 -0
  34. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_save_card_doesn_t_require_card_info_if_token_is_present.yml +36 -0
  35. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_brandtoken_gets_data_about_a_brandtoken.yml +74 -0
  36. data/fixtures/vcr_cassettes/GMO_Payment_SiteAPI/_search_card_detail_by_member_id_gets_data_about_card_detail.yml +36 -0
  37. data/gmo.gemspec +1 -1
  38. data/lib/gmo.rb +6 -1
  39. data/lib/gmo/const.rb +2509 -3
  40. data/lib/gmo/errors.rb +22 -4
  41. data/lib/gmo/remittance_api.rb +331 -0
  42. data/lib/gmo/shop_and_site_api.rb +77 -2
  43. data/lib/gmo/shop_api.rb +329 -8
  44. data/lib/gmo/site_api.rb +75 -4
  45. data/lib/gmo/version.rb +2 -2
  46. data/spec/gmo/{error_spec.rb → errors_spec.rb} +11 -2
  47. data/spec/gmo/remittance_api_spec.rb +506 -0
  48. data/spec/gmo/shop_and_site_api_spec.rb +87 -7
  49. data/spec/gmo/shop_api_spec.rb +566 -109
  50. data/spec/gmo/site_api_spec.rb +120 -23
  51. data/spec/support/config.example.yml +8 -1
  52. data/spec/support/config.yml +8 -1
  53. data/spec/support/config_loader.rb +1 -1
  54. data/spec/support/vcr.rb +12 -3
  55. metadata +44 -11
@@ -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
@@ -78,8 +87,8 @@ describe "GMO::Payment::ShopAPI" do
78
87
  :order_id => order_id,
79
88
  :amount => 100
80
89
  })
81
- result["AccessID"].nil?.should_not be_true
82
- result["AccessPass"].nil?.should_not be_true
90
+ result["AccessID"].nil?.should_not be_truthy
91
+ result["AccessPass"].nil?.should_not be_truthy
83
92
  end
84
93
 
85
94
  it "got error if missing options", :vcr do
@@ -89,6 +98,82 @@ describe "GMO::Payment::ShopAPI" do
89
98
  end
90
99
  end
91
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
+
139
+ describe "#entry_tran_rakuten_id" do
140
+ it "gets data about a transaction", :vcr do
141
+ order_id = @order_id
142
+ result = @service.entry_tran_rakuten_id({
143
+ :order_id => order_id,
144
+ :job_cd => "AUTH",
145
+ :amount => 100
146
+ })
147
+ result["AccessID"].nil?.should_not be true
148
+ result["AccessPass"].nil?.should_not be true
149
+ end
150
+
151
+ it "got error if missing options", :vcr do
152
+ lambda {
153
+ result = @service.entry_tran_rakuten_id()
154
+ }.should raise_error('Required order_id, job_cd, amount were not provided.')
155
+ end
156
+ end
157
+
158
+ describe "#entry_tran_docomo" do
159
+ it "gets data about a transaction", :vcr do
160
+ order_id = @order_id
161
+ result = @service.entry_tran_docomo({
162
+ :order_id => order_id,
163
+ :job_cd => "AUTH",
164
+ :amount => 100
165
+ })
166
+ result["AccessID"].nil?.should_not be true
167
+ result["AccessPass"].nil?.should_not be true
168
+ end
169
+
170
+ it "got error if missing options", :vcr do
171
+ lambda {
172
+ result = @service.entry_tran_docomo()
173
+ }.should raise_error('Required order_id, job_cd, amount were not provided.')
174
+ end
175
+ end
176
+
92
177
  describe "#exec_tran" do
93
178
  it "gets data about a transaction", :vcr do
94
179
  order_id = generate_id
@@ -110,18 +195,18 @@ describe "GMO::Payment::ShopAPI" do
110
195
  :expire => "1405",
111
196
  :client_field_1 => client_field_1
112
197
  })
113
- result["ACS"].nil?.should_not be_true
114
- result["OrderID"].nil?.should_not be_true
115
- result["Forward"].nil?.should_not be_true
116
- result["Method"].nil?.should_not be_true
117
- result["PayTimes"].nil?.should_not be_true
118
- result["Approve"].nil?.should_not be_true
119
- result["TranID"].nil?.should_not be_true
120
- result["TranDate"].nil?.should_not be_true
121
- result["CheckString"].nil?.should_not be_true
122
- result["ClientField1"].nil?.should_not be_true
123
- (result["ClientField1"] == client_field_1).should be_true
124
- result["ClientField3"].nil?.should_not be_true
198
+ result["ACS"].nil?.should_not be_truthy
199
+ result["OrderID"].nil?.should_not be_truthy
200
+ result["Forward"].nil?.should_not be_truthy
201
+ result["Method"].nil?.should_not be_truthy
202
+ result["PayTimes"].nil?.should_not be_truthy
203
+ result["Approve"].nil?.should_not be_truthy
204
+ result["TranID"].nil?.should_not be_truthy
205
+ result["TranDate"].nil?.should_not be_truthy
206
+ result["CheckString"].nil?.should_not be_truthy
207
+ result["ClientField1"].nil?.should_not be_truthy
208
+ (result["ClientField1"] == client_field_1).should be_truthy
209
+ result["ClientField3"].nil?.should_not be_truthy
125
210
  end
126
211
 
127
212
  it "got error if missing options", :vcr do
@@ -130,6 +215,27 @@ describe "GMO::Payment::ShopAPI" do
130
215
  }.should raise_error("Required access_id, access_pass, order_id, card_no, expire were not provided.")
131
216
  end
132
217
 
218
+ it "doesn't require card info if token is present", :vcr do
219
+ lambda {
220
+ order_id = generate_id
221
+ result = @service.entry_tran({
222
+ :order_id => order_id,
223
+ :job_cd => "AUTH",
224
+ :amount => 100
225
+ })
226
+ access_id = result["AccessID"]
227
+ access_pass = result["AccessPass"]
228
+ result = @service.exec_tran({
229
+ :order_id => order_id,
230
+ :access_id => access_id,
231
+ :access_pass => access_pass,
232
+ :method => 1,
233
+ :pay_times => 1,
234
+ :token => "onetimetokenfromgmo"
235
+ })
236
+ }.should_not raise_error("Required card_no, expire were not provided.")
237
+ end
238
+
133
239
  context "parameter contains Japanese characters" do
134
240
  before { require "kconv" unless defined?(Kconv) }
135
241
 
@@ -153,19 +259,19 @@ describe "GMO::Payment::ShopAPI" do
153
259
  :expire => "1405",
154
260
  :client_field_1 => client_field_1
155
261
  })
156
- result["ACS"].nil?.should_not be_true
157
- result["OrderID"].nil?.should_not be_true
158
- result["Forward"].nil?.should_not be_true
159
- result["Method"].nil?.should_not be_true
160
- result["PayTimes"].nil?.should_not be_true
161
- result["Approve"].nil?.should_not be_true
162
- result["TranID"].nil?.should_not be_true
163
- result["TranDate"].nil?.should_not be_true
164
- result["CheckString"].nil?.should_not be_true
165
- result["ClientField1"].nil?.should_not be_true
166
- (result["ClientField1"] == client_field_1).should be_true
167
- (result["ClientField1"].encoding.to_s == "UTF-8").should be_true
168
- result["ClientField3"].nil?.should_not be_true
262
+ result["ACS"].nil?.should_not be_truthy
263
+ result["OrderID"].nil?.should_not be_truthy
264
+ result["Forward"].nil?.should_not be_truthy
265
+ result["Method"].nil?.should_not be_truthy
266
+ result["PayTimes"].nil?.should_not be_truthy
267
+ result["Approve"].nil?.should_not be_truthy
268
+ result["TranID"].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["ClientField1"].encoding.to_s == "UTF-8").should be_truthy
274
+ result["ClientField3"].nil?.should_not be_truthy
169
275
  end
170
276
  end
171
277
  end
@@ -193,22 +299,22 @@ describe "GMO::Payment::ShopAPI" do
193
299
  :receipts_disp_13 => '00:00-00:15',
194
300
  :client_field_1 => client_field_1
195
301
  })
196
- result["OrderID"].nil?.should_not be_true
197
- result["Convenience"].nil?.should_not be_true
198
- result["ConfNo"].nil?.should_not be_true
199
- result["ReceiptNo"].nil?.should_not be_true
200
- result["PaymentTerm"].nil?.should_not be_true
201
- result["TranDate"].nil?.should_not be_true
202
- result["CheckString"].nil?.should_not be_true
203
- result["ClientField1"].nil?.should_not be_true
204
- (result["ClientField1"] == client_field_1).should be_true
205
- result["ClientField3"].nil?.should_not be_true
302
+ result["OrderID"].nil?.should_not be_truthy
303
+ result["Convenience"].nil?.should_not be_truthy
304
+ result["ConfNo"].nil?.should_not be_truthy
305
+ result["ReceiptNo"].nil?.should_not be_truthy
306
+ result["PaymentTerm"].nil?.should_not be_truthy
307
+ result["TranDate"].nil?.should_not be_truthy
308
+ result["CheckString"].nil?.should_not be_truthy
309
+ result["ClientField1"].nil?.should_not be_truthy
310
+ (result["ClientField1"] == client_field_1).should be_truthy
311
+ result["ClientField3"].nil?.should_not be_truthy
206
312
  end
207
313
 
208
314
  it "got error if missing options", :vcr do
209
315
  lambda {
210
316
  result = @service.exec_tran_cvs()
211
- }.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.")
317
+ }.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.")
212
318
  end
213
319
  end
214
320
 
@@ -232,14 +338,14 @@ describe "GMO::Payment::ShopAPI" do
232
338
  :receipts_disp_12 => '0300000001',
233
339
  :receipts_disp_13 => '00:00-00:15'
234
340
  })
235
- result["OrderID"].nil?.should_not be_true
236
- result["CustID"].nil?.should_not be_true
237
- result["BkCode"].nil?.should_not be_true
238
- result["ConfNo"].nil?.should_not be_true
239
- result["EncryptReceiptNo"].nil?.should_not be_true
240
- result["PaymentTerm"].nil?.should_not be_true
241
- result["TranDate"].nil?.should_not be_true
242
- result["CheckString"].nil?.should_not be_true
341
+ result["OrderID"].nil?.should_not be_truthy
342
+ result["CustID"].nil?.should_not be_truthy
343
+ result["BkCode"].nil?.should_not be_truthy
344
+ result["ConfNo"].nil?.should_not be_truthy
345
+ result["EncryptReceiptNo"].nil?.should_not be_truthy
346
+ result["PaymentTerm"].nil?.should_not be_truthy
347
+ result["TranDate"].nil?.should_not be_truthy
348
+ result["CheckString"].nil?.should_not be_truthy
243
349
  end
244
350
 
245
351
  it "got error if missing options", :vcr do
@@ -249,6 +355,172 @@ describe "GMO::Payment::ShopAPI" do
249
355
  end
250
356
  end
251
357
 
358
+ describe "#exec_tran_linepay" do
359
+ it "gets data about a transaction", :vcr do
360
+ order_id = generate_id
361
+ result = @service.entry_tran_linepay({
362
+ :order_id => order_id,
363
+ :job_cd => 'CAPTURE',
364
+ :amount => 100
365
+ })
366
+ access_id = result["AccessID"]
367
+ access_pass = result["AccessPass"]
368
+ result = @service.exec_tran_linepay({
369
+ :order_id => order_id,
370
+ :access_id => access_id,
371
+ :access_pass => access_pass,
372
+ :ret_url => 'https://example.com/path/to/return/success',
373
+ :error_rcv_url => 'https://example.com/path/to/return/failure',
374
+ :product_name => '購入する商品名'
375
+ })
376
+ result["Start"].nil?.should_not be_truthy
377
+ result["AccessID"].nil?.should_not be_truthy
378
+ result["Token"].nil?.should_not be_truthy
379
+ result["StartURL"].nil?.should_not be_truthy
380
+ end
381
+
382
+ it "got error if missing options", :vcr do
383
+ lambda {
384
+ result = @service.exec_tran_linepay()
385
+ }.should raise_error("Required access_id, access_pass, order_id, ret_url, error_rcv_url, product_name were not provided.")
386
+ end
387
+ end
388
+
389
+ describe "#exec_tran_rakuten_id" do
390
+ it "gets data about a transaction", :vcr do
391
+ order_id = generate_id
392
+ result = @service.entry_tran_rakuten_id({
393
+ :order_id => order_id,
394
+ :job_cd => 'CAPTURE',
395
+ :amount => 100
396
+ })
397
+ access_id = result["AccessID"]
398
+ access_pass = result["AccessPass"]
399
+ result = @service.exec_tran_rakuten_id({
400
+ :order_id => order_id,
401
+ :access_id => access_id,
402
+ :access_pass => access_pass,
403
+ :ret_url => 'https://example.com/path/to/return/success',
404
+ :error_rcv_url => 'https://example.com/path/to/return/failure',
405
+ :item_id => '0001',
406
+ :item_name => '購入する商品名'
407
+ })
408
+ result["AccessID"].nil?.should_not be_truthy
409
+ result["Token"].nil?.should_not be_truthy
410
+ result["StartURL"].nil?.should_not be_truthy
411
+ result["StartLimitDate"].nil?.should_not be_truthy
412
+ end
413
+
414
+ it "got error if missing options", :vcr do
415
+ lambda {
416
+ result = @service.exec_tran_rakuten_id()
417
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
418
+ end
419
+ end
420
+
421
+ describe "#exec_tran_docomo" do
422
+ it "gets data about a transaction", :vcr do
423
+ order_id = generate_id
424
+ result = @service.entry_tran_docomo({
425
+ :order_id => order_id,
426
+ :job_cd => 'CAPTURE',
427
+ :amount => 100
428
+ })
429
+ access_id = result["AccessID"]
430
+ access_pass = result["AccessPass"]
431
+ result = @service.exec_tran_docomo({
432
+ :order_id => order_id,
433
+ :access_id => access_id,
434
+ :access_pass => access_pass,
435
+ :ret_url => 'https://example.com/path/to/return/success',
436
+ :error_rcv_url => 'https://example.com/path/to/return/failure',
437
+ :item_id => '0001',
438
+ :item_name => '購入する商品名'
439
+ })
440
+ result["AccessID"].nil?.should_not be_truthy
441
+ result["Token"].nil?.should_not be_truthy
442
+ result["StartURL"].nil?.should_not be_truthy
443
+ result["StartLimitDate"].nil?.should_not be_truthy
444
+ end
445
+
446
+ it "got error if missing options", :vcr do
447
+ lambda {
448
+ result = @service.exec_tran_docomo()
449
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
450
+ end
451
+ end
452
+
453
+ describe "#exec_tran_brandtoken" do
454
+ it "gets data about a transaction", :vcr do
455
+ order_id = generate_id
456
+ client_field_1 = "client_field1"
457
+ result = @service.entry_tran_brandtoken({
458
+ :order_id => order_id,
459
+ :job_cd => "AUTH",
460
+ :amount => 100
461
+ })
462
+ access_id = result["AccessID"]
463
+ access_pass = result["AccessPass"]
464
+ result = @service.exec_tran_brandtoken({
465
+ :order_id => order_id,
466
+ :access_id => access_id,
467
+ :access_pass => access_pass,
468
+ :token_type => :apple_pay,
469
+ :token => 'base64encodedtoken',
470
+ :client_field_1 => client_field_1
471
+ })
472
+ result["Status"].nil?.should_not be true
473
+ result["OrderID"].nil?.should_not be true
474
+ result["Forward"].nil?.should_not be true
475
+ result["Approve"].nil?.should_not be true
476
+ result["TranID"].nil?.should_not be true
477
+ result["TranDate"].nil?.should_not be true
478
+ (result["ClientField1"] == client_field_1).should be true
479
+ result["ClientField2"].nil?.should_not be true
480
+ result["ClientField3"].nil?.should_not be true
481
+ end
482
+
483
+ it "got error if missing options", :vcr do
484
+ lambda {
485
+ result = @service.exec_tran_brandtoken()
486
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
487
+ end
488
+
489
+ context "parameter contains Japanese characters" do
490
+ before { require "kconv" unless defined?(Kconv) }
491
+
492
+ it "should correctly handle Japanese", :vcr do
493
+ order_id = generate_id
494
+ client_field_1 = "〜−¢£¬−‖①ほげほげhogehoge"
495
+ result = @service.entry_tran_brandtoken({
496
+ :order_id => order_id,
497
+ :job_cd => "AUTH",
498
+ :amount => 100
499
+ })
500
+ access_id = result["AccessID"]
501
+ access_pass = result["AccessPass"]
502
+ result = @service.exec_tran_brandtoken({
503
+ :order_id => order_id,
504
+ :access_id => access_id,
505
+ :access_pass => access_pass,
506
+ :token_type => :apple_pay,
507
+ :token => 'base64encodedtoken',
508
+ :client_field_1 => client_field_1
509
+ })
510
+ result["Status"].nil?.should_not be true
511
+ result["OrderID"].nil?.should_not be true
512
+ result["Forward"].nil?.should_not be true
513
+ result["Approve"].nil?.should_not be true
514
+ result["TranID"].nil?.should_not be true
515
+ result["TranDate"].nil?.should_not be true
516
+ (result["ClientField1"] == client_field_1).should be true
517
+ (result["ClientField1"].encoding.to_s == "UTF-8").should be true
518
+ result["ClientField2"].nil?.should_not be true
519
+ result["ClientField3"].nil?.should_not be true
520
+ end
521
+ end
522
+ end
523
+
252
524
  describe "#alter_tran" do
253
525
  it "gets data about order", :vcr do
254
526
  order_id = generate_id
@@ -274,13 +546,13 @@ describe "GMO::Payment::ShopAPI" do
274
546
  :job_cd => "RETURN",
275
547
  :amount => 100
276
548
  })
277
- result["AccessID"].nil?.should_not be_true
278
- result["AccessPass"].nil?.should_not be_true
279
- result["Forward"].nil?.should_not be_true
280
- result["Approve"].nil?.should_not be_true
281
- result["AccessPass"].nil?.should_not be_true
282
- result["TranID"].nil?.should_not be_true
283
- result["TranDate"].nil?.should_not be_true
549
+ result["AccessID"].nil?.should_not be_truthy
550
+ result["AccessPass"].nil?.should_not be_truthy
551
+ result["Forward"].nil?.should_not be_truthy
552
+ result["Approve"].nil?.should_not be_truthy
553
+ result["AccessPass"].nil?.should_not be_truthy
554
+ result["TranID"].nil?.should_not be_truthy
555
+ result["TranDate"].nil?.should_not be_truthy
284
556
  end
285
557
 
286
558
  it "change order auth to sale", :vcr do
@@ -307,13 +579,13 @@ describe "GMO::Payment::ShopAPI" do
307
579
  :job_cd => "SALES",
308
580
  :amount => 100
309
581
  })
310
- result["AccessID"].nil?.should_not be_true
311
- result["AccessPass"].nil?.should_not be_true
312
- result["Forward"].nil?.should_not be_true
313
- result["Approve"].nil?.should_not be_true
314
- result["AccessPass"].nil?.should_not be_true
315
- result["TranID"].nil?.should_not be_true
316
- result["TranDate"].nil?.should_not be_true
582
+ result["AccessID"].nil?.should_not be_truthy
583
+ result["AccessPass"].nil?.should_not be_truthy
584
+ result["Forward"].nil?.should_not be_truthy
585
+ result["Approve"].nil?.should_not be_truthy
586
+ result["AccessPass"].nil?.should_not be_truthy
587
+ result["TranID"].nil?.should_not be_truthy
588
+ result["TranDate"].nil?.should_not be_truthy
317
589
  end
318
590
 
319
591
  it "got error if missing options", :vcr do
@@ -348,12 +620,12 @@ describe "GMO::Payment::ShopAPI" do
348
620
  :job_cd => "AUTH",
349
621
  :amount => 1000
350
622
  })
351
- result["AccessID"].nil?.should_not be_true
352
- result["AccessPass"].nil?.should_not be_true
353
- result["Forward"].nil?.should_not be_true
354
- result["Approve"].nil?.should_not be_true
355
- result["TranID"].nil?.should_not be_true
356
- result["TranDate"].nil?.should_not be_true
623
+ result["AccessID"].nil?.should_not be_truthy
624
+ result["AccessPass"].nil?.should_not be_truthy
625
+ result["Forward"].nil?.should_not be_truthy
626
+ result["Approve"].nil?.should_not be_truthy
627
+ result["TranID"].nil?.should_not be_truthy
628
+ result["TranDate"].nil?.should_not be_truthy
357
629
  end
358
630
 
359
631
  it "got error if missing options", :vcr do
@@ -363,6 +635,192 @@ describe "GMO::Payment::ShopAPI" do
363
635
  end
364
636
  end
365
637
 
638
+ describe "#change_tran_brandtoken" do
639
+ it "gets data about order", :vcr do
640
+ order_id = generate_id
641
+ result = @service.entry_tran_brandtoken({
642
+ :order_id => order_id,
643
+ :job_cd => "AUTH",
644
+ :amount => 100
645
+ })
646
+ access_id = result["AccessID"]
647
+ access_pass = result["AccessPass"]
648
+ @service.exec_tran_brandtoken({
649
+ :order_id => order_id,
650
+ :access_id => access_id,
651
+ :access_pass => access_pass,
652
+ :token_type => :apple_pay,
653
+ :token => 'base64encodedtoken'
654
+ })
655
+ result = @service.change_tran_brandtoken({
656
+ :order_id => order_id,
657
+ :access_id => access_id,
658
+ :access_pass => access_pass,
659
+ :job_cd => "CAPTURE",
660
+ :amount => 1500
661
+ })
662
+ result["AccessID"].nil?.should_not be true
663
+ result["AccessPass"].nil?.should_not be true
664
+ result["Status"].nil?.should_not be true
665
+ result["Forward"].nil?.should_not be true
666
+ result["Approve"].nil?.should_not be true
667
+ result["TranID"].nil?.should_not be true
668
+ result["TranDate"].nil?.should_not be true
669
+ end
670
+
671
+ it "got error if missing options", :vcr do
672
+ lambda {
673
+ result = @service.change_tran_brandtoken()
674
+ }.should raise_error('Required access_id, access_pass, order_id, job_cd, amount were not provided.')
675
+ end
676
+ end
677
+
678
+ describe "#void_tran_brandtoken" do
679
+ it "gets data about order", :vcr do
680
+ order_id = generate_id
681
+ result = @service.entry_tran_brandtoken({
682
+ :order_id => order_id,
683
+ :job_cd => "AUTH",
684
+ :amount => 100
685
+ })
686
+ access_id = result["AccessID"]
687
+ access_pass = result["AccessPass"]
688
+ @service.exec_tran_brandtoken({
689
+ :order_id => order_id,
690
+ :access_id => access_id,
691
+ :access_pass => access_pass,
692
+ :token_type => :apple_pay,
693
+ :token => 'base64encodedtoken'
694
+ })
695
+ result = @service.void_tran_brandtoken({
696
+ :order_id => order_id,
697
+ :access_id => access_id,
698
+ :access_pass => access_pass
699
+ })
700
+ result["AccessID"].nil?.should_not be true
701
+ result["AccessPass"].nil?.should_not be true
702
+ result["Status"].nil?.should_not be true
703
+ result["Forward"].nil?.should_not be true
704
+ result["Approve"].nil?.should_not be true
705
+ result["TranID"].nil?.should_not be true
706
+ result["TranDate"].nil?.should_not be true
707
+ end
708
+
709
+ it "got error if missing options", :vcr do
710
+ lambda {
711
+ result = @service.void_tran_brandtoken()
712
+ }.should raise_error('Required access_id, access_pass, order_id were not provided.')
713
+ end
714
+ end
715
+
716
+ describe "#sales_tran_brandtoken" do
717
+ it "gets data about a transaction", :vcr do
718
+ order_id = generate_id
719
+ result = @service.entry_tran_brandtoken({
720
+ :order_id => order_id,
721
+ :job_cd => "AUTH",
722
+ :amount => 1000
723
+ })
724
+ access_id = result["AccessID"]
725
+ access_pass = result["AccessPass"]
726
+ @service.exec_tran_brandtoken({
727
+ :order_id => order_id,
728
+ :access_id => access_id,
729
+ :access_pass => access_pass,
730
+ :token_type => :apple_pay,
731
+ :token => 'base64encodedtoken'
732
+ })
733
+ member_id = generate_id
734
+ @shop_site.trade_brandtoken({
735
+ :member_id => member_id,
736
+ :order_id => order_id
737
+ })
738
+ result = @service.sales_tran_brandtoken({
739
+ :access_id => access_id,
740
+ :access_pass => access_pass,
741
+ :order_id => order_id,
742
+ :amount => 1000
743
+ })
744
+ result["AccessID"].nil?.should_not be true
745
+ result["AccessPass"].nil?.should_not be true
746
+ result["Status"].nil?.should_not be true
747
+ result["Forward"].nil?.should_not be true
748
+ result["Approve"].nil?.should_not be true
749
+ result["TranID"].nil?.should_not be true
750
+ result["TranDate"].nil?.should_not be true
751
+ end
752
+
753
+ it "got error if missing options", :vcr do
754
+ lambda {
755
+ result = @service.sales_tran_brandtoken()
756
+ }.should raise_error('Required access_id, access_pass, order_id, amount were not provided.')
757
+ end
758
+ end
759
+
760
+ describe "#refund_tran_brandtoken" do
761
+ it "gets data about a transaction", :vcr do
762
+ order_id = generate_id
763
+ result = @service.entry_tran_brandtoken({
764
+ :order_id => order_id,
765
+ :job_cd => "CAPTURE",
766
+ :amount => 1000
767
+ })
768
+ access_id = result["AccessID"]
769
+ access_pass = result["AccessPass"]
770
+ @service.exec_tran_brandtoken({
771
+ :order_id => order_id,
772
+ :access_id => access_id,
773
+ :access_pass => access_pass,
774
+ :token_type => :apple_pay,
775
+ :token => 'base64encodedtoken'
776
+ })
777
+ result = @service.refund_tran_brandtoken({
778
+ :access_id => access_id,
779
+ :access_pass => access_pass,
780
+ :order_id => order_id,
781
+ :amount => 1000
782
+ })
783
+ result["AccessID"].nil?.should_not be true
784
+ result["AccessPass"].nil?.should_not be true
785
+ result["Status"].nil?.should_not be true
786
+ result["Forward"].nil?.should_not be true
787
+ result["Approve"].nil?.should_not be true
788
+ result["TranID"].nil?.should_not be true
789
+ result["TranDate"].nil?.should_not be true
790
+ end
791
+
792
+ it "got error if missing options", :vcr do
793
+ lambda {
794
+ result = @service.refund_tran_brandtoken()
795
+ }.should raise_error('Required access_id, access_pass, order_id, amount were not provided.')
796
+ end
797
+ end
798
+
799
+ describe "#cvs_cancel" do
800
+ it "gets data about a transaction", :vcr do
801
+ order_id = generate_id
802
+ result = @service.entry_tran_cvs({
803
+ :order_id => order_id,
804
+ :amount => 100
805
+ })
806
+ access_id = result["AccessID"]
807
+ access_pass = result["AccessPass"]
808
+ result = @service.cvs_cancel({
809
+ :order_id => order_id,
810
+ :access_id => access_id,
811
+ :access_pass => access_pass,
812
+ })
813
+
814
+ result["OrderID"].nil?.should_not be_truthy
815
+ result["Status"].nil?.should_not be_truthy
816
+ end
817
+
818
+ it "got error if missing options", :vcr do
819
+ lambda {
820
+ result = @service.cvs_cancel()
821
+ }.should raise_error("Required access_id, access_pass, order_id were not provided.")
822
+ end
823
+ end
366
824
 
367
825
  describe "#search_trade" do
368
826
  it "gets data about order", :vcr do
@@ -370,24 +828,24 @@ describe "GMO::Payment::ShopAPI" do
370
828
  result = @service.search_trade({
371
829
  :order_id => order_id
372
830
  })
373
- result["OrderID"].nil?.should_not be_true
374
- result["Status"].nil?.should_not be_true
375
- result["ProcessDate"].nil?.should_not be_true
376
- result["JobCd"].nil?.should_not be_true
377
- result["AccessID"].nil?.should_not be_true
378
- result["AccessPass"].nil?.should_not be_true
379
- result["ItemCode"].nil?.should_not be_true
380
- result["Amount"].nil?.should_not be_true
381
- result["Tax"].nil?.should_not be_true
382
- result["SiteID"].nil?.should_not be_true
383
- result["MemberID"].nil?.should_not be_true
384
- result["CardNo"].nil?.should_not be_true
385
- result["Expire"].nil?.should_not be_true
386
- result["Method"].nil?.should_not be_true
387
- result["PayTimes"].nil?.should_not be_true
388
- result["Forward"].nil?.should_not be_true
389
- result["TranID"].nil?.should_not be_true
390
- result["Approve"].nil?.should_not be_true
831
+ result["OrderID"].nil?.should_not be_truthy
832
+ result["Status"].nil?.should_not be_truthy
833
+ result["ProcessDate"].nil?.should_not be_truthy
834
+ result["JobCd"].nil?.should_not be_truthy
835
+ result["AccessID"].nil?.should_not be_truthy
836
+ result["AccessPass"].nil?.should_not be_truthy
837
+ result["ItemCode"].nil?.should_not be_truthy
838
+ result["Amount"].nil?.should_not be_truthy
839
+ result["Tax"].nil?.should_not be_truthy
840
+ result["SiteID"].nil?.should_not be_truthy
841
+ result["MemberID"].nil?.should_not be_truthy
842
+ result["CardNo"].nil?.should_not be_truthy
843
+ result["Expire"].nil?.should_not be_truthy
844
+ result["Method"].nil?.should_not be_truthy
845
+ result["PayTimes"].nil?.should_not be_truthy
846
+ result["Forward"].nil?.should_not be_truthy
847
+ result["TranID"].nil?.should_not be_truthy
848
+ result["Approve"].nil?.should_not be_truthy
391
849
  end
392
850
 
393
851
  it "got error if missing options", :vcr do
@@ -399,30 +857,29 @@ describe "GMO::Payment::ShopAPI" do
399
857
 
400
858
  describe "#search_trade_multi" do
401
859
  it "gets data about order", :vcr do
402
- client_field_1 = "client_field1"
403
860
  result = @service.search_trade_multi({
404
861
  :order_id => @order_id,
405
862
  :pay_type => "0"
406
863
  })
407
- result["Status"].nil?.should_not be_true
408
- result["ProcessDate"].nil?.should_not be_true
409
- result["JobCd"].nil?.should_not be_true
410
- result["AccessID"].nil?.should_not be_true
411
- result["AccessPass"].nil?.should_not be_true
412
- result["ItemCode"].nil?.should_not be_true
413
- result["Amount"].nil?.should_not be_true
414
- result["Tax"].nil?.should_not be_true
415
- result["SiteID"].nil?.should_not be_true
416
- result["MemberID"].nil?.should_not be_true
417
- result["CardNo"].nil?.should_not be_true
418
- result["Expire"].nil?.should_not be_true
419
- result["Method"].nil?.should_not be_true
420
- result["PayTimes"].nil?.should_not be_true
421
- result["Forward"].nil?.should_not be_true
422
- result["TranID"].nil?.should_not be_true
423
- result["Approve"].nil?.should_not be_true
424
- result["PayType"].nil?.should_not be_true
425
- result["PaymentTerm"].nil?.should_not be_true
864
+ result["Status"].nil?.should_not be_truthy
865
+ result["ProcessDate"].nil?.should_not be_truthy
866
+ result["JobCd"].nil?.should_not be_truthy
867
+ result["AccessID"].nil?.should_not be_truthy
868
+ result["AccessPass"].nil?.should_not be_truthy
869
+ result["ItemCode"].nil?.should_not be_truthy
870
+ result["Amount"].nil?.should_not be_truthy
871
+ result["Tax"].nil?.should_not be_truthy
872
+ result["SiteID"].nil?.should_not be_truthy
873
+ result["MemberID"].nil?.should_not be_truthy
874
+ result["CardNo"].nil?.should_not be_truthy
875
+ result["Expire"].nil?.should_not be_truthy
876
+ result["Method"].nil?.should_not be_truthy
877
+ result["PayTimes"].nil?.should_not be_truthy
878
+ result["Forward"].nil?.should_not be_truthy
879
+ result["TranID"].nil?.should_not be_truthy
880
+ result["Approve"].nil?.should_not be_truthy
881
+ result["PayType"].nil?.should_not be_truthy
882
+ result["PaymentTerm"].nil?.should_not be_truthy
426
883
  end
427
884
 
428
885
  it "got error if missing options", :vcr do