active_merchant-epsilon 0.9.4 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 796c4a13b9c534627b19fe2d6a4dd453fffc8e7f1f6c7fc52711d6c69d08d068
4
- data.tar.gz: cdc35c37a721d174bcb4baaae539b7181d431c4542ea38787f6809af8dcc65c7
3
+ metadata.gz: a0e846e512a231038d3e3d1c9c873fbd143f9273b5300408a7eb01ea567db19f
4
+ data.tar.gz: be1757162ec55305ba5e37faf1f78a26164cb73a5207d5395a81da6e85346535
5
5
  SHA512:
6
- metadata.gz: 825d06fe57d653ab355a609b7bc911da06064331c0cfde751bbad17d8712faf9b1a84cc1e3d5edced495c5e27d6120034c878b7f6cab4d29e554f625fb3cddb0
7
- data.tar.gz: ae1f17b24a9605299929af24ce84fe78531f372dacfd7e721252bd2dc7d68e853e65e361e747334d3192fe3558fbbd5e5def50e9293305783b991bdd02a391ef
6
+ metadata.gz: 02e58bc1a1452e386fe6ffff3eb0fed57e6bd14791969c2449e7ef86f855b3fca0ea81571d02af544554d27de66a9eeb4dab8f120e0b55727666f9ec69c5287a
7
+ data.tar.gz: bebcb439e9eb71793f08faea283f15686c662062aaa222bf14ae75961cc812c3624e7959f61da87e7ee10241b5e55bf1440f851b85d113622bd894e3429a6149
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ### 0.10.0
4
+
5
+ * [Capture authorized payments](https://github.com/pepabo/active_merchant-epsilon/pull/112)
6
+
3
7
  ### 0.9.4
4
8
 
5
9
  * [Support Epsilon Link Payment instead of GMO Payment After Delivery](https://github.com/pepabo/active_merchant-epsilon/pull/110)
@@ -19,6 +19,7 @@ module ActiveMerchant #:nodoc:
19
19
  find_user: 'get_user_info.cgi',
20
20
  change_recurring_amount: 'change_amount_payment.cgi',
21
21
  find_order: 'getsales2.cgi',
22
+ capture: 'sales_payment.cgi',
22
23
  }.freeze
23
24
 
24
25
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
@@ -51,6 +52,7 @@ module ActiveMerchant #:nodoc:
51
52
 
52
53
  params[:memo1] = detail[:memo1] if detail.has_key?(:memo1)
53
54
  params[:memo2] = detail[:memo2] if detail.has_key?(:memo2)
55
+ params[:kari_flag] = detail[:capture] ? 2 : 1 if detail.has_key?(:capture)
54
56
 
55
57
  commit(PATHS[:registered_purchase], params)
56
58
  end
@@ -83,6 +85,7 @@ module ActiveMerchant #:nodoc:
83
85
 
84
86
  params[:memo1] = detail[:memo1] if detail.has_key?(:memo1)
85
87
  params[:memo2] = detail[:memo2] if detail.has_key?(:memo2)
88
+ params[:kari_flag] = detail[:capture] ? 2 : 1 if detail.has_key?(:capture)
86
89
 
87
90
  commit(PATHS[:registered_recurring], params)
88
91
  end
@@ -182,6 +185,15 @@ module ActiveMerchant #:nodoc:
182
185
  commit(PATHS[:find_order], params, response_keys)
183
186
  end
184
187
 
188
+ def capture(order_number)
189
+ params = {
190
+ contract_code: self.contract_code,
191
+ order_number: order_number,
192
+ }
193
+
194
+ commit(PATHS[:capture], params)
195
+ end
196
+
185
197
  private
186
198
 
187
199
  def billing_params(amount, payment_method, detail)
@@ -208,6 +220,7 @@ module ActiveMerchant #:nodoc:
208
220
 
209
221
  params[:memo1] = detail[:memo1] if detail.has_key?(:memo1)
210
222
  params[:memo2] = detail[:memo2] if detail.has_key?(:memo2)
223
+ params[:kari_flag] = detail[:capture] ? 2 : 1 if detail.has_key?(:capture)
211
224
 
212
225
  if detail.has_key?(:token)
213
226
  params[:token] = detail[:token]
@@ -49,7 +49,8 @@ module ActiveMerchant #:nodoc:
49
49
  :acs_url,
50
50
  :pa_req,
51
51
  :receipt_number,
52
- :receipt_date
52
+ :receipt_date,
53
+ :captured,
53
54
  ].freeze
54
55
 
55
56
  private
@@ -123,6 +123,10 @@ module ActiveMerchant #:nodoc:
123
123
  uri_decode(@xml.xpath(ResponseXpath::REDIRECT).to_s)
124
124
  end
125
125
 
126
+ def captured
127
+ @xml.xpath(ResponseXpath::CAPTURED).to_s != '1'
128
+ end
129
+
126
130
  def uri_decode(string)
127
131
  CGI.unescape(string).encode(Encoding::UTF_8, Encoding::CP932)
128
132
  end
@@ -153,6 +157,7 @@ module ActiveMerchant #:nodoc:
153
157
  PAYMENT_CODE = '//Epsilon_result/result[@payment_code]/@payment_code'
154
158
  AMOUNT = '//Epsilon_result/result[@amount]/@amount'
155
159
  REDIRECT = '//Epsilon_result/result[@redirect]/@redirect'
160
+ CAPTURED = '//Epsilon_result/result[@kari_flag]/@kari_flag'
156
161
  end
157
162
 
158
163
  module ResultCode
@@ -1,5 +1,5 @@
1
1
  module ActiveMerchant
2
2
  module Epsilon
3
- VERSION = "0.9.4"
3
+ VERSION = "0.10.0"
4
4
  end
5
5
  end
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/sales_payment.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&order_number=1234567890
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ Connection:
13
+ - close
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 12 Jun 2020 11:00:12 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml; charset=CP932
35
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ <?xml version="1.0" encoding="x-sjis-cp932"?>
39
+ <Epsilon_result>
40
+ <result err_code="810" />
41
+ <result err_detail="%91%CE%8F%DB%8E%E6%88%F8%82%CD%82%A0%82%E8%82%DC%82%B9%82%F1" />
42
+ <result result="9" />
43
+ </Epsilon_result>
44
+ recorded_at: Fri, 12 Jun 2020 11:00:14 GMT
45
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/sales_payment.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&order_number=O14289569
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ Connection:
13
+ - close
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 12 Jun 2020 11:00:16 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml; charset=CP932
35
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ <?xml version="1.0" encoding="x-sjis-cp932"?>
39
+ <Epsilon_result>
40
+ <result err_code="" />
41
+ <result err_detail="" />
42
+ <result result="1" />
43
+ </Epsilon_result>
44
+ recorded_at: Fri, 12 Jun 2020 11:00:17 GMT
45
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,49 @@
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: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1591959614&user_name=YAMADA+Taro&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Greate+Product&order_number=O14289569&st_code=10000-0000-0000&mission_code=1&kari_flag=1&item_price=100&process_code=1&card_number=4242424242424242&expire_y=2021&expire_m=10&card_st_code=&pay_time=&tds_check_code=&user_agent=ActiveMerchant%3A%3AEpsilon-0.9.4&memo1=memo1&memo2=memo2
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ Connection:
13
+ - close
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 12 Jun 2020 11:00:15 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml; charset=CP932
35
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ <?xml version="1.0" encoding="x-sjis-cp932"?>
39
+ <Epsilon_result>
40
+ <result acsurl="" />
41
+ <result err_code="" />
42
+ <result err_detail="" />
43
+ <result kari_flag="1" />
44
+ <result pareq="" />
45
+ <result result="1" />
46
+ <result trans_code="1362118" />
47
+ </Epsilon_result>
48
+ recorded_at: Fri, 12 Jun 2020 11:00:16 GMT
49
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,49 @@
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: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1591960355&user_name=YAMADA+Taro&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Greate+Product&order_number=O35284193&st_code=10000-0000-0000&mission_code=1&item_price=1000&process_code=1&card_number=4242424242424242&expire_y=2021&expire_m=10&card_st_code=&pay_time=&tds_check_code=&user_agent=ActiveMerchant%3A%3AEpsilon-0.9.4&memo1=memo1&memo2=memo2&kari_flag=1
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ Connection:
13
+ - close
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 12 Jun 2020 11:12:35 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml; charset=CP932
35
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ <?xml version="1.0" encoding="x-sjis-cp932"?>
39
+ <Epsilon_result>
40
+ <result acsurl="" />
41
+ <result err_code="" />
42
+ <result err_detail="" />
43
+ <result kari_flag="1" />
44
+ <result pareq="" />
45
+ <result result="1" />
46
+ <result trans_code="1362123" />
47
+ </Epsilon_result>
48
+ recorded_at: Fri, 12 Jun 2020 11:12:37 GMT
49
+ recorded_with: VCR 6.0.0
@@ -0,0 +1,49 @@
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: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1591960357&user_name=YAMADA+Taro&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Greate+Product&order_number=O37368550&st_code=10000-0000-0000&mission_code=1&item_price=1000&process_code=1&card_number=4242424242424242&expire_y=2021&expire_m=10&card_st_code=&pay_time=&tds_check_code=&user_agent=ActiveMerchant%3A%3AEpsilon-0.9.4&memo1=memo1&memo2=memo2&kari_flag=2
9
+ headers:
10
+ Content-Type:
11
+ - application/x-www-form-urlencoded
12
+ Connection:
13
+ - close
14
+ Accept-Encoding:
15
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
16
+ Accept:
17
+ - "*/*"
18
+ User-Agent:
19
+ - Ruby
20
+ response:
21
+ status:
22
+ code: 200
23
+ message: OK
24
+ headers:
25
+ Date:
26
+ - Fri, 12 Jun 2020 11:12:37 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml; charset=CP932
35
+ body:
36
+ encoding: UTF-8
37
+ string: |-
38
+ <?xml version="1.0" encoding="x-sjis-cp932"?>
39
+ <Epsilon_result>
40
+ <result acsurl="" />
41
+ <result err_code="" />
42
+ <result err_detail="" />
43
+ <result kari_flag="0" />
44
+ <result pareq="" />
45
+ <result result="1" />
46
+ <result trans_code="1362124" />
47
+ </Epsilon_result>
48
+ recorded_at: Fri, 12 Jun 2020 11:12:39 GMT
49
+ recorded_with: VCR 6.0.0
@@ -72,6 +72,24 @@ class RemoteEpsilonGatewayTest < MiniTest::Test
72
72
  end
73
73
  end
74
74
 
75
+ def test_purchase_with_capture_true_successful
76
+ VCR.use_cassette(:purchase_with_capture_true_successful) do
77
+ response = gateway.purchase(1000, valid_credit_card, purchase_detail.merge(capture: true))
78
+
79
+ assert_equal true, response.success?
80
+ assert_equal true, response.params['captured']
81
+ end
82
+ end
83
+
84
+ def test_purchase_with_capture_false_successful
85
+ VCR.use_cassette(:purchase_with_capture_false_successful) do
86
+ response = gateway.purchase(1000, valid_credit_card, purchase_detail.merge(capture: false))
87
+
88
+ assert_equal true, response.success?
89
+ assert_equal false, response.params['captured']
90
+ end
91
+ end
92
+
75
93
  def test_purchase_fail
76
94
  VCR.use_cassette(:purchase_fail) do
77
95
  response = gateway.purchase(10000, invalid_credit_card, purchase_detail)
@@ -286,4 +304,27 @@ class RemoteEpsilonGatewayTest < MiniTest::Test
286
304
  assert_equal false, response.success?
287
305
  end
288
306
  end
307
+
308
+ def test_capture_success
309
+ detail = purchase_detail
310
+
311
+ VCR.use_cassette(:capture_success_authorize) do
312
+ purchase_response = gateway.purchase(100, valid_credit_card, detail.merge(capture: false))
313
+
314
+ assert_equal true, purchase_response.success?
315
+ assert_equal false, purchase_response.params['captured']
316
+ end
317
+
318
+ VCR.use_cassette(:capture_success) do
319
+ response = gateway.capture(detail[:order_number])
320
+ assert_equal true, response.success?
321
+ end
322
+ end
323
+
324
+ def test_capture_failure
325
+ VCR.use_cassette(:capture_failure) do
326
+ response = gateway.capture('1234567890')
327
+ assert_equal false, response.success?
328
+ end
329
+ end
289
330
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_merchant-epsilon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.4
4
+ version: 0.10.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi TAKAHASHI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-30 00:00:00.000000000 Z
11
+ date: 2020-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -181,6 +181,9 @@ files:
181
181
  - test/fixtures/vcr_cassettes/autheticate_three_d_secure_card_successful.yml
182
182
  - test/fixtures/vcr_cassettes/cancel_recurring_fail.yml
183
183
  - test/fixtures/vcr_cassettes/cancel_recurring_successful.yml
184
+ - test/fixtures/vcr_cassettes/capture_failure.yml
185
+ - test/fixtures/vcr_cassettes/capture_success.yml
186
+ - test/fixtures/vcr_cassettes/capture_success_authorize.yml
184
187
  - test/fixtures/vcr_cassettes/change_recurring_amount_failure.yml
185
188
  - test/fixtures/vcr_cassettes/change_recurring_amount_successful.yml
186
189
  - test/fixtures/vcr_cassettes/convenience_store_purchase_fail.yml
@@ -198,6 +201,8 @@ files:
198
201
  - test/fixtures/vcr_cassettes/installment_purchase_successful.yml
199
202
  - test/fixtures/vcr_cassettes/purchase_fail.yml
200
203
  - test/fixtures/vcr_cassettes/purchase_successful.yml
204
+ - test/fixtures/vcr_cassettes/purchase_with_capture_false_successful.yml
205
+ - test/fixtures/vcr_cassettes/purchase_with_capture_true_successful.yml
201
206
  - test/fixtures/vcr_cassettes/purchase_with_three_d_secure_card_successful.yml
202
207
  - test/fixtures/vcr_cassettes/purchase_with_verification_value.yml
203
208
  - test/fixtures/vcr_cassettes/recurring_fail.yml
@@ -252,6 +257,9 @@ test_files:
252
257
  - test/fixtures/vcr_cassettes/autheticate_three_d_secure_card_successful.yml
253
258
  - test/fixtures/vcr_cassettes/cancel_recurring_fail.yml
254
259
  - test/fixtures/vcr_cassettes/cancel_recurring_successful.yml
260
+ - test/fixtures/vcr_cassettes/capture_failure.yml
261
+ - test/fixtures/vcr_cassettes/capture_success.yml
262
+ - test/fixtures/vcr_cassettes/capture_success_authorize.yml
255
263
  - test/fixtures/vcr_cassettes/change_recurring_amount_failure.yml
256
264
  - test/fixtures/vcr_cassettes/change_recurring_amount_successful.yml
257
265
  - test/fixtures/vcr_cassettes/convenience_store_purchase_fail.yml
@@ -269,6 +277,8 @@ test_files:
269
277
  - test/fixtures/vcr_cassettes/installment_purchase_successful.yml
270
278
  - test/fixtures/vcr_cassettes/purchase_fail.yml
271
279
  - test/fixtures/vcr_cassettes/purchase_successful.yml
280
+ - test/fixtures/vcr_cassettes/purchase_with_capture_false_successful.yml
281
+ - test/fixtures/vcr_cassettes/purchase_with_capture_true_successful.yml
272
282
  - test/fixtures/vcr_cassettes/purchase_with_three_d_secure_card_successful.yml
273
283
  - test/fixtures/vcr_cassettes/purchase_with_verification_value.yml
274
284
  - test/fixtures/vcr_cassettes/recurring_fail.yml