diff --git a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml deleted file mode 100644 index 7492678..0000000 --- a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_gets_data_about_a_mail_deposit.yml +++ /dev/null @@ -1,38 +0,0 @@ ---- -http_interactions: -- request: - method: post - uri: https:///api/MailDepositRegistration.idPass - body: - encoding: Windows-31J - string: Deposit_ID=dep0000&Mail_Address=anyutzy%40demo.com&Amount=000&Mail_Deposit_Account_Name=An+Yutzy&Expire=5&Shop_Mail_Address=anyutzy%40demo.com&Method=&Shop_ID=&Shop_Pass= - headers: - Accept-Encoding: - - gzip;q=.0,deflate;q=0.6,identity;q=0.3 - Accept: - - "*/*" - User-Agent: - - Ruby - response: - status: - code: 200 - message: OK - headers: - Server: - - nginx - Date: - - Mon, 0 May 207 05:58:27 GMT - Content-Type: - - text/plain;charset=Windows-3J - Transfer-Encoding: - - chunked - Connection: - - close - X-Frame-Options: - - SAMEORIGIN - body: - encoding: Windows-31J - string: Deposit_ID=dep00001&Method=1&Amount=1000&Expire=20170503 - http_version: - recorded_at: Mon, 01 May 2017 05:58:27 GMT -recorded_with: VCR 3.0.3 diff --git a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_with_valid_options_gets_data_about_a_mail_deposit.yml b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_with_valid_options_gets_data_about_a_mail_deposit.yml new file mode 100644 index 0000000..ffe5166 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_with_valid_options_gets_data_about_a_mail_deposit.yml @@ -0,0 +1,47 @@ +--- +http_interactions: +- request: + method: post + uri: https:///api/MailDepositRegistration.idPass + body: + encoding: UTF-8 + string: Deposit_ID=dep00001&Mail_Address=anyutzy%40demo.com&Amount=1000&Mail_Deposit_Account_Name=An+Yutzy&Expire=5&Shop_Mail_Address=anyutzy%40demo.com&Auth_Code=auth00001&Auth_Code2=auth00002&Auth_Code3=auth00003&Remit_Method_Bank=1&Mail_Template_Free1=mail_template_free_1&Mail_Template_Free2=mail_template_free_2&Mail_Template_Free3=mail_template_free_3&Mail_Template_Number=1&Bank_ID=bank_id00001&Select_Key=select00001&Client_Name=%83C%83%89%83C%83j%83%93%83%5E%83%8D%83E&Method=1&Shop_ID=&Shop_Pass= + headers: + 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: + - Thu, 12 Oct 2023 07:13:06 GMT + Content-Type: + - text/plain;charset=windows-31j + Content-Length: + - '56' + Connection: + - close + Cache-Control: + - no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + 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=1&Amount=1000&Expire=20231018 + recorded_at: Thu, 12 Oct 2023 07:13:06 GMT +recorded_with: VCR 6.1.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_with_valid_options_makes_request_with_correct_parameters.yml b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_with_valid_options_makes_request_with_correct_parameters.yml new file mode 100644 index 0000000..ffe5166 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_RemittanceAPI/_create_mail_deposit_with_valid_options_makes_request_with_correct_parameters.yml @@ -0,0 +1,47 @@ +--- +http_interactions: +- request: + method: post + uri: https:///api/MailDepositRegistration.idPass + body: + encoding: UTF-8 + string: Deposit_ID=dep00001&Mail_Address=anyutzy%40demo.com&Amount=1000&Mail_Deposit_Account_Name=An+Yutzy&Expire=5&Shop_Mail_Address=anyutzy%40demo.com&Auth_Code=auth00001&Auth_Code2=auth00002&Auth_Code3=auth00003&Remit_Method_Bank=1&Mail_Template_Free1=mail_template_free_1&Mail_Template_Free2=mail_template_free_2&Mail_Template_Free3=mail_template_free_3&Mail_Template_Number=1&Bank_ID=bank_id00001&Select_Key=select00001&Client_Name=%83C%83%89%83C%83j%83%93%83%5E%83%8D%83E&Method=1&Shop_ID=&Shop_Pass= + headers: + 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: + - Thu, 12 Oct 2023 07:13:06 GMT + Content-Type: + - text/plain;charset=windows-31j + Content-Length: + - '56' + Connection: + - close + Cache-Control: + - no-cache, no-store + Pragma: + - no-cache + Expires: + - '0' + 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=1&Amount=1000&Expire=20231018 + recorded_at: Thu, 12 Oct 2023 07:13:06 GMT +recorded_with: VCR 6.1.0 diff --git a/lib/gmo/const.rb b/lib/gmo/const.rb index 79ea842..82fdbd2 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", @@ -87,6 +92,10 @@ module Const :locale => "Locale", :md => "MD", :mail_address => "MailAddress", + :mail_template_free_1 => "Mail_Template_Free1", + :mail_template_free_2 => "Mail_Template_Free2", + :mail_template_free_3 => "Mail_Template_Free3", + :mail_template_number => "Mail_Template_Number", :member_id => "MemberID", :member_name => "MemberName", :member_no => "MemberNo", @@ -123,9 +132,11 @@ module Const :register_disp_6 => "RegisterDisp6", :register_disp_7 => "RegisterDisp7", :register_disp_8 => "RegisterDisp8", + :remit_method_bank => "Remit_Method_Bank", :reserve_no => "ReserveNo", :ret_url => "RetURL", :security_code => "SecurityCode", + :select_key => "Select_Key", :seq_mode => "SeqMode", :service_name => "ServiceName", :service_tel => "ServiceTel", diff --git a/lib/gmo/remittance_api.rb b/lib/gmo/remittance_api.rb index f8d1032..f58a499 100644 --- a/lib/gmo/remittance_api.rb +++ b/lib/gmo/remittance_api.rb @@ -250,6 +250,17 @@ def search_balance(options = {}) # Mail_Deposit_Account_Name # Expire # Shop_Mail_Address + # Auth_Code + # Auth_Code2 + # Auth_Code3 + # Remit_Method_Bank + # Mail_Template_Free1 + # Mail_Template_Free2 + # Mail_Template_Free3 + # Mail_Template_Number + # Bank_ID + # Select_Key + # Client_Name ### @return ### # Method # Amount @@ -268,7 +279,7 @@ def search_balance(options = {}) def create_mail_deposit(options = {}) name = "/api/MailDepositRegistration.idPass" options[:method] = 1 - required = %i(deposit_id deposit_email amount deposit_account_name expire deposit_shop_email) + required = %i(deposit_id deposit_email amount expire deposit_shop_email) assert_required_options(required, options) post_request name, options end diff --git a/spec/gmo/remittance_api_spec.rb b/spec/gmo/remittance_api_spec.rb index 005f1be..4e730f9 100644 --- a/spec/gmo/remittance_api_spec.rb +++ b/spec/gmo/remittance_api_spec.rb @@ -376,54 +376,76 @@ end describe "#create_mail_deposit" do - let(:do_api_call) { - @service.create_mail_deposit({ - :deposit_id => "dep00001", - :deposit_email => "anyutzy@demo.com", - :amount => 1000, - :deposit_account_name => "An Yutzy", - :expire => 5, - :deposit_shop_email => "anyutzy@demo.com" - }) - } + subject(:do_api_call) { @service.create_mail_deposit(options) } + + context 'with valid options', :vcr do + let(:options) do + { + :deposit_id => "dep00001", + :deposit_email => "anyutzy@demo.com", + :amount => 1000, + :deposit_account_name => "An Yutzy", + :expire => 5, + :deposit_shop_email => "anyutzy@demo.com", + :auth_code => "auth00001", + :auth_code_2 => "auth00002", + :auth_code_3 => "auth00003", + :remit_method_bank => "1", + :mail_template_free_1 => "mail_template_free_1", + :mail_template_free_2 => "mail_template_free_2", + :mail_template_free_3 => "mail_template_free_3", + :mail_template_number => 1, + :bank_id => "bank_id00001", + :select_key => "select00001", + :client_name => "イライニンタロウ", + } + end - it "gets data about a mail deposit", :vcr do - result = do_api_call - result["Deposit_ID"].nil?.should_not be_truthy - result["Method"].nil?.should_not be_truthy - result["Amount"].nil?.should_not be_truthy - result["Expire"].nil?.should_not be_truthy - end + before { allow(GMO).to receive(:make_request).and_call_original } - context 'with all required options' do - let(:response) { OpenStruct.new(status: 200, body: nil ) } - before { allow(GMO).to receive(:make_request) { response } } + it "gets data about a mail deposit" do + result = do_api_call + expect(result["Deposit_ID"]).to eq options[:deposit_id] + expect(result["Method"]).to eq "1" + expect(result["Amount"]).to eq options[:amount].to_s + expect(result["Expire"]).not_to be_nil + end - it "makes request with correct parameters", :vcr do + it "makes request with correct parameters" do + do_api_call path = "/api/MailDepositRegistration.idPass" args = { - "Deposit_ID" => "dep00001", - "Mail_Address" => "anyutzy@demo.com", - "Amount" => 1000, - "Mail_Deposit_Account_Name" => "An Yutzy", - "Expire" => 5, - "Shop_Mail_Address" => "anyutzy@demo.com", + "Deposit_ID" => options[:deposit_id], + "Mail_Address" => options[:deposit_email], + "Amount" => options[:amount], + "Mail_Deposit_Account_Name" => options[:deposit_account_name], + "Expire" => options[:expire], + "Shop_Mail_Address" => options[:deposit_shop_email], + "Auth_Code" => options[:auth_code], + "Auth_Code2" => options[:auth_code_2], + "Auth_Code3" => options[:auth_code_3], + "Remit_Method_Bank" => options[:remit_method_bank], + "Mail_Template_Free1" => options[:mail_template_free_1], + "Mail_Template_Free2" => options[:mail_template_free_2], + "Mail_Template_Free3" => options[:mail_template_free_3], + "Mail_Template_Number" => options[:mail_template_number], + "Bank_ID" => options[:bank_id], + "Select_Key" => options[:select_key], + "Client_Name" => options[:client_name], "Method" => 1, "Shop_ID" => @service.shop_id, "Shop_Pass" => @service.shop_pass } - verb = "post" - options = { :host => @service.host } - expect(GMO).to receive(:make_request).with(path, args, verb, options) + expect(GMO).to have_received(:make_request).with(path, args, "post", { :host => @service.host }) end - - after { do_api_call } end - it "got error if missing options", :vcr do - lambda { - result = @service.create_mail_deposit() - }.should raise_error("Required deposit_id, deposit_email, amount, deposit_account_name, expire, deposit_shop_email were not provided.") + context "with invalid options" do + let(:options) { {} } + + it "got error" do + expect { do_api_call }.to raise_error("Required deposit_id, deposit_email, amount, expire, deposit_shop_email were not provided.") + end end end