active_merchant-epsilon 0.9.1 → 0.9.2

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
- SHA1:
3
- metadata.gz: 47c8ebb3aaa32f424787d2b5c842250ee06aeb65
4
- data.tar.gz: 4feb0998d3dc9422908b18c17867e0fbab12f404
2
+ SHA256:
3
+ metadata.gz: 915567d0ef3dfd3c77a829198bcf4fbc62e29a2a8bc5840b99c6ce1ae8337073
4
+ data.tar.gz: f95f8b2405b3e6b9139688157ceeb962789a72bfe83f251503879dd1ff128c84
5
5
  SHA512:
6
- metadata.gz: c2d4ea004d1f5e2b511c3ac8722389b98f790bc17bd9970a8bdc01724e7ab7323bbfb44ca3f2ae49d2ac2f26f08a25bd5a094bfdad821b78a37cc7dc7532dfe8
7
- data.tar.gz: 4ac64c7b58f282109c8edcbdb96394926d98947549aa3a333b36cffba8c304d3c32ac72a4b5eb2e9c7348b6056c2eab540c1d08e9eafd2e4a300efcdd7c75b17
6
+ metadata.gz: f958bcbe2ab8f3cbe876396b4460017c38e65aa1ec8f8140326a3f65185612ab9a8bc89d57be4f3d4aafe9b06aa2dbf4eafee7e419553739dfb6300cc6f65418
7
+ data.tar.gz: 79bd291e76a237d3a478bfd1c76bc4b28c9edc1e99d5f0ab990e282485af9630ce2822f2f0874cfacd7df6789b8bf885e2e4a13ac5ab995d5bb6789fd2222bba
data/.travis.yml CHANGED
@@ -1,8 +1,8 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 2.1.7
4
- - 2.2.3
5
- - 2.3.0
3
+ - 2.3.8
4
+ - 2.4.5
5
+ - 2.5.3
6
6
 
7
7
  script: bundle exec rake test:remote
8
8
  script: bundle exec rake test:unit
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # CHANGELOG
2
2
 
3
+ ### 0.9.2
4
+
5
+ * [Support GMO Payment After Delivery](https://github.com/pepabo/active_merchant-epsilon/pull/106)
6
+
3
7
  ### 0.9.1
4
8
 
5
9
  * [Add amount to response parameters when find order](https://github.com/pepabo/active_merchant-epsilon/pull/99)
data/README.md CHANGED
@@ -302,6 +302,45 @@ else
302
302
  end
303
303
  ```
304
304
 
305
+ ### GMO Payment After Delivery
306
+
307
+ ```ruby
308
+ ActiveMerchant::Billing::EpsilonGmoAfterGateway.contract_code = 'YOUR_CONTRACT_CODE'
309
+
310
+ gateway = ActiveMerchant::Billing::EpsilonGmoAfterGateway.new
311
+
312
+ amount = 10000
313
+
314
+ purchase_detail = {
315
+ user_id: 'YOUR_APP_USER_IDENTIFIER',
316
+ user_name: '山田 太郎',
317
+ user_email: 'yamada-taro@example.com',
318
+ user_tel: '0312345678',
319
+ item_code: 'ITEM001',
320
+ item_name: 'Greate Product',
321
+ order_number: 'UNIQUE ORDER NUMBER',
322
+ consignee_postal: '1500002',
323
+ consignee_name: '山田 太郎',
324
+ consignee_address: '東京都渋谷区1-1-1',
325
+ consignee_tel: '0312345678',
326
+ orderer_postal: '1500002',
327
+ orderer_name: '山田 太郎',
328
+ orderer_address: '東京都渋谷区1-1-1',
329
+ orderer_tel: '0312345678',
330
+ memo1: 'memo1',
331
+ memo2: 'memo2',
332
+ }
333
+
334
+ response = gateway.purchase(amount, purchase_detail)
335
+
336
+ if response.success?
337
+ puts "Successfully send order data"
338
+ puts "Redirect url is #{response.params['redirect']}"
339
+ else
340
+ raise StandardError, response.message
341
+ end
342
+ ```
343
+
305
344
  ### Error handling
306
345
 
307
346
  If epsilon server returns status excepted 200, `#purchase` method raise `ActiveMerchant::ResponseError`.
@@ -18,13 +18,13 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ['lib']
20
20
 
21
- spec.add_dependency 'activemerchant', '~> 1.66.0'
21
+ spec.add_dependency 'activemerchant', '~> 1.88'
22
22
  spec.add_dependency 'nokogiri'
23
23
 
24
- spec.add_development_dependency 'bundler', '~> 1.7'
24
+ spec.add_development_dependency 'bundler'
25
25
  spec.add_development_dependency 'dotenv'
26
26
  spec.add_development_dependency 'pry-byebug'
27
- spec.add_development_dependency 'rake', '~> 10.0'
27
+ spec.add_development_dependency 'rake'
28
28
  spec.add_development_dependency 'tapp'
29
29
  spec.add_development_dependency 'webmock'
30
30
  spec.add_development_dependency 'vcr'
@@ -0,0 +1,38 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class EpsilonGmoAfterGateway < EpsilonBaseGateway
4
+ def purchase(amount, detail = {})
5
+ params = {
6
+ contract_code: self.contract_code,
7
+ user_id: detail[:user_id],
8
+ user_name: detail[:user_name],
9
+ user_mail_add: detail[:user_email],
10
+ item_code: detail[:item_code],
11
+ item_name: detail[:item_name],
12
+ order_number: detail[:order_number],
13
+ st_code: '00000-0000-00000-00010-00000-00000-00000',
14
+ mission_code: EpsilonMissionCode::PURCHASE,
15
+ item_price: amount,
16
+ process_code: EpsilonProcessCode::FIRST,
17
+ xml: 1, # 応答形式。1: xml形式を固定
18
+ delivery_code: 99, # 配送区分。99で固定
19
+ consignee_postal: detail[:consignee_postal],
20
+ consignee_name: detail[:consignee_name],
21
+ consignee_address: detail[:consignee_address],
22
+ consignee_tel: detail[:consignee_tel],
23
+ orderer_postal: detail[:orderer_postal],
24
+ orderer_name: detail[:orderer_name],
25
+ orderer_address: detail[:orderer_address],
26
+ orderer_tel: detail[:orderer_tel],
27
+ version: 2, # 推奨文字コードがUTF8の方を指定
28
+ }
29
+
30
+ params[:memo1] = detail[:memo1] if detail.has_key?(:memo1)
31
+ params[:memo2] = detail[:memo2] if detail.has_key?(:memo2)
32
+ params[:user_tel] = detail[:user_tel] if detail.has_key?(:user_tel)
33
+
34
+ commit('receive_order3.cgi', params, [:redirect])
35
+ end
36
+ end
37
+ end
38
+ end
@@ -1,3 +1,5 @@
1
+ require 'cgi'
2
+
1
3
  module ActiveMerchant #:nodoc:
2
4
  module Billing #:nodoc:
3
5
  class ResponseParser
@@ -117,8 +119,18 @@ module ActiveMerchant #:nodoc:
117
119
  @xml.xpath(ResponseXpath::AMOUNT).to_s
118
120
  end
119
121
 
122
+ def redirect
123
+ uri_decode(@xml.xpath(ResponseXpath::REDIRECT).to_s)
124
+ end
125
+
120
126
  def uri_decode(string)
121
- URI.decode(string).encode(Encoding::UTF_8, Encoding::CP932)
127
+ decoded_string = CGI.unescape(string)
128
+
129
+ unless decoded_string.encoding == Encoding::UTF_8
130
+ decoded_string = decoded_string.encode(Encoding::UTF_8, Encoding::CP932)
131
+ end
132
+
133
+ decoded_string
122
134
  end
123
135
 
124
136
  module ResponseXpath
@@ -146,6 +158,7 @@ module ActiveMerchant #:nodoc:
146
158
  ITEM_PRICE = '//Epsilon_result/result[@item_price]/@item_price'
147
159
  PAYMENT_CODE = '//Epsilon_result/result[@payment_code]/@payment_code'
148
160
  AMOUNT = '//Epsilon_result/result[@amount]/@amount'
161
+ REDIRECT = '//Epsilon_result/result[@redirect]/@redirect'
149
162
  end
150
163
 
151
164
  module ResultCode
@@ -10,4 +10,5 @@ require_relative 'billing/gateways/epsilon'
10
10
  require_relative 'billing/gateways/epsilon_convenience_store'
11
11
  require_relative 'billing/gateways/epsilon_gmo_id'
12
12
  require_relative 'billing/gateways/epsilon_virtual_account'
13
+ require_relative 'billing/gateways/epsilon_gmo_after'
13
14
  require_relative 'billing/gateways/response_parser'
@@ -1,5 +1,5 @@
1
1
  module ActiveMerchant
2
2
  module Epsilon
3
- VERSION = "0.9.1"
3
+ VERSION = "0.9.2"
4
4
  end
5
5
  end
@@ -0,0 +1,44 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/receive_order3.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=&user_name=YAMADA+Taro&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Greate+Product&order_number=O2665045&st_code=00000-0000-00000-00010-00000-00000-00000&mission_code=1&item_price=10000&process_code=1&xml=1&delivery_code=99&consignee_postal=1500002&consignee_name=%E3%82%A4%E3%83%97%E3%82%B7%E3%83%AD%E3%83%B3%E3%82%BF%E3%83%AD%E3%82%A6&consignee_address=%E6%9D%B1%E4%BA%AC%E9%83%BD%E6%B8%8B%E8%B0%B7%E5%8C%BA%EF%BC%91%E2%88%92%EF%BC%91%E2%88%92%EF%BC%91&consignee_tel=0312345678&orderer_postal=1500002&orderer_name=YAMADA+Taro&orderer_address=%E6%9D%B1%E4%BA%AC%E9%83%BD%E6%B8%8B%E8%B0%B7%E5%8C%BA1-1-1&orderer_tel=0312345678&version=2&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, 13 Mar 2020 02:42:03 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml
35
+ body:
36
+ encoding: UTF-8
37
+ string: "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n <Epsilon_result>\r\n
38
+ \ <result result=\"0\" />\r\n <result err_code=\"601\" />\r\n <result
39
+ err_detail=\"%E3%83%A6%E3%83%BC%E3%82%B6%E3%83%BCID%E3%81%AE%E5%BD%A2%E5%BC%8F%E3%81%8C%E7%95%B0%E5%B8%B8%E3%81%A7%E3%81%99\"
40
+ />\r\n <result memo1=\"memo1\" />\r\n <result memo2=\"memo2\" />\r\n
41
+ \ </Epsilon_result>\r\n"
42
+ http_version: null
43
+ recorded_at: Fri, 13 Mar 2020 02:42:04 GMT
44
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,45 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: post
5
+ uri: https://beta.epsilon.jp/cgi-bin/order/receive_order3.cgi
6
+ body:
7
+ encoding: UTF-8
8
+ string: contract_code=[CONTRACT_CODE]&user_id=U1584067324&user_name=YAMADA+Taro&user_mail_add=yamada-taro%40example.com&item_code=ITEM001&item_name=Greate+Product&order_number=O4628159&st_code=00000-0000-00000-00010-00000-00000-00000&mission_code=1&item_price=10000&process_code=1&xml=1&delivery_code=99&consignee_postal=1500002&consignee_name=%E3%82%A4%E3%83%97%E3%82%B7%E3%83%AD%E3%83%B3%E3%82%BF%E3%83%AD%E3%82%A6&consignee_address=%E6%9D%B1%E4%BA%AC%E9%83%BD%E6%B8%8B%E8%B0%B7%E5%8C%BA%EF%BC%91%E2%88%92%EF%BC%91%E2%88%92%EF%BC%91&consignee_tel=0312345678&orderer_postal=1500002&orderer_name=YAMADA+Taro&orderer_address=%E6%9D%B1%E4%BA%AC%E9%83%BD%E6%B8%8B%E8%B0%B7%E5%8C%BA1-1-1&orderer_tel=0312345678&version=2&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, 13 Mar 2020 02:42:05 GMT
27
+ Server:
28
+ - Apache
29
+ Connection:
30
+ - close
31
+ Transfer-Encoding:
32
+ - chunked
33
+ Content-Type:
34
+ - text/xml
35
+ body:
36
+ encoding: UTF-8
37
+ string: |
38
+ <?xml version="1.0" encoding="UTF-8" ?>
39
+ <Epsilon_result>
40
+ <result result="1" />
41
+ <result redirect="https%3A%2F%2Fbeta.epsilon.jp%2Fcgi-bin%2Forder%2Fmethod_select3.cgi%3Ftrans_code%3DpShgPaOlX%252Fs55" />
42
+ </Epsilon_result>
43
+ http_version: null
44
+ recorded_at: Fri, 13 Mar 2020 02:42:05 GMT
45
+ recorded_with: VCR 5.1.0
@@ -0,0 +1,29 @@
1
+ require 'test_helper'
2
+
3
+ class RemoteEpsilonGmoAfterGatewayTest < MiniTest::Test
4
+ include SamplePaymentMethods
5
+
6
+ def gateway
7
+ @gateway ||= ActiveMerchant::Billing::EpsilonGmoAfterGateway.new
8
+ end
9
+
10
+ def test_gmo_after_purchase_successfull
11
+ VCR.use_cassette(:gmo_after_purchase_successful) do
12
+ response = gateway.purchase(10000, gmo_after_purchase_detail)
13
+
14
+ assert_equal true, response.success?
15
+ assert_equal true, !response.params['redirect'].empty?
16
+ end
17
+ end
18
+
19
+ def test_gmo_after_purchase_fail
20
+ invalid_purchase_detail = gmo_after_purchase_detail
21
+ invalid_purchase_detail[:user_id] = ''
22
+
23
+ VCR.use_cassette(:gmo_after_purchase_fail) do
24
+ response = gateway.purchase(10000, invalid_purchase_detail)
25
+
26
+ assert_equal false, response.success?
27
+ end
28
+ end
29
+ end
data/test/test_helper.rb CHANGED
@@ -9,7 +9,7 @@ require 'tapp'
9
9
  require 'vcr'
10
10
 
11
11
  require 'webmock/minitest'
12
- require 'mocha/mini_test'
12
+ require 'mocha/minitest'
13
13
 
14
14
  Dotenv.load
15
15
 
@@ -206,6 +206,28 @@ module SamplePaymentMethods
206
206
  }
207
207
  end
208
208
 
209
+ def gmo_after_purchase_detail
210
+ now = Time.now
211
+ {
212
+ user_id: "U#{Time.now.to_i}",
213
+ user_name: 'YAMADA Taro',
214
+ user_email: 'yamada-taro@example.com',
215
+ item_code: 'ITEM001',
216
+ item_name: 'Greate Product',
217
+ order_number: "O#{now.sec}#{now.usec}",
218
+ memo1: 'memo1',
219
+ memo2: 'memo2',
220
+ consignee_postal: '1500002',
221
+ consignee_name: 'イプシロンタロウ',
222
+ consignee_address: '東京都渋谷区1−1−1',
223
+ consignee_tel: '0312345678',
224
+ orderer_postal: '1500002',
225
+ orderer_name: 'YAMADA Taro',
226
+ orderer_address: '東京都渋谷区1-1-1',
227
+ orderer_tel: '0312345678',
228
+ }
229
+ end
230
+
209
231
  def fixture_xml(filename, parse: true)
210
232
  xml = File.read("test/fixtures/#{filename}")
211
233
  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.9.1
4
+ version: 0.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kenichi TAKAHASHI
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-26 00:00:00.000000000 Z
11
+ date: 2020-03-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemerchant
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.66.0
19
+ version: '1.88'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.66.0
26
+ version: '1.88'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: nokogiri
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -42,16 +42,16 @@ dependencies:
42
42
  name: bundler
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
45
+ - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '1.7'
47
+ version: '0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - "~>"
52
+ - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '1.7'
54
+ version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: dotenv
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,16 +84,16 @@ dependencies:
84
84
  name: rake
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '10.0'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '10.0'
96
+ version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: tapp
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -172,6 +172,7 @@ files:
172
172
  - lib/active_merchant/billing/gateways/epsilon/epsilon_mission_code.rb
173
173
  - lib/active_merchant/billing/gateways/epsilon/epsilon_process_code.rb
174
174
  - lib/active_merchant/billing/gateways/epsilon_convenience_store.rb
175
+ - lib/active_merchant/billing/gateways/epsilon_gmo_after.rb
175
176
  - lib/active_merchant/billing/gateways/epsilon_gmo_id.rb
176
177
  - lib/active_merchant/billing/gateways/epsilon_virtual_account.rb
177
178
  - lib/active_merchant/billing/gateways/response_parser.rb
@@ -188,6 +189,8 @@ files:
188
189
  - test/fixtures/vcr_cassettes/find_order_success.yml
189
190
  - test/fixtures/vcr_cassettes/find_user_failure.yml
190
191
  - test/fixtures/vcr_cassettes/find_user_success.yml
192
+ - test/fixtures/vcr_cassettes/gmo_after_purchase_fail.yml
193
+ - test/fixtures/vcr_cassettes/gmo_after_purchase_successful.yml
191
194
  - test/fixtures/vcr_cassettes/gmo_id_purchase_failure.yml
192
195
  - test/fixtures/vcr_cassettes/gmo_id_purchase_successful.yml
193
196
  - test/fixtures/vcr_cassettes/gmo_id_void_faiure.yml
@@ -215,6 +218,7 @@ files:
215
218
  - test/fixtures/vcr_cassettes/void_fail.yml
216
219
  - test/fixtures/vcr_cassettes/void_successful.yml
217
220
  - test/remote/gateways/remote_epsilon_convenience_store_test.rb
221
+ - test/remote/gateways/remote_epsilon_gmo_after_test.rb
218
222
  - test/remote/gateways/remote_epsilon_gmo_id_test.rb
219
223
  - test/remote/gateways/remote_epsilon_test.rb
220
224
  - test/remote/gateways/remote_epsilon_virtual_account_test.rb
@@ -240,8 +244,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
240
244
  - !ruby/object:Gem::Version
241
245
  version: '0'
242
246
  requirements: []
243
- rubyforge_project:
244
- rubygems_version: 2.5.1
247
+ rubygems_version: 3.0.3
245
248
  signing_key:
246
249
  specification_version: 4
247
250
  summary: Epsilon integration for ActiveMerchant.
@@ -257,6 +260,8 @@ test_files:
257
260
  - test/fixtures/vcr_cassettes/find_order_success.yml
258
261
  - test/fixtures/vcr_cassettes/find_user_failure.yml
259
262
  - test/fixtures/vcr_cassettes/find_user_success.yml
263
+ - test/fixtures/vcr_cassettes/gmo_after_purchase_fail.yml
264
+ - test/fixtures/vcr_cassettes/gmo_after_purchase_successful.yml
260
265
  - test/fixtures/vcr_cassettes/gmo_id_purchase_failure.yml
261
266
  - test/fixtures/vcr_cassettes/gmo_id_purchase_successful.yml
262
267
  - test/fixtures/vcr_cassettes/gmo_id_void_faiure.yml
@@ -284,6 +289,7 @@ test_files:
284
289
  - test/fixtures/vcr_cassettes/void_fail.yml
285
290
  - test/fixtures/vcr_cassettes/void_successful.yml
286
291
  - test/remote/gateways/remote_epsilon_convenience_store_test.rb
292
+ - test/remote/gateways/remote_epsilon_gmo_after_test.rb
287
293
  - test/remote/gateways/remote_epsilon_gmo_id_test.rb
288
294
  - test/remote/gateways/remote_epsilon_test.rb
289
295
  - test/remote/gateways/remote_epsilon_virtual_account_test.rb