diff --git a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_link_redirect_url_with_invalid_options_got_error.yml b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_link_redirect_url_with_invalid_options_got_error.yml new file mode 100644 index 0000000..7dfaf76 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_link_redirect_url_with_invalid_options_got_error.yml @@ -0,0 +1,53 @@ +--- +http_interactions: +- request: + method: post + uri: https:///api/shop/LinkRedirectUrl.json + body: + encoding: UTF-8 + string: '{"Deposit_ID":"dep00001","Call_Back_Url":"https://example.com/callback","Amount":"100","Auth_Code":"AUTH001","Shop_ID":"","Shop_Pass":""}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: '' + headers: + Server: + - nginx + Date: + - Mon, 09 Oct 2023 08:25:18 GMT + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - "177" + Connection: + - close + X-Content-Type-Options: + - nosniff + Cache-Control: + - no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Disposition: + - attachment;filename="LinkRedirectUrl.json" + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "1; mode=block" + Strict-Transport-Security: + - max-age=63072000 + body: + encoding: UTF-8 + string: '{"Redirect_Url":"https:///mail/mail-deposit?token=7c0bbc6531f42138eca9b8caf63b7735b5ad8d2faf8fe2ede3c364fd71f88e85","Deposit_ID":"dep00001","Method":"1"}' + recorded_at: Mon, 09 Oct 2023 08:25:18 GMT +recorded_with: VCR 6.1.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_link_redirect_url_with_valid_options_gets_data_about_a_link_edirect_url.yml b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_link_redirect_url_with_valid_options_gets_data_about_a_link_edirect_url.yml new file mode 100644 index 0000000..cbab266 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_cancel_link_redirect_url_with_valid_options_gets_data_about_a_link_edirect_url.yml @@ -0,0 +1,103 @@ +--- +http_interactions: +- request: + method: post + uri: https:///api/shop/LinkRedirectUrl.json + body: + encoding: UTF-8 + string: '{"Deposit_ID":"dep00001","Call_Back_Url":"https://example.com/callback","Amount":"100","Auth_Code":"AUTH001","Shop_ID":"","Shop_Pass":""}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: '' + headers: + Server: + - nginx + Date: + - Mon, 09 Oct 2023 08:25:18 GMT + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - "177" + Connection: + - close + X-Content-Type-Options: + - nosniff + Cache-Control: + - no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Disposition: + - attachment;filename="LinkRedirectUrl.json" + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "1; mode=block" + Strict-Transport-Security: + - max-age=63072000 + body: + encoding: UTF-8 + string: '{"Redirect_Url":"https:///mail/mail-deposit?token=cbc777b18666b7aa21f42e98fa972c493530c3d5d6bfd9125b262075512bf285","Deposit_ID":"dep00001","Method":"1"}' + recorded_at: Mon, 09 Oct 2023 08:25:18 GMT +- request: + method: post + uri: https:///api/shop/LinkRedirectUrl.json + body: + encoding: UTF-8 + string: '{"Deposit_ID":"dep00001","Method":2,"Shop_ID":"","Shop_Pass":""}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: '' + headers: + Server: + - nginx + Date: + - Mon, 09 Oct 2023 08:26:00 GMT + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - '38' + Connection: + - close + X-Content-Type-Options: + - nosniff + Cache-Control: + - no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Disposition: + - attachment;filename="LinkRedirectUrl.json" + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "1; mode=block" + Strict-Transport-Security: + - max-age=63072000 + body: + encoding: UTF-8 + string: '{"Deposit_ID":"dep00001","Method":"2"}' + recorded_at: Mon, 09 Oct 2023 08:26:00 GMT +recorded_with: VCR 6.1.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_link_redirect_url_with_valid_options_gets_data_about_link_redirect_url.yml b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_link_redirect_url_with_valid_options_gets_data_about_link_redirect_url.yml new file mode 100644 index 0000000..920063a --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_link_redirect_url_with_valid_options_gets_data_about_link_redirect_url.yml @@ -0,0 +1,53 @@ +--- +http_interactions: +- request: + method: post + uri: https:///api/shop/LinkRedirectUrl.json + body: + encoding: UTF-8 + string: '{"Deposit_ID":"dep00001","Amount":"1000","Auth_Code":"auth00001","Call_Back_Url":"https://example.com/callback","Shop_ID":"","Shop_Pass":""}' + headers: + Content-Type: + - application/json + Accept-Encoding: + - gzip;q=1.0,deflate;q=0.6,identity;q=0.3 + Accept: + - "*/*" + User-Agent: + - Ruby + response: + status: + code: 200 + message: '' + headers: + Server: + - nginx + Date: + - Fri, 06 Oct 2023 10:30:26 GMT + Content-Type: + - application/json;charset=UTF-8 + Content-Length: + - "177" + Connection: + - close + X-Content-Type-Options: + - nosniff + Cache-Control: + - no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + Content-Disposition: + - attachment;filename="LinkRedirectUrl.json" + X-Frame-Options: + - SAMEORIGIN + X-Xss-Protection: + - "1; mode=block" + Strict-Transport-Security: + - max-age=63072000 + body: + encoding: UTF-8 + string: '{"Redirect_Url":"https:///mail/mail-deposit?token=cfd81440aef67210b6f3eccf3cb8e7d7020013d67108ca4d13d1ca897fb0d0f6","Deposit_ID":"dep00001","Method":"1"}' + recorded_at: Fri, 06 Oct 2023 10:30:26 GMT +recorded_with: VCR 6.1.0 diff --git a/lib/gmo/const.rb b/lib/gmo/const.rb index 79ea842..edec684 100644 --- a/lib/gmo/const.rb +++ b/lib/gmo/const.rb @@ -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", @@ -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", @@ -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", diff --git a/lib/gmo/remittance_api.rb b/lib/gmo/remittance_api.rb index f8d1032..e270bdd 100644 --- a/lib/gmo/remittance_api.rb +++ b/lib/gmo/remittance_api.rb @@ -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 = {}) diff --git a/spec/gmo/remittance_api_spec.rb b/spec/gmo/remittance_api_spec.rb index 005f1be..474aafb 100644 --- a/spec/gmo/remittance_api_spec.rb +++ b/spec/gmo/remittance_api_spec.rb @@ -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