Skip to content

Commit

Permalink
送金サービス リンクタイプURL取得の追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ken1flan committed Oct 17, 2023
1 parent cced303 commit 69a809e
Show file tree
Hide file tree
Showing 6 changed files with 329 additions and 0 deletions.

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

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

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

4 changes: 4 additions & 0 deletions lib/gmo/const.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,18 @@ module Const
:register_disp_6 => "RegisterDisp6",
:register_disp_7 => "RegisterDisp7",
:register_disp_8 => "RegisterDisp8",
:remit_method_amazongift => "Remit_Method_Amazongift",
:remit_method_aupay => "Remit_Method_Aupay",
:remit_method_bank => "Remit_Method_Bank",
:remit_method_sevenatm => "Remit_Method_Sevenatm",
:reserve_no => "ReserveNo",
:ret_url => "RetURL",
:security_code => "SecurityCode",
:select_key => "Select_Key",
:seq_mode => "SeqMode",
:service_name => "ServiceName",
:service_tel => "ServiceTel",
:sevenatm_payment_term_day => "Sevenatm_Payment_Term_Day",
:shop_id => "ShopID",
:shop_mail_address => "ShopMailAddress",
:shop_pass => "ShopPass",
Expand Down
51 changes: 51 additions & 0 deletions lib/gmo/remittance_api.rb
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,57 @@ def search_mail_deposit(options = {})
post_request name, options
end

#########
# Deposit_ID
# Call_Back_Url
# Amount
# Auth_Code
# Auth_Code2
# Auth_Code3
# Remit_Method_Bank
# Remit_Method_Sevenatm
# Sevenatm_Payment_Term_Day
# Remit_Method_Amazongift
# Remit_Method_Aup ay
# Bank_ID
# Client_Name
### @return ###
# Deposit_ID
# Redirect_Url
# Method
### example ###
# gmo.create_link_redirect_url({
# deposit_id: 'dep00001',
# call_back_url: 'https://XXXX/XXXX/XXXX/XXXX',
# amount: '1000',
# auth_code: 'auth00001',
# })
# {"Deposit_ID"=>"dep00001", "Redirect_Url"=>"https://XXXX/XXXX/XXXX/XXXX", "Method"=>"1"}
def create_link_redirect_url(options = {})
name = "/api/shop/LinkRedirectUrl.json"
required = %i(deposit_id call_back_url amount auth_code)
assert_required_options(required, options)
post_request name, options
end

#########
# Deposit_ID
### @return ###
# Deposit_ID
# Method
### example ###
# gmo.cancel_link_redirect_url({
# deposit_id: 'dep00001',
# })
# {"Deposit_ID"=>"dep00001", "Method"=>"2"}
def cancel_link_redirect_url(options = {})
name = "/api/shop/LinkRedirectUrl.json"
required = %i(deposit_id)
options[:method] = 2
assert_required_options(required, options)
post_request name, options
end

private

def api_call(name, args = {}, verb = "post", options = {})
Expand Down
65 changes: 65 additions & 0 deletions spec/gmo/remittance_api_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -525,4 +525,69 @@
end
end

describe "#create_link_redirect_url" do
subject(:do_api_call) { @service.create_link_redirect_url(options) }

context 'with valid options', :vcr do
let(:deposit_id) { "dep00001" }
let(:options) do
{
deposit_id: deposit_id,
call_back_url: "https://example.com/callback",
amount: "1000",
auth_code: "auth00005",
auth_code_2: "auth00002",
auth_code_3: "auth00003",
remit_method_bank: "1",
remit_method_sevenatm: "1",
sevenatm_payment_term_day: "15",
remit_method_amazongift: "1",
remit_method_aupay: "1",
bank_id: "bank_id00001",
client_name: "リンクユーアールエル",
}
end

it "gets data about link redirect url" do
result = do_api_call
expect(result["Deposit_ID"]).to eq(deposit_id)
expect(result["Redirect_Url"]).not_to be_nil
expect(result["Method"]).to eq("1")
end
end

context "with invalid options", :vcr do
let(:options) { {} }

it "got error" do
expect { do_api_call }.to raise_error("Required deposit_id, call_back_url, amount, auth_code were not provided.")
end
end
end

describe "#cancel_link_redirect_url" do
subject (:do_api_call) { @service.cancel_link_redirect_url(options) }

before { @service.create_link_redirect_url(deposit_id: deposit_id, call_back_url: 'https://example.com/callback', amount: '100', auth_code: 'AUTH001') }

context 'with valid options', :vcr do
let(:options) { { deposit_id: deposit_id } }
let(:deposit_id) { "dep00001" }

it "gets data about a link edirect url" do
result = do_api_call
expect(result["Deposit_ID"]).not_to be_nil
expect(result["Method"]).to eq "2"
end
end

context "with invalid options", :vcr do
let(:options) { {} }
let(:deposit_id) { "dep00001" }

it "got error" do
expect { do_api_call }.to raise_error("Required deposit_id were not provided.")
end
end
end
end

0 comments on commit 69a809e

Please sign in to comment.