active_merchant-epsilon 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.env.sample +3 -0
- data/.gitignore +17 -0
- data/CHANGELOG.md +29 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +256 -0
- data/Rakefile +19 -0
- data/active_merchant-epsilon.gemspec +31 -0
- data/lib/active_merchant/billing/convenience_store.rb +55 -0
- data/lib/active_merchant/billing/gateways/epsilon.rb +194 -0
- data/lib/active_merchant/billing/gateways/epsilon/epsilon_base.rb +132 -0
- data/lib/active_merchant/billing/gateways/epsilon/epsilon_mission_code.rb +30 -0
- data/lib/active_merchant/billing/gateways/epslion_convenience_store.rb +27 -0
- data/lib/active_merchant/epsilon.rb +9 -0
- data/lib/active_merchant/epsilon/version.rb +5 -0
- data/test/fixtures/vcr_cassettes/autheticate_three_d_secure_card_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/cancel_recurring_fail.yml +82 -0
- data/test/fixtures/vcr_cassettes/cancel_recurring_successful.yml +83 -0
- data/test/fixtures/vcr_cassettes/change_recurring_amount_failure.yml +85 -0
- data/test/fixtures/vcr_cassettes/change_recurring_amount_successful.yml +85 -0
- data/test/fixtures/vcr_cassettes/convenience_store_purchase_fail.yml +39 -0
- data/test/fixtures/vcr_cassettes/convenience_store_purchase_successful.yml +50 -0
- data/test/fixtures/vcr_cassettes/find_user_failure.yml +44 -0
- data/test/fixtures/vcr_cassettes/find_user_success.yml +44 -0
- data/test/fixtures/vcr_cassettes/installment_purchase_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/purchase_fail.yml +45 -0
- data/test/fixtures/vcr_cassettes/purchase_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/purchase_with_three_d_secure_card_successful.yml +45 -0
- data/test/fixtures/vcr_cassettes/purchase_with_verification_value.yml +46 -0
- data/test/fixtures/vcr_cassettes/recurring_fail.yml +45 -0
- data/test/fixtures/vcr_cassettes/recurring_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/registered_purchase_fail.yml +45 -0
- data/test/fixtures/vcr_cassettes/registered_purchase_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/registered_recurring_fail.yml +45 -0
- data/test/fixtures/vcr_cassettes/registered_recurring_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/revolving_purchase_successful.yml +46 -0
- data/test/fixtures/vcr_cassettes/terminate_recurring_fail.yml +96 -0
- data/test/fixtures/vcr_cassettes/terminate_recurring_successful.yml +82 -0
- data/test/fixtures/vcr_cassettes/verify_fail.yml +45 -0
- data/test/fixtures/vcr_cassettes/verify_successful.yml +85 -0
- data/test/fixtures/vcr_cassettes/void_fail.yml +42 -0
- data/test/fixtures/vcr_cassettes/void_successful.yml +85 -0
- data/test/remote/gateways/remote_epsilon_convenience_store_test.rb +27 -0
- data/test/remote/gateways/remote_epsilon_test.rb +249 -0
- data/test/test_helper.rb +162 -0
- data/test/unit/gateways/epsilon_test.rb +11 -0
- data/wercker.yml +18 -0
- metadata +248 -0
@@ -0,0 +1,42 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://beta.epsilon.jp/cgi-bin/order/cancel_payment.cgi
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: contract_code=[CONTRACT_CODE]&order_number=1234567890
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/x-www-form-urlencoded
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
User-Agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Wed, 15 Oct 2014 06:45:41 GMT
|
25
|
+
Server:
|
26
|
+
- Apache
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Content-Type:
|
30
|
+
- text/xml; charset=CP932
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: |-
|
34
|
+
<?xml version="1.0" encoding="x-sjis-cp932"?>
|
35
|
+
<Epsilon_result>
|
36
|
+
<result err_code="810" />
|
37
|
+
<result err_detail="%91%CE%8F%DB%8E%E6%88%F8%82%CD%82%A0%82%E8%82%DC%82%B9%82%F1" />
|
38
|
+
<result result="9" />
|
39
|
+
</Epsilon_result>
|
40
|
+
http_version:
|
41
|
+
recorded_at: Wed, 15 Oct 2014 06:45:42 GMT
|
42
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,85 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: post
|
5
|
+
uri: https://beta.epsilon.jp/cgi-bin/order/direct_card_payment.cgi
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: contract_code=[CONTRACT_CODE]&user_id=U1413355539&user_name=TARO+YAMADA&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Greate+Product&order_number=O39187589&st_code=10000-0000-0000&mission_code=1&item_price=100&process_code=1&card_number=4242424242424242&expire_y=2015&expire_m=10&user_agent=ActiveMerchant%3A%3AEpsilon-0.0.1
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/x-www-form-urlencoded
|
12
|
+
Accept-Encoding:
|
13
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
14
|
+
Accept:
|
15
|
+
- "*/*"
|
16
|
+
User-Agent:
|
17
|
+
- Ruby
|
18
|
+
response:
|
19
|
+
status:
|
20
|
+
code: 200
|
21
|
+
message: OK
|
22
|
+
headers:
|
23
|
+
Date:
|
24
|
+
- Wed, 15 Oct 2014 06:45:39 GMT
|
25
|
+
Server:
|
26
|
+
- Apache
|
27
|
+
Transfer-Encoding:
|
28
|
+
- chunked
|
29
|
+
Content-Type:
|
30
|
+
- text/xml; charset=CP932
|
31
|
+
body:
|
32
|
+
encoding: UTF-8
|
33
|
+
string: |-
|
34
|
+
<?xml version="1.0" encoding="x-sjis-cp932"?>
|
35
|
+
<Epsilon_result>
|
36
|
+
<result acsurl="" />
|
37
|
+
<result err_code="" />
|
38
|
+
<result err_detail="" />
|
39
|
+
<result kari_flag="1" />
|
40
|
+
<result pareq="" />
|
41
|
+
<result result="1" />
|
42
|
+
<result trans_code="494184" />
|
43
|
+
</Epsilon_result>
|
44
|
+
http_version:
|
45
|
+
recorded_at: Wed, 15 Oct 2014 06:45:41 GMT
|
46
|
+
- request:
|
47
|
+
method: post
|
48
|
+
uri: https://beta.epsilon.jp/cgi-bin/order/cancel_payment.cgi
|
49
|
+
body:
|
50
|
+
encoding: US-ASCII
|
51
|
+
string: contract_code=[CONTRACT_CODE]&order_number=O39187589
|
52
|
+
headers:
|
53
|
+
Content-Type:
|
54
|
+
- application/x-www-form-urlencoded
|
55
|
+
Accept-Encoding:
|
56
|
+
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
57
|
+
Accept:
|
58
|
+
- "*/*"
|
59
|
+
User-Agent:
|
60
|
+
- Ruby
|
61
|
+
response:
|
62
|
+
status:
|
63
|
+
code: 200
|
64
|
+
message: OK
|
65
|
+
headers:
|
66
|
+
Date:
|
67
|
+
- Wed, 15 Oct 2014 06:45:41 GMT
|
68
|
+
Server:
|
69
|
+
- Apache
|
70
|
+
Transfer-Encoding:
|
71
|
+
- chunked
|
72
|
+
Content-Type:
|
73
|
+
- text/xml; charset=CP932
|
74
|
+
body:
|
75
|
+
encoding: UTF-8
|
76
|
+
string: |-
|
77
|
+
<?xml version="1.0" encoding="x-sjis-cp932"?>
|
78
|
+
<Epsilon_result>
|
79
|
+
<result err_code="" />
|
80
|
+
<result err_detail="" />
|
81
|
+
<result result="1" />
|
82
|
+
</Epsilon_result>
|
83
|
+
http_version:
|
84
|
+
recorded_at: Wed, 15 Oct 2014 06:45:41 GMT
|
85
|
+
recorded_with: VCR 2.9.3
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteEpsilonConvenienceStoreGatewayTest < MiniTest::Test
|
4
|
+
include SamplePaymentMethods
|
5
|
+
|
6
|
+
def gateway
|
7
|
+
@gateway ||= ActiveMerchant::Billing::EpsilonConvenienceStoreGateway.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_convenience_store_purchase_successful
|
11
|
+
VCR.use_cassette(:convenience_store_purchase_successful) do
|
12
|
+
response = gateway.purchase(10000, valid_convenience_store, purchase_detail)
|
13
|
+
|
14
|
+
assert_equal true, response.success?
|
15
|
+
assert_match /\d{7}/, response.params['receipt_number']
|
16
|
+
assert_match /\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}/, response.params['receipt_date']
|
17
|
+
assert_match /\d{4}\-\d{2}\-\d{2}/, response.params['convenience_store_limit_date']
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_convenience_store_purchase_fail
|
22
|
+
VCR.use_cassette(:convenience_store_purchase_fail) do
|
23
|
+
response = gateway.purchase(10000, invalid_convenience_store, purchase_detail)
|
24
|
+
assert_equal false, response.success?
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,249 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class RemoteEpsilonGatewayTest < MiniTest::Test
|
4
|
+
include SamplePaymentMethods
|
5
|
+
|
6
|
+
def gateway
|
7
|
+
@gateway ||= ActiveMerchant::Billing::EpsilonGateway.new
|
8
|
+
end
|
9
|
+
|
10
|
+
def test_purchase_successful
|
11
|
+
VCR.use_cassette(:purchase_successful) do
|
12
|
+
if valid_credit_card.validate.empty?
|
13
|
+
response = gateway.purchase(10000, valid_credit_card, purchase_detail)
|
14
|
+
end
|
15
|
+
|
16
|
+
assert_equal true, response.success?
|
17
|
+
assert_equal false, response.params['three_d_secure']
|
18
|
+
assert_empty response.params['acs_url']
|
19
|
+
assert_empty response.params['pa_req']
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_purchase_with_verification_value_successful
|
24
|
+
VCR.use_cassette(:purchase_with_verification_value) do
|
25
|
+
if valid_credit_card_with_verification_value.validate.empty?
|
26
|
+
response = gateway.purchase(10000, valid_credit_card_with_verification_value, purchase_detail)
|
27
|
+
end
|
28
|
+
|
29
|
+
assert_equal true, response.success?
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_installment_purchase_successful
|
34
|
+
VCR.use_cassette(:installment_purchase_successful) do
|
35
|
+
if valid_credit_card_with_verification_value.validate.empty?
|
36
|
+
response = gateway.purchase(10000, valid_credit_card_with_verification_value, installment_purchase_detail)
|
37
|
+
end
|
38
|
+
|
39
|
+
assert_equal true, response.success?
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_revolving_purchase_successful
|
44
|
+
VCR.use_cassette(:revolving_purchase_successful) do
|
45
|
+
if valid_credit_card_with_verification_value.validate.empty?
|
46
|
+
response = gateway.purchase(10000, valid_credit_card_with_verification_value, revolving_purchase_detail)
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_equal true, response.success?
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_purchase_with_three_d_secure_card_successful
|
54
|
+
VCR.use_cassette(:purchase_with_three_d_secure_card_successful) do
|
55
|
+
if valid_three_d_secure_card.validate.empty?
|
56
|
+
response = gateway.purchase(
|
57
|
+
10000,
|
58
|
+
valid_three_d_secure_card,
|
59
|
+
purchase_detail.merge(three_d_secure_check_code: 1)
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
assert_equal true, response.success?
|
64
|
+
assert_equal true, response.params['three_d_secure']
|
65
|
+
assert_match /\Ahttps?/, response.params['acs_url']
|
66
|
+
refute_empty response.params['pa_req']
|
67
|
+
end
|
68
|
+
|
69
|
+
VCR.use_cassette(:autheticate_three_d_secure_card_successful) do
|
70
|
+
response = gateway.authenticate(valid_three_d_secure_pa_res)
|
71
|
+
assert_equal true, response.success?
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_purchase_fail
|
76
|
+
VCR.use_cassette(:purchase_fail) do
|
77
|
+
response = gateway.purchase(10000, invalid_credit_card, purchase_detail)
|
78
|
+
assert_equal false, response.success?
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def test_recurring_successful
|
83
|
+
VCR.use_cassette(:recurring_successful) do
|
84
|
+
response = gateway.recurring(10000, valid_credit_card, purchase_detail)
|
85
|
+
assert_equal true, response.success?
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def test_recurring_fail
|
90
|
+
VCR.use_cassette(:recurring_fail) do
|
91
|
+
response = gateway.recurring(10000, invalid_credit_card, purchase_detail)
|
92
|
+
assert_equal false, response.success?
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def test_registered_recurring_successful
|
97
|
+
VCR.use_cassette(:registered_recurring_successful) do
|
98
|
+
response = gateway.registered_recurring(10000, purchase_detail_for_registered)
|
99
|
+
assert_equal true, response.success?
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
def test_registered_recurring_fail
|
104
|
+
VCR.use_cassette(:registered_recurring_fail) do
|
105
|
+
invalid_purchase_detail = purchase_detail_for_registered
|
106
|
+
invalid_purchase_detail[:mission_code] = ''
|
107
|
+
response = gateway.registered_recurring(10000, invalid_purchase_detail)
|
108
|
+
|
109
|
+
assert_equal false, response.success?
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def test_cancel_recurring
|
114
|
+
VCR.use_cassette(:cancel_recurring_successful) do
|
115
|
+
detail = purchase_detail
|
116
|
+
|
117
|
+
response = gateway.recurring(10000, valid_credit_card, detail)
|
118
|
+
|
119
|
+
assert_equal true, response.success?
|
120
|
+
|
121
|
+
response = gateway.cancel_recurring(user_id: detail[:user_id], item_code: detail[:item_code])
|
122
|
+
|
123
|
+
assert_equal true, response.success?
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
def test_cancel_recurring_fail
|
128
|
+
VCR.use_cassette(:cancel_recurring_fail) do
|
129
|
+
detail = purchase_detail
|
130
|
+
|
131
|
+
response = gateway.recurring(10000, valid_credit_card, detail)
|
132
|
+
|
133
|
+
assert_equal true, response.success?
|
134
|
+
|
135
|
+
response = gateway.cancel_recurring(
|
136
|
+
user_id: detail[:user_id],
|
137
|
+
item_code: detail[:item_code] + 'wrong'
|
138
|
+
)
|
139
|
+
|
140
|
+
assert_equal false, response.success?
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_terminate_recurring
|
145
|
+
VCR.use_cassette(:terminate_recurring_successful) do
|
146
|
+
detail = purchase_detail
|
147
|
+
response = gateway.recurring(10000, valid_credit_card, detail)
|
148
|
+
assert_equal true, response.success?
|
149
|
+
response = gateway.terminate_recurring(user_id: detail[:user_id])
|
150
|
+
assert_equal true, response.success?
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_terminate_recurring_fail
|
155
|
+
VCR.use_cassette(:terminate_recurring_fail) do
|
156
|
+
detail = purchase_detail
|
157
|
+
response = gateway.recurring(10000, valid_credit_card, detail)
|
158
|
+
assert_equal true, response.success?
|
159
|
+
assert_raises(ActiveMerchant::ResponseError) do
|
160
|
+
gateway.terminate_recurring(user_id: detail[:user_id] + 'wrong')
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
def test_void
|
166
|
+
VCR.use_cassette(:void_successful) do
|
167
|
+
detail = purchase_detail
|
168
|
+
|
169
|
+
purchase_response = gateway.purchase(100, valid_credit_card, detail)
|
170
|
+
|
171
|
+
assert_equal true, purchase_response.success?
|
172
|
+
|
173
|
+
response = gateway.void(detail[:order_number])
|
174
|
+
|
175
|
+
assert_equal true, response.success?
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_void_fail
|
180
|
+
VCR.use_cassette(:void_fail) do
|
181
|
+
response = gateway.void('1234567890')
|
182
|
+
assert_equal false, response.success?
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
def test_verify
|
187
|
+
VCR.use_cassette(:verify_successful) do
|
188
|
+
response = gateway.verify(valid_credit_card, purchase_detail.slice(:user_id, :user_email))
|
189
|
+
assert_equal true, response.success?
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
193
|
+
def test_verify_fail
|
194
|
+
VCR.use_cassette(:verify_fail) do
|
195
|
+
response = gateway.verify(invalid_credit_card, purchase_detail.slice(:user_id, :user_email))
|
196
|
+
assert_equal false, response.success?
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_find_user_success
|
201
|
+
VCR.use_cassette(:find_user_success) do
|
202
|
+
response = gateway.find_user(user_id: "U1416470209")
|
203
|
+
assert_equal true, response.success?
|
204
|
+
end
|
205
|
+
end
|
206
|
+
|
207
|
+
def test_find_user_failure
|
208
|
+
VCR.use_cassette(:find_user_failure) do
|
209
|
+
response = gateway.find_user(user_id: "")
|
210
|
+
assert_equal false, response.success?
|
211
|
+
end
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_registered_purchase_successful
|
215
|
+
VCR.use_cassette(:registered_purchase_successful) do
|
216
|
+
response = gateway.registered_purchase(10000, purchase_detail_for_registered)
|
217
|
+
assert_equal true, response.success?
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
def test_registered_purchase_fail
|
222
|
+
VCR.use_cassette(:registered_purchase_fail) do
|
223
|
+
invalid_purchase_detail = purchase_detail_for_registered
|
224
|
+
invalid_purchase_detail[:user_id] = ''
|
225
|
+
response = gateway.registered_purchase(10000, invalid_purchase_detail)
|
226
|
+
assert_equal false, response.success?
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_change_recurring_amount_successful
|
231
|
+
VCR.use_cassette(:change_recurring_amount_successful) do
|
232
|
+
detail = purchase_detail
|
233
|
+
response = gateway.recurring(10000, valid_credit_card, detail)
|
234
|
+
assert_equal true, response.success?
|
235
|
+
response = gateway.change_recurring_amount(new_item_price: 5000, user_id: detail[:user_id], item_code: detail[:item_code])
|
236
|
+
assert_equal true, response.success?
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
def test_change_recurring_amount_failure
|
241
|
+
VCR.use_cassette(:change_recurring_amount_failure) do
|
242
|
+
detail = purchase_detail
|
243
|
+
response = gateway.recurring(10000, valid_credit_card, detail)
|
244
|
+
assert_equal true, response.success?
|
245
|
+
response = gateway.change_recurring_amount(new_item_price: 5000, user_id: detail[:user_id], item_code: 'invalid code')
|
246
|
+
assert_equal false, response.success?
|
247
|
+
end
|
248
|
+
end
|
249
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
require 'minitest/autorun'
|
2
|
+
|
3
|
+
require 'active_merchant'
|
4
|
+
require 'active_merchant/epsilon'
|
5
|
+
|
6
|
+
require 'dotenv'
|
7
|
+
require 'pry'
|
8
|
+
require 'tapp'
|
9
|
+
require 'vcr'
|
10
|
+
|
11
|
+
require 'webmock/minitest'
|
12
|
+
|
13
|
+
Dotenv.load
|
14
|
+
|
15
|
+
ActiveMerchant::Billing::Base.mode = :test
|
16
|
+
|
17
|
+
ActiveMerchant::Billing::EpsilonGateway.contract_code = ENV['CONTRACT_CODE']
|
18
|
+
ActiveMerchant::Billing::EpsilonGateway.proxy_address = ENV['PROXY_ADDRESS'] if ENV['PROXY_ADDRESS']
|
19
|
+
ActiveMerchant::Billing::EpsilonGateway.proxy_port = ENV['PROXY_PORT'] if ENV['PROXY_PORT']
|
20
|
+
|
21
|
+
VCR.configure do |c|
|
22
|
+
c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
|
23
|
+
c.hook_into :webmock
|
24
|
+
c.filter_sensitive_data('[CONTRACT_CODE]') { ENV['CONTRACT_CODE'] }
|
25
|
+
end
|
26
|
+
|
27
|
+
module SamplePaymentMethods
|
28
|
+
def valid_credit_card
|
29
|
+
ActiveMerchant::Billing::CreditCard.require_verification_value = false
|
30
|
+
ActiveMerchant::Billing::CreditCard.new(
|
31
|
+
first_name: 'TARO',
|
32
|
+
last_name: 'YAMADA',
|
33
|
+
number: '4242424242424242',
|
34
|
+
month: '10',
|
35
|
+
year: Time.now.year + 1,
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
def valid_credit_card_with_verification_value
|
40
|
+
ActiveMerchant::Billing::CreditCard.require_verification_value = true
|
41
|
+
ActiveMerchant::Billing::CreditCard.new(
|
42
|
+
first_name: 'TARO',
|
43
|
+
last_name: 'YAMADA',
|
44
|
+
number: '4242424242424242',
|
45
|
+
month: '10',
|
46
|
+
year: Time.now.year + 1,
|
47
|
+
verification_value: '000',
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def valid_three_d_secure_card
|
52
|
+
ActiveMerchant::Billing::CreditCard.require_verification_value = false
|
53
|
+
ActiveMerchant::Billing::CreditCard.new(
|
54
|
+
first_name: 'TARO',
|
55
|
+
last_name: 'YAMADA',
|
56
|
+
number: '4123451111111117',
|
57
|
+
month: '12',
|
58
|
+
year: '2023',
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
def invalid_credit_card
|
63
|
+
ActiveMerchant::Billing::CreditCard.require_verification_value = false
|
64
|
+
ActiveMerchant::Billing::CreditCard.new(
|
65
|
+
first_name: 'TARO',
|
66
|
+
last_name: 'YAMADA',
|
67
|
+
number: '0000000000000000',
|
68
|
+
month: '10',
|
69
|
+
year: Time.now.year + 1,
|
70
|
+
)
|
71
|
+
end
|
72
|
+
|
73
|
+
def purchase_detail
|
74
|
+
now = Time.now
|
75
|
+
{
|
76
|
+
user_id: "U#{Time.now.to_i}",
|
77
|
+
user_name: 'YAMADA Taro',
|
78
|
+
user_email: 'yamada-taro@example.com',
|
79
|
+
item_code: 'ITEM001',
|
80
|
+
item_name: 'Greate Product',
|
81
|
+
order_number: "O#{now.sec}#{now.usec}"
|
82
|
+
}
|
83
|
+
end
|
84
|
+
|
85
|
+
def installment_purchase_detail
|
86
|
+
now = Time.now
|
87
|
+
{
|
88
|
+
user_id: "U#{Time.now.to_i}",
|
89
|
+
user_name: 'YAMADA Taro',
|
90
|
+
user_email: 'yamada-taro@example.com',
|
91
|
+
item_code: 'ITEM001',
|
92
|
+
item_name: 'Greate Product',
|
93
|
+
order_number: "O#{now.sec}#{now.usec}",
|
94
|
+
credit_type: ActiveMerchant::Billing::EpsilonGateway::CreditType::INSTALLMENT,
|
95
|
+
payment_time: 3,
|
96
|
+
}
|
97
|
+
end
|
98
|
+
|
99
|
+
def revolving_purchase_detail
|
100
|
+
now = Time.now
|
101
|
+
{
|
102
|
+
user_id: "U#{Time.now.to_i}",
|
103
|
+
user_name: 'YAMADA Taro',
|
104
|
+
user_email: 'yamada-taro@example.com',
|
105
|
+
item_code: 'ITEM001',
|
106
|
+
item_name: 'Greate Product',
|
107
|
+
order_number: "O#{now.sec}#{now.usec}",
|
108
|
+
credit_type: ActiveMerchant::Billing::EpsilonGateway::CreditType::REVOLVING,
|
109
|
+
}
|
110
|
+
end
|
111
|
+
|
112
|
+
def purchase_detail_for_registered
|
113
|
+
{
|
114
|
+
user_id: "U1416470209",
|
115
|
+
user_email: 'yamada-taro@example.com',
|
116
|
+
user_name: 'YAMADA TARO',
|
117
|
+
item_code: 'ITEM001',
|
118
|
+
item_name: 'Greate Product',
|
119
|
+
order_number: "O#{Time.now.to_i}",
|
120
|
+
mission_code: '6'
|
121
|
+
}
|
122
|
+
end
|
123
|
+
|
124
|
+
def valid_three_d_secure_pa_res
|
125
|
+
now = Time.now
|
126
|
+
{
|
127
|
+
order_number: "O#{now.sec}#{now.usec}",
|
128
|
+
three_d_secure_pa_res: 'xxxxxxxxxxxxxxxx',
|
129
|
+
}
|
130
|
+
end
|
131
|
+
|
132
|
+
def valid_convenience_store
|
133
|
+
ActiveMerchant::Billing::ConvenienceStore.new(
|
134
|
+
code: ActiveMerchant::Billing::ConvenienceStore::Code::LAWSON,
|
135
|
+
full_name_kana: 'ヤマダ タロウ',
|
136
|
+
phone_number: '0312345678'
|
137
|
+
)
|
138
|
+
end
|
139
|
+
|
140
|
+
def invalid_convenience_store
|
141
|
+
ActiveMerchant::Billing::ConvenienceStore.new(
|
142
|
+
code: ActiveMerchant::Billing::ConvenienceStore::Code::LAWSON,
|
143
|
+
full_name_kana: 'ヤマダ タロウ',
|
144
|
+
phone_number: '0312345678901'
|
145
|
+
)
|
146
|
+
end
|
147
|
+
|
148
|
+
def fixture_xml(filename, parse: true)
|
149
|
+
xml = File.read("test/fixtures/#{filename}")
|
150
|
+
parse ? Nokogiri.parse(xml.sub('x-sjis-cp932', 'CP932')) : xml
|
151
|
+
end
|
152
|
+
|
153
|
+
def stub_gateway(status: 200, body: nil, action: :purchase)
|
154
|
+
endpoint = ActiveMerchant::Billing::EpsilonGateway.test_url
|
155
|
+
path = ActiveMerchant::Billing::EpsilonGateway::PATHS[action]
|
156
|
+
|
157
|
+
stub_request(:post, endpoint + path).to_return(
|
158
|
+
status: status,
|
159
|
+
body: body
|
160
|
+
)
|
161
|
+
end
|
162
|
+
end
|