Skip to content

Commit

Permalink
送金サービス リンクタイプURL取得の追加
Browse files Browse the repository at this point in the history
  • Loading branch information
ken1flan committed Oct 12, 2023
1 parent 13fd4df commit d36e846
Show file tree
Hide file tree
Showing 6 changed files with 335 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.

10 changes: 10 additions & 0 deletions lib/gmo/const.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,15 @@ module Const
:address_4 => "Address4",
:address_5 => "Address5",
:address_6 => "Address6",
:auth_code => "Auth_Code",
:auth_code_2 => "Auth_Code2",
:auth_code_3 => "Auth_Code3",
:amount => "Amount",
:bank_code => "Bank_Code",
:bank_id => "Bank_ID",
:branch_code => "Branch_Code",
:branch_code_jp => "Branch_Code_Jpbank",
:call_back_url => "Call_Back_Url",
:cancel_amount => "CancelAmount",
:cancel_tax => "CancelTax",
:card_name => "CardName",
Expand All @@ -52,6 +56,7 @@ module Const
:client_field_2 => "ClientField2",
:client_field_3 => "ClientField3",
:client_field_flg => "ClientFieldFlag",
:client_name => "Client_Name",
:commodity => "Commodity",
:confirm_base_date => "ConfirmBaseDate",
:continuance_month => "ContinuanceMonth",
Expand Down Expand Up @@ -123,12 +128,17 @@ 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",
: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 @@ -314,6 +314,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 @@ -503,4 +503,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 d36e846

Please sign in to comment.