diff --git a/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_edy_gets_data_about_a_transaction.yml b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_edy_gets_data_about_a_transaction.yml new file mode 100644 index 0000000..25474b3 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_edy_gets_data_about_a_transaction.yml @@ -0,0 +1,35 @@ +--- +http_interactions: +- request: + method: post + uri: https:///payment/EntryTranEdy.idPass + body: + encoding: UTF-8 + string: OrderID=662969828&Amount=00&ShopID=&ShopPass= + 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, 2 Sep 2022 08:03:49 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: AccessID=63bff23f2cb9bfc9c528fd82f03d04e&AccessPass=509ced83bb0acd48c958f3baff94452 + recorded_at: Mon, 12 Sep 2022 08:03:49 GMT +recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_suica_gets_data_about_a_transaction.yml b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_suica_gets_data_about_a_transaction.yml new file mode 100644 index 0000000..d8f73d0 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_suica_gets_data_about_a_transaction.yml @@ -0,0 +1,35 @@ +--- +http_interactions: +- request: + method: post + uri: https:///payment/EntryTranSuica.idPass + body: + encoding: UTF-8 + string: OrderID=662969828&Amount=00&ShopID=&ShopPass= + 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, 2 Sep 2022 08:03:48 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: AccessID=63bff23f2cb9bfc9c528fd82f03d04e&AccessPass=473707429075004e2a4f74fbca48db + recorded_at: Mon, 12 Sep 2022 08:03:48 GMT +recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_virtualaccount_gets_data_about_a_transaction.yml b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_virtualaccount_gets_data_about_a_transaction.yml new file mode 100644 index 0000000..06c82f8 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_virtualaccount_gets_data_about_a_transaction.yml @@ -0,0 +1,35 @@ +--- +http_interactions: +- request: + method: post + uri: https:///payment/EntryTranVirtualaccount.idPass + body: + encoding: UTF-8 + string: OrderID=66262284&Amount=00&ShopID=&ShopPass= + 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: + - Thu, 08 Sep 2022 07:4:44 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: OrderID=66262284&AccessID=672560ef8bfede4aece2bdd43a66dd59&AccessPass=b436e6b362b89c622f266be43b290 + recorded_at: Thu, 08 Sep 2022 07:14:44 GMT +recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_edy_gets_data_about_a_transaction.yml b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_edy_gets_data_about_a_transaction.yml new file mode 100644 index 0000000..8797bcf --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_edy_gets_data_about_a_transaction.yml @@ -0,0 +1,67 @@ +--- +http_interactions: +- request: + method: post + uri: https:///payment/EntryTranEdy.idPass + body: + encoding: UTF-8 + string: OrderID=662970040&Amount=00&ShopID=&ShopPass= + 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, 2 Sep 2022 08:07:20 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: AccessID=e85e402df4ae23036f6de940c4eb2d7&AccessPass=6440b8df892f0a2dba3cb203805 + recorded_at: Mon, 12 Sep 2022 08:07:20 GMT +- request: + method: post + uri: https:///payment/ExecTranEdy.idPass + body: + encoding: UTF-8 + string: OrderID=662970040&AccessID=e85e402df4ae23036f6de940c4eb2d7&AccessPass=6440b8df892f0a2dba3cb203805&MailAddress=test%40example.com&ClientField=client_field&ClientFieldFlag=&ShopID=&ShopPass= + 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, 2 Sep 2022 08:07:23 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: OrderID=662970040&ReceiptNo=EDY662970042705&EdyOrderNo=662970040-2209204852&PaymentTerm=2022092270722&TranDate=202209270722&CheckString=8db002858a8d3b8eaf4b3e7a2cd20&ClientField=client_field&ClientField2=&ClientField3= + recorded_at: Mon, 12 Sep 2022 08:07:23 GMT +recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_suica_gets_data_about_a_transaction.yml b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_suica_gets_data_about_a_transaction.yml new file mode 100644 index 0000000..f60531c --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_suica_gets_data_about_a_transaction.yml @@ -0,0 +1,67 @@ +--- +http_interactions: +- request: + method: post + uri: https:///payment/EntryTranSuica.idPass + body: + encoding: UTF-8 + string: OrderID=662969936&Amount=00&ShopID=&ShopPass= + 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, 2 Sep 2022 08:05:37 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: AccessID=288a3a5032a25e723dad495d3b28a&AccessPass=d2dea7b2b94eab5ab3bddcfbd9cf58bc + recorded_at: Mon, 12 Sep 2022 08:05:37 GMT +- request: + method: post + uri: https:///payment/ExecTranSuica.idPass + body: + encoding: UTF-8 + string: OrderID=662969936&AccessID=288a3a5032a25e723dad495d3b28a&AccessPass=d2dea7b2b94eab5ab3bddcfbd9cf58bc&ItemName=%8Dw%93%FC%82%B7%82%E9%8F%A4%95i%96%BC&MailAddress=test%40example.com&ClientField=client_field&ClientFieldFlag=&ShopID=&ShopPass= + 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, 2 Sep 2022 08:05:39 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: OrderID=662969936&SuicaOrderNo=662969936-22092052836&ReceiptNo=SCA93925&PaymentTerm=2022092270637&TranDate=202209270539&CheckString=dfca947cffe2aa8927f3fcbb403d02&ClientField=client_field&ClientField2=&ClientField3= + recorded_at: Mon, 12 Sep 2022 08:05:39 GMT +recorded_with: VCR 6.0.0 diff --git a/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_virtualaccount_gets_data_about_a_transaction.yml b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_virtualaccount_gets_data_about_a_transaction.yml new file mode 100644 index 0000000..35b1a41 --- /dev/null +++ b/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_exec_tran_virtualaccount_gets_data_about_a_transaction.yml @@ -0,0 +1,68 @@ +--- +http_interactions: +- request: + method: post + uri: https:///payment/EntryTranVirtualaccount.idPass + body: + encoding: UTF-8 + string: OrderID=66262552&Amount=00&ShopID=&ShopPass= + 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: + - Thu, 08 Sep 2022 07:9:3 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: UTF-8 + string: OrderID=66262552&AccessID=dda76d2bb678f82ad3e4a7ded59d5b0&AccessPass=fdeccc446bb3320f48259062055ad926 + recorded_at: Thu, 08 Sep 2022 07:19:13 GMT +- request: + method: post + uri: https:///payment/ExecTranVirtualaccount.idPass + body: + encoding: UTF-8 + string: OrderID=66262552&AccessID=dda76d2bb678f82ad3e4a7ded59d5b0&AccessPass=fdeccc446bb3320f48259062055ad926&TradeDays=4&ShopID=&ShopPass= + 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: + - Thu, 08 Sep 2022 07:9:3 GMT + Content-Type: + - text/plain;charset=Windows-3J + Transfer-Encoding: + - chunked + Connection: + - close + body: + encoding: ASCII-8BIT + string: !binary |- + QWNjZXNzSUQ9ZGRhNzZkMmJiNjc4ZjgyPFRPS0VOPmFkM2U0YTdkZWQ1OWQ1YjAmQmFua0NvZGU9OTk5OCZCYW5rTmFtZT2DZYNYg2eL4o1zJkJyYW5jaENvZGU9OTk5JkJyYW5jaE5hbWU9g2WDWINnjniTWCZBY2NvdW50VHlwZT08VE9LRU4+JkFjY291bnROdW1iZXI9PFRPS0VOPjAyOTMyOSZBdmFpbGFibGVEYXRlPTIwMjIwOTIyJlRyYWRlQ29kZT00MjY8VE9LRU4+PFRPS0VOPjM4 + recorded_at: Thu, 08 Sep 2022 07:19:13 GMT +recorded_with: VCR 6.0.0 diff --git a/lib/gmo/const.rb b/lib/gmo/const.rb index 354a9af..79ea842 100644 --- a/lib/gmo/const.rb +++ b/lib/gmo/const.rb @@ -154,7 +154,11 @@ module Const :lang_cd => "LangCd", :user_info => "UserInfo", :package_name => "PackageName", - :search_type => "SearchType" + :search_type => "SearchType", + :trade_days => "TradeDays", + :trade_reason => "TradeReason", + :trade_client_name => "TradeClientName", + :trade_client_mail_address => "TradeClientMailAddress" }.freeze API_ERROR_MESSAGES_EN = { diff --git a/lib/gmo/shop_api.rb b/lib/gmo/shop_api.rb index ad75e0f..a7bafa0 100644 --- a/lib/gmo/shop_api.rb +++ b/lib/gmo/shop_api.rb @@ -158,6 +158,69 @@ def entry_tran_docomo(options = {}) post_request name, options end + ### @params ### + # OrderID + # Amount + # Tax + ### @return ### + # AccessID + # AccessPass + ### example ### + # gmo.entry_tran_virtualaccount({ + # order_id: "ord12345", + # tax: "0001001", + # amount: 100 + # }) + # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744"} + def entry_tran_virtualaccount(options = {}) + name = "EntryTranVirtualaccount.idPass" + required = [:order_id, :amount] + assert_required_options(required, options) + post_request name, options + end + + ### @params ### + # OrderID + # Amount + # Tax + ### @return ### + # AccessID + # AccessPass + ### example ### + # gmo.entry_tran_suica({ + # order_id: "ord12345", + # tax: "0001001", + # amount: 100 + # }) + # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744"} + def entry_tran_suica(options = {}) + name = "EntryTranSuica.idPass" + required = [:order_id, :amount] + assert_required_options(required, options) + post_request name, options + end + + ### @params ### + # OrderID + # Amount + # Tax + ### @return ### + # AccessID + # AccessPass + ### example ### + # gmo.entry_tran_edy({ + # order_id: "ord12345", + # tax: "0001001", + # amount: 100 + # }) + # => {"AccessID"=>"139f8ec33a07c55f406937c52ce4473d", "AccessPass"=>"2689b204d2c17192fa35f9269fa7e744"} + def entry_tran_edy(options = {}) + name = "EntryTranEdy.idPass" + required = [:order_id, :amount] + assert_required_options(required, options) + post_request name, options + end + ## 2.2.2.2.決済実行 # 指定されたサイトに会員を登録します。 # return @@ -286,6 +349,33 @@ def exec_tran_docomo(options = {}) post_request name, options end + # 【銀行振込(バーチャル口座)決済】 + # 18.1.2.2. 決済実行 + def exec_tran_virtualaccount(options = {}) + name = "ExecTranVirtualaccount.idPass" + required = [:access_id, :access_pass, :order_id, :trade_days] + assert_required_options(required, options) + post_request name, options + end + + # 【モバイルSuica決済】 + # 18.1.2.2. 決済実行 + def exec_tran_suica(options = {}) + name = "ExecTranSuica.idPass" + required = [:access_id, :access_pass, :order_id, :item_name, :mail_address] + assert_required_options(required, options) + post_request name, options + end + + # 【楽天Edy決済】 + # 18.1.2.2. 決済実行 + def exec_tran_edy(options = {}) + name = "ExecTranEdy.idPass" + required = [:access_id, :access_pass, :order_id, :mail_address] + assert_required_options(required, options) + post_request name, options + end + ### @params ### # AccessID # AccessPass diff --git a/spec/gmo/shop_api_spec.rb b/spec/gmo/shop_api_spec.rb index 1c61d8d..e1c7c3b 100644 --- a/spec/gmo/shop_api_spec.rb +++ b/spec/gmo/shop_api_spec.rb @@ -174,6 +174,60 @@ end end + describe "#entry_tran_virtualaccount" do + it "gets data about a transaction", :vcr do + order_id = @order_id + result = @service.entry_tran_virtualaccount({ + :order_id => order_id, + :amount => 100 + }) + result["AccessID"].nil?.should_not be true + result["AccessPass"].nil?.should_not be true + end + + it "got error if missing options", :vcr do + lambda { + result = @service.entry_tran_virtualaccount() + }.should raise_error('Required order_id, amount were not provided.') + end + end + + describe "#entry_tran_suica" do + it "gets data about a transaction", :vcr do + order_id = @order_id + result = @service.entry_tran_suica({ + :order_id => order_id, + :amount => 100 + }) + result["AccessID"].nil?.should_not be true + result["AccessPass"].nil?.should_not be true + end + + it "got error if missing options", :vcr do + lambda { + result = @service.entry_tran_suica() + }.should raise_error('Required order_id, amount were not provided.') + end + end + + describe "#entry_tran_edy" do + it "gets data about a transaction", :vcr do + order_id = @order_id + result = @service.entry_tran_edy({ + :order_id => order_id, + :amount => 100 + }) + result["AccessID"].nil?.should_not be true + result["AccessPass"].nil?.should_not be true + end + + it "got error if missing options", :vcr do + lambda { + result = @service.entry_tran_edy() + }.should raise_error('Required order_id, amount were not provided.') + end + end + describe "#exec_tran" do it "gets data about a transaction", :vcr do order_id = generate_id @@ -470,6 +524,110 @@ end end + describe "#exec_tran_virtualaccount" do + it "gets data about a transaction", :vcr do + order_id = generate_id + result = @service.entry_tran_virtualaccount({ + :order_id => order_id, + :amount => 100 + }) + access_id = result["AccessID"] + access_pass = result["AccessPass"] + result = @service.exec_tran_virtualaccount({ + :order_id => order_id, + :access_id => access_id, + :access_pass => access_pass, + :trade_days => 14 + }) + result["AccessID"].nil?.should_not be_truthy + result["BankCode"].nil?.should_not be_truthy + result["BankName"].nil?.should_not be_truthy + result["BranchCode"].nil?.should_not be_truthy + result["BranchName"].nil?.should_not be_truthy + result["AccountType"].nil?.should_not be_truthy + result["AccountNumber"].nil?.should_not be_truthy + result["AvailableDate"].nil?.should_not be_truthy + result["TradeCode"].nil?.should_not be_truthy + end + + it "got error if missing options", :vcr do + lambda { + result = @service.exec_tran_virtualaccount() + }.should raise_error("Required access_id, access_pass, order_id, trade_days were not provided.") + end + end + + describe "#exec_tran_suica" do + it "gets data about a transaction", :vcr do + order_id = generate_id + client_field_1 = "client_field1" + result = @service.entry_tran_suica({ + :order_id => order_id, + :amount => 100 + }) + access_id = result["AccessID"] + access_pass = result["AccessPass"] + result = @service.exec_tran_suica({ + :order_id => order_id, + :access_id => access_id, + :access_pass => access_pass, + :item_name => '購入する商品名', + :mail_address => 'test@example.com', + :client_field_1 => client_field_1, + :client_field_flg => 1 + }) + result["OrderID"].nil?.should_not be_truthy + result["SuicaOrderNo"].nil?.should_not be_truthy + result["ReceiptNo"].nil?.should_not be_truthy + result["PaymentTerm"].nil?.should_not be_truthy + result["TranDate"].nil?.should_not be_truthy + result["CheckString"].nil?.should_not be_truthy + (result["ClientField1"] == client_field_1).should be_truthy + result["ClientField3"].nil?.should_not be_truthy + end + + it "got error if missing options", :vcr do + lambda { + result = @service.exec_tran_suica() + }.should raise_error("Required access_id, access_pass, order_id, item_name, mail_address were not provided.") + end + end + + describe "#exec_tran_edy" do + it "gets data about a transaction", :vcr do + order_id = generate_id + client_field_1 = "client_field1" + result = @service.entry_tran_edy({ + :order_id => order_id, + :amount => 100 + }) + access_id = result["AccessID"] + access_pass = result["AccessPass"] + result = @service.exec_tran_edy({ + :order_id => order_id, + :access_id => access_id, + :access_pass => access_pass, + :mail_address => 'test@example.com', + :client_field_1 => client_field_1, + :client_field_flg => 1 + }) + result["OrderID"].nil?.should_not be_truthy + result["ReceiptNo"].nil?.should_not be_truthy + result["EdyOrderNo"].nil?.should_not be_truthy + result["PaymentTerm"].nil?.should_not be_truthy + result["TranDate"].nil?.should_not be_truthy + result["CheckString"].nil?.should_not be_truthy + (result["ClientField1"] == client_field_1).should be_truthy + result["ClientField3"].nil?.should_not be_truthy + end + + it "got error if missing options", :vcr do + lambda { + result = @service.exec_tran_edy() + }.should raise_error("Required access_id, access_pass, order_id, mail_address were not provided.") + end + end + describe "#exec_tran_brandtoken" do it "gets data about a transaction", :vcr do order_id = generate_id