-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #114 from pepabo/add-cancel-purchase-for-link-type
リンクタイプ決済の取引取消機能を追加する
- Loading branch information
Showing
8 changed files
with
283 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
test/fixtures/vcr_cassettes/epsilon_link_type_purchase_fail.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
44 changes: 44 additions & 0 deletions
44
test/fixtures/vcr_cassettes/epsilon_link_type_purchase_successfull.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
test/fixtures/vcr_cassettes/epsilon_link_type_void_fail.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
45 changes: 45 additions & 0 deletions
45
test/fixtures/vcr_cassettes/epsilon_link_type_void_successfull.yml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'test_helper' | ||
class RemoteEpsilonLinkPaymentTest < MiniTest::Test | ||
include SamplePaymentMethods | ||
|
||
def gateway | ||
@gateway ||= ActiveMerchant::Billing::EpsilonLinkPaymentGateway.new | ||
end | ||
|
||
def test_epsilon_link_type_purchase_successfull | ||
VCR.use_cassette(:epsilon_link_type_purchase_successfull) do | ||
response = gateway.purchase(10000, valid_epsilon_link_type_purchase_detail) | ||
|
||
assert_equal true, response.success? | ||
assert_equal true, !response.params['redirect'].empty? | ||
end | ||
end | ||
|
||
def test_epsilon_link_type_purchase_fail | ||
VCR.use_cassette(:epsilon_link_type_purchase_fail) do | ||
response = gateway.purchase(10000, invalid_epsilon_link_type_purchase_detail) | ||
|
||
assert_equal false, response.success? | ||
assert_equal true, response.params["error_detail"].valid_encoding? | ||
end | ||
end | ||
|
||
def test_epsilon_link_type_void_successfull | ||
VCR.use_cassette(:epsilon_link_type_void_successfull) do | ||
# あらかじめ課金済ステータスの受注がイプシロン側にないと取り消しができないため、課金済の受注をイプシロン側で作成しておいた。 | ||
# ここでは void の引数として作成済の受注のorder_numberを渡している。 | ||
# VCRのキャッシュを作成し直す場合は変更しないとエラーとなる。 | ||
response = gateway.void('595213151') | ||
|
||
assert_equal true, response.success? | ||
end | ||
end | ||
|
||
def test_epsilon_link_type_void_fail | ||
VCR.use_cassette(:epsilon_link_type_void_fail) do | ||
response = gateway.void('invalid_order_number') | ||
|
||
assert_equal false, response.success? | ||
assert_equal true, response.params["error_detail"].valid_encoding? | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -230,6 +230,52 @@ def gmo_after_purchase_detail | |
} | ||
end | ||
|
||
def valid_epsilon_link_type_purchase_detail | ||
now = Time.now | ||
{ | ||
user_id: "U#{Time.now.to_i}", | ||
user_name: '山田 太郎', | ||
user_email: '[email protected]', | ||
item_code: 'ITEM001', | ||
item_name: 'Greate Product', | ||
order_number: "O#{now.sec}#{now.usec}", | ||
st_code: '00000-0000-01000-00000-00000-00000-00000', | ||
memo1: 'memo1', | ||
memo2: 'memo2', | ||
consignee_postal: '1000001', | ||
consignee_name: 'イプシロンタロウ', | ||
consignee_address: '東京都千代田区千代田1番1号', | ||
consignee_tel: '0312345678', | ||
orderer_postal: '1000001', | ||
orderer_name: 'YAMADA Taro', | ||
orderer_address: '東京都千代田区千代田1番1号', | ||
orderer_tel: '0312345678', | ||
} | ||
end | ||
|
||
def invalid_epsilon_link_type_purchase_detail | ||
now = Time.now | ||
{ | ||
user_id: "U#{Time.now.to_i}", | ||
user_name: '山田 太郎', | ||
user_email: '[email protected]', | ||
item_code: 'ITEM001', | ||
item_name: 'Greate Product', | ||
order_number: "O#{now.sec}#{now.usec}", | ||
st_code: 'invalid_id', | ||
memo1: 'memo1', | ||
memo2: 'memo2', | ||
consignee_postal: '1000001', | ||
consignee_name: 'イプシロンタロウ', | ||
consignee_address: '東京都千代田区千代田1番1号', | ||
consignee_tel: '0312345678', | ||
orderer_postal: '1000001', | ||
orderer_name: 'YAMADA Taro', | ||
orderer_address: '東京都千代田区千代田1番1号', | ||
orderer_tel: '0312345678', | ||
} | ||
end | ||
|
||
def fixture_xml(filename, parse: true) | ||
xml = File.read("test/fixtures/#{filename}") | ||
parse ? Nokogiri.parse(xml.sub('x-sjis-cp932', 'CP932')) : xml | ||
|