Skip to content

Commit

Permalink
Merge pull request #108 from pepabo/use-version-1-epsilon-gmo-after
Browse files Browse the repository at this point in the history
GMO後払い version 1 を使うようにする
  • Loading branch information
yono authored Mar 19, 2020
2 parents 08c5987 + c905899 commit 10171b1
Show file tree
Hide file tree
Showing 10 changed files with 29 additions and 23 deletions.
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/gateways/epsilon_gmo_after.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class EpsilonGmoAfterGateway < EpsilonBaseGateway

RESPONSE_KEYS = DEFAULT_RESPONSE_KEYS + [
:redirect,
]

def purchase(amount, detail = {})
params = {
contract_code: self.contract_code,
Expand All @@ -24,14 +29,13 @@ def purchase(amount, detail = {})
orderer_name: detail[:orderer_name],
orderer_address: detail[:orderer_address],
orderer_tel: detail[:orderer_tel],
version: 2, # 推奨文字コードがUTF8の方を指定
}

params[:memo1] = detail[:memo1] if detail.has_key?(:memo1)
params[:memo2] = detail[:memo2] if detail.has_key?(:memo2)
params[:user_tel] = detail[:user_tel] if detail.has_key?(:user_tel)

commit('receive_order3.cgi', params, [:redirect])
commit('receive_order3.cgi', params, RESPONSE_KEYS)
end
end
end
Expand Down
8 changes: 1 addition & 7 deletions lib/active_merchant/billing/gateways/response_parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -124,13 +124,7 @@ def redirect
end

def uri_decode(string)
decoded_string = CGI.unescape(string)

unless decoded_string.encoding == Encoding::UTF_8
decoded_string = decoded_string.encode(Encoding::UTF_8, Encoding::CP932)
end

decoded_string
CGI.unescape(string).encode(Encoding::UTF_8, Encoding::CP932)
end

module ResponseXpath
Expand Down
8 changes: 4 additions & 4 deletions test/fixtures/vcr_cassettes/gmo_after_purchase_fail.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions test/fixtures/vcr_cassettes/gmo_after_purchase_successful.yml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_convenience_store_purchase_fail
VCR.use_cassette(:convenience_store_purchase_fail) do
response = gateway.purchase(10000, invalid_convenience_store, purchase_detail)
assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end
end
1 change: 1 addition & 0 deletions test/remote/gateways/remote_epsilon_gmo_after_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def test_gmo_after_purchase_fail
response = gateway.purchase(10000, invalid_purchase_detail)

assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end
end
1 change: 1 addition & 0 deletions test/remote/gateways/remote_epsilon_gmo_id_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ def test_gmo_id_purchase_failure
detail = invalid_gmo_id_purchase_detail
response = gateway.purchase(200, detail)
assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end

Expand Down
3 changes: 3 additions & 0 deletions test/remote/gateways/remote_epsilon_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ def test_purchase_fail
VCR.use_cassette(:purchase_fail) do
response = gateway.purchase(10000, invalid_credit_card, purchase_detail)
assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end

Expand Down Expand Up @@ -138,6 +139,7 @@ def test_cancel_recurring_fail
)

assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end

Expand Down Expand Up @@ -239,6 +241,7 @@ def test_registered_purchase_fail
invalid_purchase_detail[:user_id] = ''
response = gateway.registered_purchase(10000, invalid_purchase_detail)
assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end

Expand Down
3 changes: 2 additions & 1 deletion test/remote/gateways/remote_epsilon_virtual_account_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ def test_virtual_account_purchase_fail
VCR.use_cassette(:virtual_account_purchase_fail) do
response = gateway.purchase(10000, invalid_purchase_detail)
assert_equal false, response.success?
assert_equal true, response.params["error_detail"].valid_encoding?
end
end
end
end
11 changes: 6 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,20 +210,21 @@ def gmo_after_purchase_detail
now = Time.now
{
user_id: "U#{Time.now.to_i}",
user_name: 'YAMADA Taro',
user_name: '山田 太郎',
user_email: '[email protected]',
user_tel: '0312345678',
item_code: 'ITEM001',
item_name: 'Greate Product',
order_number: "O#{now.sec}#{now.usec}",
memo1: 'memo1',
memo2: 'memo2',
consignee_postal: '1500002',
consignee_postal: '1000001',
consignee_name: 'イプシロンタロウ',
consignee_address: '東京都渋谷区1−1−1',
consignee_address: '東京都千代田区千代田1番1号',
consignee_tel: '0312345678',
orderer_postal: '1500002',
orderer_postal: '1000001',
orderer_name: 'YAMADA Taro',
orderer_address: '東京都渋谷区1-1-1',
orderer_address: '東京都千代田区千代田1番1号',
orderer_tel: '0312345678',
}
end
Expand Down

0 comments on commit 10171b1

Please sign in to comment.