active_merchant-epsilon 0.7.1 → 0.8.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: de613713996b163807e1009830cbf15483bcffb5
4
- data.tar.gz: ff296596a2714652296dcd1987041bb91c0d57d5
2
+ SHA256:
3
+ metadata.gz: 96900bb6e2ffe304af0dd4e77038ebd866ba35a4f6353c325c3f710fbee92d32
4
+ data.tar.gz: 0460b0c1188422cf7284909c7d1afe652288213a755a6e578f85ea4e694ca496
5
5
  SHA512:
6
- metadata.gz: 8dbb68b9951e5b8d356cfb01f4d60e7ec1b1e4ce09d39e25633b2a1e959cef2c510cc37d7fae32c5197528e17790efb312497639bb421fd26f1c4bb0ca5a71d6
7
- data.tar.gz: 93e4804adfc464e0302d76e25cc9a6d957d00f8947f27f8e89f5b51396be2ed7fb989e8b16ac66d2ac313a289439a53389ac071b6d3f879085582450de341fce
6
+ metadata.gz: 7819f8f373f75271064d3c4183c9887bc0c96d2bf0c3fb53961eaa0a77f544e062174d88111e49757c34da816a71d9da3b5b72254507d34e65393d4341dca54f
7
+ data.tar.gz: 55a59a130cce776f5a61d7193604421267c7796167e514bfd28b0852225458a846dc170bcf1d4cf072ee09ea80a037c5a538de386d9abf30ec81d422675ab10a
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ### 0.8.0
4
+ * GMO IDに登録されているクレジットカードで決済できるようにしました。
5
+ * [GMO ID決済の機能を追加した by ryuchan00](https://github.com/pepabo/active_merchant-epsilon/pull/93)
6
+
3
7
  ### 0.5.9
4
8
 
5
9
  * 都度課金、定期課金、コンビニ決済で memo1, memo2 を送信できるようにした #83
data/README.md CHANGED
@@ -217,7 +217,7 @@ if credit_card.validate.empty?
217
217
  end
218
218
  ```
219
219
 
220
- ### Recurring Billing (Monthly subscritpion)
220
+ ### Recurring Billing (Monthly subscriptions)
221
221
 
222
222
  ```ruby
223
223
  purchase_detail[:mission_code] = ActiveMerchant::Billing::EpsilonGateway::MissionCode::RECURRING_6
@@ -243,6 +243,35 @@ gateway.void('order_number')
243
243
  gateway.verify(credit_card, user_id: 'user_id', user_email: 'user@example.com')
244
244
  ```
245
245
 
246
+ ### GMO ID Settlement
247
+
248
+ ```ruby
249
+ ActiveMerchant::Billing::EpsilonGmoIdGateway.contract_code = 'YOUR_CONTRACT_CODE'
250
+
251
+ gateway = ActiveMerchant::Billing::EpsilonGmoIdGateway.new
252
+
253
+ amount = 10000
254
+
255
+ purchase_detail = {
256
+ user_id: 'YOUR_APP_USER_IDENTIFIER',
257
+ user_email: 'yamada-taro@example.com',
258
+ user_name: 'YAMADA TARO',
259
+ item_code: 'ITEM001',
260
+ item_name: 'Golden Product',
261
+ order_number: 'UNIQUE ORDER NUMBER',
262
+ gmo_id: 'Your member id of GMO ID',
263
+ gmo_card_id: 'Your sequential card number of GMO ID',
264
+ }
265
+
266
+ gateway.purchase(amount, purchase_detail)
267
+ ```
268
+
269
+ ### GMO ID Settlement Void Transaction
270
+
271
+ ```ruby
272
+ gateway.void('order_number')
273
+ ```
274
+
246
275
  ### Error handling
247
276
 
248
277
  If epsilon server returns status excepted 200, `#purchase` method raise `ActiveMerchant::ResponseError`.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require "bundler/gem_tasks"
2
2
  require 'rake/testtask'
3
3
 
4
4
  desc 'Run the unit test suite'
5
- task :defualt => 'test:unit'
5
+ task :default => 'test:unit'
6
6
 
7
7
  namespace :test do
8
8
  Rake::TestTask.new(:unit) do |t|
@@ -0,0 +1,13 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ module EpsilonProcessCode
4
+ FIRST = 1 # 初回課金
5
+ REGISTERED = 2 # 登録済み課金
6
+ ONLY_REGISTER = 3 # 登録のみ
7
+ CHANGE_INFORMATION = 4 # 登録内容変更
8
+ CANCEL_DELETE_ACCOUNT = 7 # 退会取り消し
9
+ CANCEL_MONTHLY = 8 # 月次課金解除
10
+ DELETE_ACCOUNT = 9 # 退会
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,39 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class EpsilonGmoIdGateway < EpsilonBaseGateway
4
+ PATHS = {
5
+ purchase: 'receive_order_gmo2.cgi',
6
+ void: 'cancel_payment.cgi',
7
+ }.freeze
8
+
9
+ def purchase(amount, detail = {})
10
+ params = {
11
+ contract_code: self.contract_code,
12
+ user_id: detail[:user_id],
13
+ user_name: detail[:user_name],
14
+ user_mail_add: detail[:user_email],
15
+ item_code: detail[:item_code],
16
+ item_name: detail[:item_name],
17
+ order_number: detail[:order_number],
18
+ st_code: '10000-0000-00000-00000-00000-00000-00000',
19
+ mission_code: EpsilonMissionCode::PURCHASE,
20
+ item_price: amount,
21
+ process_code: EpsilonProcessCode::REGISTERED,
22
+ gmo_id: detail[:gmo_id],
23
+ gmo_card_id: detail[:gmo_card_id],
24
+ }
25
+
26
+ commit(PATHS[:purchase], params)
27
+ end
28
+
29
+ def void(order_number)
30
+ params = {
31
+ contract_code: self.contract_code,
32
+ order_number: order_number,
33
+ }
34
+
35
+ commit(PATHS[:void], params)
36
+ end
37
+ end
38
+ end
39
+ end
@@ -4,7 +4,9 @@ require_relative 'epsilon/version'
4
4
 
5
5
  require_relative 'billing/convenience_store'
6
6
  require_relative 'billing/gateways/epsilon/epsilon_mission_code'
7
+ require_relative 'billing/gateways/epsilon/epsilon_process_code'
7
8
  require_relative 'billing/gateways/epsilon/epsilon_base'
8
9
  require_relative 'billing/gateways/epsilon'
9
10
  require_relative 'billing/gateways/epslion_convenience_store'
11
+ require_relative 'billing/gateways/epsilon_gmo_id'
10
12
  require_relative 'billing/gateways/response_parser'
@@ -1,5 +1,5 @@
1
1
  module ActiveMerchant
2
2
  module Epsilon
3
- VERSION = "0.7.1"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -0,0 +1,39 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/receive_order_gmo2.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1522814256&user_name=YAMADA+TARO&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Golden+Product&order_number=O1522814256&st_code=10000-0000-00000-00000-00000-00000-00000&mission_code=1&item_price=200&process_code=2&gmo_id=[GMO_ID]&gmo_card_id=invail+id
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, 04 Apr 2018 03:57:36 GMT
25
+ Server:
26
+ - Apache
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Content-Type:
30
+ - text/xml
31
+ body:
32
+ encoding: UTF-8
33
+ string: "<?xml version=\"1.0\" encoding=\"x-sjis-cp932\" ?>\r\n<Epsilon_result>\r\n
34
+ \ <result trans_code=\"708876\" />\r\n <result result=\"9\" />\r\n <result
35
+ err_code=\"601\" />\r\n <result err_detail=\"%89%EF%88%F5%83N%83%8C%83W%83b%83g%83J%81%5B%83h%83V%81%5B%83P%83%93%83X%94%D4%8D%86%82%AA%95s%90%B3%82%C5%82%B7\"
36
+ />\r\n</Epsilon_result>\r\n"
37
+ http_version:
38
+ recorded_at: Wed, 04 Apr 2018 03:57:36 GMT
39
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,38 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/receive_order_gmo2.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1522814260&user_name=YAMADA+TARO&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Golden+Product&order_number=O1522814260&st_code=10000-0000-00000-00000-00000-00000-00000&mission_code=1&item_price=200&process_code=2&gmo_id=[GMO_ID]&gmo_card_id=[GMO_CARD_ID]
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, 04 Apr 2018 03:57:40 GMT
25
+ Server:
26
+ - Apache
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Content-Type:
30
+ - text/xml
31
+ body:
32
+ encoding: UTF-8
33
+ string: "<?xml version=\"1.0\" encoding=\"x-sjis-cp932\" ?>\r\n<Epsilon_result>\r\n
34
+ \ <result trans_code=\"708878\" />\r\n <result result=\"1\" />\r\n <result
35
+ err_code=\"\" />\r\n <result err_detail=\"\" />\r\n</Epsilon_result>\r\n"
36
+ http_version:
37
+ recorded_at: Wed, 04 Apr 2018 03:57:42 GMT
38
+ recorded_with: VCR 4.0.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: UTF-8
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, 04 Apr 2018 03:57:35 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="" />
37
+ <result err_detail="" />
38
+ <result result="" />
39
+ </Epsilon_result>
40
+ http_version:
41
+ recorded_at: Wed, 04 Apr 2018 03:57:36 GMT
42
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,77 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/receive_order_gmo2.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1522814256&user_name=YAMADA+TARO&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Golden+Product&order_number=O1522814256&st_code=10000-0000-00000-00000-00000-00000-00000&mission_code=1&item_price=200&process_code=2&gmo_id=[GMO_ID]&gmo_card_id=[GMO_CARD_ID]
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, 04 Apr 2018 03:57:37 GMT
25
+ Server:
26
+ - Apache
27
+ Transfer-Encoding:
28
+ - chunked
29
+ Content-Type:
30
+ - text/xml
31
+ body:
32
+ encoding: UTF-8
33
+ string: "<?xml version=\"1.0\" encoding=\"x-sjis-cp932\" ?>\r\n<Epsilon_result>\r\n
34
+ \ <result trans_code=\"708876\" />\r\n <result result=\"1\" />\r\n <result
35
+ err_code=\"\" />\r\n <result err_detail=\"\" />\r\n</Epsilon_result>\r\n"
36
+ http_version:
37
+ recorded_at: Wed, 04 Apr 2018 03:57:39 GMT
38
+ - request:
39
+ method: post
40
+ uri: https://beta.epsilon.jp/cgi-bin/order/cancel_payment.cgi
41
+ body:
42
+ encoding: UTF-8
43
+ string: contract_code=[CONTRACT_CODE]&order_number=O1522814256
44
+ headers:
45
+ Content-Type:
46
+ - application/x-www-form-urlencoded
47
+ Accept-Encoding:
48
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
49
+ Accept:
50
+ - "*/*"
51
+ User-Agent:
52
+ - Ruby
53
+ response:
54
+ status:
55
+ code: 200
56
+ message: OK
57
+ headers:
58
+ Date:
59
+ - Wed, 04 Apr 2018 03:57:39 GMT
60
+ Server:
61
+ - Apache
62
+ Transfer-Encoding:
63
+ - chunked
64
+ Content-Type:
65
+ - text/xml; charset=CP932
66
+ body:
67
+ encoding: UTF-8
68
+ string: |-
69
+ <?xml version="1.0" encoding="x-sjis-cp932"?>
70
+ <Epsilon_result>
71
+ <result err_code="" />
72
+ <result err_detail="" />
73
+ <result result="1" />
74
+ </Epsilon_result>
75
+ http_version:
76
+ recorded_at: Wed, 04 Apr 2018 03:57:40 GMT
77
+ recorded_with: VCR 4.0.0
@@ -0,0 +1,44 @@
1
+ require 'test_helper'
2
+
3
+ class RemoteEpsilonGmoIdGatewayTest < MiniTest::Test
4
+ include SamplePaymentMethods
5
+
6
+ def gateway
7
+ @gateway ||= ActiveMerchant::Billing::EpsilonGmoIdGateway.new
8
+ end
9
+
10
+ def test_gmo_id_purchase_successful
11
+ VCR.use_cassette(:gmo_id_purchase_successful) do
12
+ detail = valid_gmo_id_purchase_detail
13
+ response = gateway.purchase(200, detail)
14
+ assert_equal true, response.success?
15
+ end
16
+ end
17
+
18
+ def test_gmo_id_purchase_failure
19
+ VCR.use_cassette(:gmo_id_purchase_failure) do
20
+ detail = invalid_gmo_id_purchase_detail
21
+ response = gateway.purchase(200, detail)
22
+ assert_equal false, response.success?
23
+ end
24
+ end
25
+
26
+ def test_gmo_id_void_successful
27
+ VCR.use_cassette(:gmo_id_void_successful) do
28
+ # purchase
29
+ detail = valid_gmo_id_purchase_detail
30
+ response = gateway.purchase(200, detail)
31
+ assert_equal true, response.success?
32
+ # void
33
+ response = gateway.void(detail[:order_number])
34
+ assert_equal true, response.success?
35
+ end
36
+ end
37
+
38
+ def test_gmo_id_void_faiure
39
+ VCR.use_cassette(:gmo_id_void_faiure) do
40
+ response = gateway.void('1234567890')
41
+ assert_equal false, response.success?
42
+ end
43
+ end
44
+ end
@@ -23,6 +23,8 @@ VCR.configure do |c|
23
23
  c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
24
24
  c.hook_into :webmock
25
25
  c.filter_sensitive_data('[CONTRACT_CODE]') { ENV['CONTRACT_CODE'] }
26
+ c.filter_sensitive_data('[GMO_ID]') { ENV['GMO_ID'] }
27
+ c.filter_sensitive_data('gmo_card_id=[GMO_CARD_ID]') { "gmo_card_id=#{ENV['GMO_CARD_ID']}" } # GMO CARD ID is not unique.
26
28
  end
27
29
 
28
30
  module SamplePaymentMethods
@@ -178,6 +180,32 @@ module SamplePaymentMethods
178
180
  )
179
181
  end
180
182
 
183
+ def valid_gmo_id_purchase_detail
184
+ {
185
+ user_id: "U#{Time.now.to_i}",
186
+ user_email: 'yamada-taro@example.com',
187
+ user_name: 'YAMADA TARO',
188
+ item_code: 'ITEM001',
189
+ item_name: 'Golden Product',
190
+ order_number: "O#{Time.now.to_i}",
191
+ gmo_id: ENV['GMO_ID'],
192
+ gmo_card_id: ENV['GMO_CARD_ID'],
193
+ }
194
+ end
195
+
196
+ def invalid_gmo_id_purchase_detail
197
+ {
198
+ user_id: "U#{Time.now.to_i}",
199
+ user_email: 'yamada-taro@example.com',
200
+ user_name: 'YAMADA TARO',
201
+ item_code: 'ITEM001',
202
+ item_name: 'Golden Product',
203
+ order_number: "O#{Time.now.to_i}",
204
+ gmo_id: ENV['GMO_ID'],
205
+ gmo_card_id: 'invail id',
206
+ }
207
+ end
208
+
181
209
  def fixture_xml(filename, parse: true)
182
210
  xml = File.read("test/fixtures/#{filename}")
183
211
  parse ? Nokogiri.parse(xml.sub('x-sjis-cp932', 'CP932')) : xml
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.7.1
4
+ version: 0.8.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: 2017-10-25 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -170,6 +170,8 @@ files:
170
170
  - lib/active_merchant/billing/gateways/epsilon.rb
171
171
  - lib/active_merchant/billing/gateways/epsilon/epsilon_base.rb
172
172
  - lib/active_merchant/billing/gateways/epsilon/epsilon_mission_code.rb
173
+ - lib/active_merchant/billing/gateways/epsilon/epsilon_process_code.rb
174
+ - lib/active_merchant/billing/gateways/epsilon_gmo_id.rb
173
175
  - lib/active_merchant/billing/gateways/epslion_convenience_store.rb
174
176
  - lib/active_merchant/billing/gateways/response_parser.rb
175
177
  - lib/active_merchant/epsilon.rb
@@ -183,6 +185,10 @@ files:
183
185
  - test/fixtures/vcr_cassettes/convenience_store_purchase_successful.yml
184
186
  - test/fixtures/vcr_cassettes/find_user_failure.yml
185
187
  - test/fixtures/vcr_cassettes/find_user_success.yml
188
+ - test/fixtures/vcr_cassettes/gmo_id_purchase_failure.yml
189
+ - test/fixtures/vcr_cassettes/gmo_id_purchase_successful.yml
190
+ - test/fixtures/vcr_cassettes/gmo_id_void_faiure.yml
191
+ - test/fixtures/vcr_cassettes/gmo_id_void_successful.yml
186
192
  - test/fixtures/vcr_cassettes/installment_purchase_successful.yml
187
193
  - test/fixtures/vcr_cassettes/purchase_fail.yml
188
194
  - test/fixtures/vcr_cassettes/purchase_successful.yml
@@ -204,6 +210,7 @@ files:
204
210
  - test/fixtures/vcr_cassettes/void_fail.yml
205
211
  - test/fixtures/vcr_cassettes/void_successful.yml
206
212
  - test/remote/gateways/remote_epsilon_convenience_store_test.rb
213
+ - test/remote/gateways/remote_epsilon_gmo_id_test.rb
207
214
  - test/remote/gateways/remote_epsilon_test.rb
208
215
  - test/test_helper.rb
209
216
  - test/unit/billing/convenience_store_test.rb
@@ -228,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
228
235
  version: '0'
229
236
  requirements: []
230
237
  rubyforge_project:
231
- rubygems_version: 2.6.13
238
+ rubygems_version: 2.7.6
232
239
  signing_key:
233
240
  specification_version: 4
234
241
  summary: Epsilon integration for ActiveMerchant.
@@ -242,6 +249,10 @@ test_files:
242
249
  - test/fixtures/vcr_cassettes/convenience_store_purchase_successful.yml
243
250
  - test/fixtures/vcr_cassettes/find_user_failure.yml
244
251
  - test/fixtures/vcr_cassettes/find_user_success.yml
252
+ - test/fixtures/vcr_cassettes/gmo_id_purchase_failure.yml
253
+ - test/fixtures/vcr_cassettes/gmo_id_purchase_successful.yml
254
+ - test/fixtures/vcr_cassettes/gmo_id_void_faiure.yml
255
+ - test/fixtures/vcr_cassettes/gmo_id_void_successful.yml
245
256
  - test/fixtures/vcr_cassettes/installment_purchase_successful.yml
246
257
  - test/fixtures/vcr_cassettes/purchase_fail.yml
247
258
  - test/fixtures/vcr_cassettes/purchase_successful.yml
@@ -263,6 +274,7 @@ test_files:
263
274
  - test/fixtures/vcr_cassettes/void_fail.yml
264
275
  - test/fixtures/vcr_cassettes/void_successful.yml
265
276
  - test/remote/gateways/remote_epsilon_convenience_store_test.rb
277
+ - test/remote/gateways/remote_epsilon_gmo_id_test.rb
266
278
  - test/remote/gateways/remote_epsilon_test.rb
267
279
  - test/test_helper.rb
268
280
  - test/unit/billing/convenience_store_test.rb