gmo 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_cvs_cancel_gets_data_about_a_transaction.yml +63 -0
- data/lib/gmo/const.rb +1130 -2
- data/lib/gmo/errors.rb +8 -8
- data/lib/gmo/remittance_api.rb +5 -3
- data/lib/gmo/shop_and_site_api.rb +5 -3
- data/lib/gmo/shop_api.rb +16 -3
- data/lib/gmo/site_api.rb +6 -3
- data/lib/gmo/version.rb +2 -2
- data/spec/gmo/remittance_api_spec.rb +3 -1
- data/spec/gmo/shop_and_site_api_spec.rb +9 -3
- data/spec/gmo/shop_api_spec.rb +30 -2
- data/spec/gmo/site_api_spec.rb +7 -3
- metadata +4 -3
data/lib/gmo/errors.rb
CHANGED
@@ -14,14 +14,14 @@ module GMO
|
|
14
14
|
|
15
15
|
private
|
16
16
|
|
17
|
-
def error_message(info)
|
18
|
-
::GMO::Const::API_ERROR_MESSAGES[
|
17
|
+
def error_message(info, locale)
|
18
|
+
::GMO::Const::API_ERROR_MESSAGES[locale][info] || info
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
22
|
module Payment
|
23
23
|
class Error < ::GMO::GMOError
|
24
|
-
attr_accessor :error_info, :response_body
|
24
|
+
attr_accessor :error_info, :response_body, :locale, :error_messages
|
25
25
|
|
26
26
|
def initialize(response_body = "", error_info = nil)
|
27
27
|
if response_body && response_body.is_a?(String)
|
@@ -46,8 +46,9 @@ module GMO
|
|
46
46
|
end
|
47
47
|
|
48
48
|
class APIError < Error
|
49
|
-
def initialize(error_info = {})
|
49
|
+
def initialize(error_info = {}, locale = ::GMO::Const::DEFAULT_LOCALE)
|
50
50
|
self.error_info = error_info
|
51
|
+
self.locale = locale
|
51
52
|
self.response_body = "ErrCode=#{error_info["ErrCode"]}&ErrInfo=#{error_info["ErrInfo"]}"
|
52
53
|
set_error_messages
|
53
54
|
message = self.response_body
|
@@ -57,10 +58,9 @@ module GMO
|
|
57
58
|
private
|
58
59
|
|
59
60
|
def set_error_messages
|
60
|
-
error_messages = self.error_info['ErrInfo'].to_s.split(ERROR_INFO_SEPARATOR)
|
61
|
-
.map { |e| error_message(e) || e }
|
62
|
-
|
63
|
-
self.response_body += "&ErrMessage=#{error_messages}"
|
61
|
+
self.error_messages = self.error_info['ErrInfo'].to_s.split(ERROR_INFO_SEPARATOR)
|
62
|
+
.map { |e| error_message(e, locale) || e }
|
63
|
+
self.response_body += "&ErrMessage=#{self.error_messages.join(ERROR_INFO_SEPARATOR)}"
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
data/lib/gmo/remittance_api.rb
CHANGED
@@ -6,7 +6,8 @@
|
|
6
6
|
# gmo = GMO::Payment::RemittanceAPI.new({
|
7
7
|
# shop_id: "foo",
|
8
8
|
# shop_pass: "bar",
|
9
|
-
# host:
|
9
|
+
# host: "test-remittance.gmopg.jp",
|
10
|
+
# locale: "ja"
|
10
11
|
# })
|
11
12
|
module GMO
|
12
13
|
module Payment
|
@@ -17,11 +18,12 @@ module GMO
|
|
17
18
|
@shop_id = options[:shop_id]
|
18
19
|
@shop_pass = options[:shop_pass]
|
19
20
|
@host = options[:host]
|
21
|
+
@locale = options.fetch(:locale, GMO::Const::DEFAULT_LOCALE)
|
20
22
|
unless @shop_id && @shop_pass && @host
|
21
23
|
raise ArgumentError, "Initialize must receive a hash with :shop_id, :shop_pass and either :host! (received #{options.inspect})"
|
22
24
|
end
|
23
25
|
end
|
24
|
-
attr_reader :shop_id, :shop_pass, :host
|
26
|
+
attr_reader :shop_id, :shop_pass, :host, :locale
|
25
27
|
|
26
28
|
#########
|
27
29
|
# Method
|
@@ -318,7 +320,7 @@ module GMO
|
|
318
320
|
args.merge!({ "Shop_ID" => @shop_id, "Shop_Pass" => @shop_pass })
|
319
321
|
api(name, args, verb, options) do |response|
|
320
322
|
if response.is_a?(Hash) && !response["ErrInfo"].nil?
|
321
|
-
raise APIError.new(response)
|
323
|
+
raise APIError.new(response, locale)
|
322
324
|
end
|
323
325
|
end
|
324
326
|
end
|
@@ -8,7 +8,8 @@
|
|
8
8
|
# site_pass: "bar",
|
9
9
|
# shop_id: "baz",
|
10
10
|
# shop_pass: "bax",
|
11
|
-
# host: "p01.mul-pay.jp"
|
11
|
+
# host: "p01.mul-pay.jp",
|
12
|
+
# locale: "ja"
|
12
13
|
# })
|
13
14
|
module GMO
|
14
15
|
module Payment
|
@@ -20,11 +21,12 @@ module GMO
|
|
20
21
|
@site_id = options[:site_id]
|
21
22
|
@site_pass = options[:site_pass]
|
22
23
|
@host = options[:host]
|
24
|
+
@locale = options.fetch(:locale, GMO::Const::DEFAULT_LOCALE)
|
23
25
|
unless @site_id && @site_pass && @shop_id && @shop_pass && @host
|
24
26
|
raise ArgumentError, "Initialize must receive a hash with :site_id, :site_pass, :shop_id, :shop_pass and either :host! (received #{options.inspect})"
|
25
27
|
end
|
26
28
|
end
|
27
|
-
attr_reader :shop_id, :shop_pass, :site_id, :site_pass, :host
|
29
|
+
attr_reader :shop_id, :shop_pass, :site_id, :site_pass, :host, :locale
|
28
30
|
|
29
31
|
# 2.17.2.1.決済後カード登録
|
30
32
|
# 指定されたオーダーID の取引に使用したカードを登録します。
|
@@ -112,7 +114,7 @@ module GMO
|
|
112
114
|
})
|
113
115
|
api(name, args, verb, options) do |response|
|
114
116
|
if response.is_a?(Hash) && !response["ErrInfo"].nil?
|
115
|
-
raise APIError.new(response)
|
117
|
+
raise APIError.new(response, locale)
|
116
118
|
end
|
117
119
|
end
|
118
120
|
end
|
data/lib/gmo/shop_api.rb
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
# gmo = GMO::Payment::ShopAPI.new({
|
7
7
|
# shop_id: "foo",
|
8
8
|
# shop_pass: "bar",
|
9
|
-
# host:
|
9
|
+
# host: "mul-pay.com",
|
10
|
+
# locale: "ja"
|
11
|
+
|
10
12
|
# })
|
11
13
|
# result = gmo.post_request("EntryTran.idPass", options)
|
12
14
|
module GMO
|
@@ -18,11 +20,12 @@ module GMO
|
|
18
20
|
@shop_id = options[:shop_id]
|
19
21
|
@shop_pass = options[:shop_pass]
|
20
22
|
@host = options[:host]
|
23
|
+
@locale = options.fetch(:locale, GMO::Const::DEFAULT_LOCALE)
|
21
24
|
unless @shop_id && @shop_pass && @host
|
22
25
|
raise ArgumentError, "Initialize must receive a hash with :shop_id, :shop_pass and either :host! (received #{options.inspect})"
|
23
26
|
end
|
24
27
|
end
|
25
|
-
attr_reader :shop_id, :shop_pass, :host
|
28
|
+
attr_reader :shop_id, :shop_pass, :host, :locale
|
26
29
|
|
27
30
|
## 2.1.2.1.取引登録
|
28
31
|
# これ以降の決済取引で必要となる取引 ID と取引パスワードの発行を行い、取引を開始します。
|
@@ -422,6 +425,16 @@ module GMO
|
|
422
425
|
post_request name, options
|
423
426
|
end
|
424
427
|
|
428
|
+
# 【コンビニ払い】
|
429
|
+
## 2.2.2.1. 支払停止
|
430
|
+
# コンビニ決済センターとの通信を行い取引の支払停止処理を行います。
|
431
|
+
def cvs_cancel(options = {})
|
432
|
+
name = "CvsCancel.idPass"
|
433
|
+
required = [:access_id, :access_pass, :order_id]
|
434
|
+
assert_required_options(required, options)
|
435
|
+
post_request name, options
|
436
|
+
end
|
437
|
+
|
425
438
|
## 2.16.2.1.取引状態参照
|
426
439
|
# 指定したオーダーID の取引情報を取得します。
|
427
440
|
def search_trade(options = {})
|
@@ -478,7 +491,7 @@ module GMO
|
|
478
491
|
args.merge!({ "ShopID" => @shop_id, "ShopPass" => @shop_pass })
|
479
492
|
api(name, args, verb, options) do |response|
|
480
493
|
if response.is_a?(Hash) && !response["ErrInfo"].nil?
|
481
|
-
raise APIError.new(response)
|
494
|
+
raise APIError.new(response, locale)
|
482
495
|
end
|
483
496
|
end
|
484
497
|
end
|
data/lib/gmo/site_api.rb
CHANGED
@@ -6,7 +6,9 @@
|
|
6
6
|
# gmo = GMO::Payment::SiteAPI.new({
|
7
7
|
# site_id: "foo",
|
8
8
|
# site_pass: "bar",
|
9
|
-
# host:
|
9
|
+
# host: "mul-pay.com",
|
10
|
+
# locale: "ja"
|
11
|
+
|
10
12
|
# })
|
11
13
|
# result = gmo.post_request("EntryTran.idPass", options)
|
12
14
|
module GMO
|
@@ -18,11 +20,12 @@ module GMO
|
|
18
20
|
@site_id = options[:site_id]
|
19
21
|
@site_pass = options[:site_pass]
|
20
22
|
@host = options[:host]
|
23
|
+
@locale = options.fetch(:locale, GMO::Const::DEFAULT_LOCALE)
|
21
24
|
unless @site_id && @site_pass && @host
|
22
25
|
raise ArgumentError, "Initialize must receive a hash with :site_id, :site_pass and either :host! (received #{options.inspect})"
|
23
26
|
end
|
24
27
|
end
|
25
|
-
attr_reader :site_id, :site_pass, :host
|
28
|
+
attr_reader :site_id, :site_pass, :host, :locale
|
26
29
|
|
27
30
|
## 2.3.2.1.会員登録
|
28
31
|
# 指定されたサイトに会員を登録します。
|
@@ -173,7 +176,7 @@ module GMO
|
|
173
176
|
args.merge!({ "SiteID" => @site_id, "SitePass" => @site_pass })
|
174
177
|
api(name, args, verb, options) do |response|
|
175
178
|
if response.is_a?(Hash) && !response["ErrInfo"].nil?
|
176
|
-
raise APIError.new(response)
|
179
|
+
raise APIError.new(response, locale)
|
177
180
|
end
|
178
181
|
end
|
179
182
|
end
|
data/lib/gmo/version.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
module GMO
|
2
|
-
VERSION = "0.
|
3
|
-
end
|
2
|
+
VERSION = "0.5.0"
|
3
|
+
end
|
@@ -8,7 +8,9 @@ describe "GMO::Payment::RemittanceAPI" do
|
|
8
8
|
@service ||= GMO::Payment::RemittanceAPI.new({
|
9
9
|
:shop_id => SPEC_CONF["remittance"]["shop_id"],
|
10
10
|
:shop_pass => SPEC_CONF["remittance"]["shop_pass"],
|
11
|
-
:host => SPEC_CONF["remittance"]["host"]
|
11
|
+
:host => SPEC_CONF["remittance"]["host"],
|
12
|
+
:locale => :ja
|
13
|
+
|
12
14
|
})
|
13
15
|
end
|
14
16
|
|
@@ -8,17 +8,23 @@ describe "GMO::Payment::ShopAndSiteAPI" do
|
|
8
8
|
:shop_pass => SPEC_CONF["shop_pass"],
|
9
9
|
:site_id => SPEC_CONF["site_id"],
|
10
10
|
:site_pass => SPEC_CONF["site_pass"],
|
11
|
-
:host => SPEC_CONF["host"]
|
11
|
+
:host => SPEC_CONF["host"],
|
12
|
+
:locale => :ja
|
13
|
+
|
12
14
|
})
|
13
15
|
@shop_api ||= GMO::Payment::ShopAPI.new({
|
14
16
|
:shop_id => SPEC_CONF["shop_id"],
|
15
17
|
:shop_pass => SPEC_CONF["shop_pass"],
|
16
|
-
:host => SPEC_CONF["host"]
|
18
|
+
:host => SPEC_CONF["host"],
|
19
|
+
:locale => :ja
|
20
|
+
|
17
21
|
})
|
18
22
|
@site_api ||= GMO::Payment::SiteAPI.new({
|
19
23
|
:site_id => SPEC_CONF["site_id"],
|
20
24
|
:site_pass => SPEC_CONF["site_pass"],
|
21
|
-
:host => SPEC_CONF["host"]
|
25
|
+
:host => SPEC_CONF["host"],
|
26
|
+
:locale => :ja
|
27
|
+
|
22
28
|
})
|
23
29
|
end
|
24
30
|
|
data/spec/gmo/shop_api_spec.rb
CHANGED
@@ -14,12 +14,14 @@ describe "GMO::Payment::ShopAPI" do
|
|
14
14
|
:site_pass => SPEC_CONF["site_pass"],
|
15
15
|
:shop_id => SPEC_CONF["shop_id"],
|
16
16
|
:shop_pass => SPEC_CONF["shop_pass"],
|
17
|
-
:host => SPEC_CONF["host"]
|
17
|
+
:host => SPEC_CONF["host"],
|
18
|
+
:locale => :ja
|
18
19
|
})
|
19
20
|
@service ||= GMO::Payment::ShopAPI.new({
|
20
21
|
:shop_id => SPEC_CONF["shop_id"],
|
21
22
|
:shop_pass => SPEC_CONF["shop_pass"],
|
22
|
-
:host => SPEC_CONF["host"]
|
23
|
+
:host => SPEC_CONF["host"],
|
24
|
+
:locale => :ja
|
23
25
|
})
|
24
26
|
end
|
25
27
|
|
@@ -692,6 +694,32 @@ describe "GMO::Payment::ShopAPI" do
|
|
692
694
|
end
|
693
695
|
end
|
694
696
|
|
697
|
+
describe "#cvs_cancel" do
|
698
|
+
it "gets data about a transaction", :vcr do
|
699
|
+
order_id = generate_id
|
700
|
+
result = @service.entry_tran_cvs({
|
701
|
+
:order_id => order_id,
|
702
|
+
:amount => 100
|
703
|
+
})
|
704
|
+
access_id = result["AccessID"]
|
705
|
+
access_pass = result["AccessPass"]
|
706
|
+
result = @service.cvs_cancel({
|
707
|
+
:order_id => order_id,
|
708
|
+
:access_id => access_id,
|
709
|
+
:access_pass => access_pass,
|
710
|
+
})
|
711
|
+
|
712
|
+
result["OrderID"].nil?.should_not be_truthy
|
713
|
+
result["Status"].nil?.should_not be_truthy
|
714
|
+
end
|
715
|
+
|
716
|
+
it "got error if missing options", :vcr do
|
717
|
+
lambda {
|
718
|
+
result = @service.cvs_cancel()
|
719
|
+
}.should raise_error("Required access_id, access_pass, order_id were not provided.")
|
720
|
+
end
|
721
|
+
end
|
722
|
+
|
695
723
|
describe "#search_trade" do
|
696
724
|
it "gets data about order", :vcr do
|
697
725
|
order_id = @order_id
|
data/spec/gmo/site_api_spec.rb
CHANGED
@@ -12,12 +12,16 @@ describe "GMO::Payment::SiteAPI" do
|
|
12
12
|
:site_pass => SPEC_CONF["site_pass"],
|
13
13
|
:shop_id => SPEC_CONF["shop_id"],
|
14
14
|
:shop_pass => SPEC_CONF["shop_pass"],
|
15
|
-
:host => SPEC_CONF["host"]
|
15
|
+
:host => SPEC_CONF["host"],
|
16
|
+
:locale => :ja
|
17
|
+
|
16
18
|
})
|
17
19
|
@service ||= GMO::Payment::SiteAPI.new({
|
18
20
|
:site_id => SPEC_CONF["site_id"],
|
19
21
|
:site_pass => SPEC_CONF["site_pass"],
|
20
|
-
:host => SPEC_CONF["host"]
|
22
|
+
:host => SPEC_CONF["host"],
|
23
|
+
:locale => :ja
|
24
|
+
|
21
25
|
})
|
22
26
|
end
|
23
27
|
|
@@ -283,4 +287,4 @@ describe "GMO::Payment::SiteAPI" do
|
|
283
287
|
}.should raise_error('Required member_id, seq_mode, token_seq were not provided.')
|
284
288
|
end
|
285
289
|
end
|
286
|
-
end
|
290
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gmo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tatsuo Kaniwa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -128,6 +128,7 @@ files:
|
|
128
128
|
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_brandtoken_gets_data_about_order.yml
|
129
129
|
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_gets_data_about_order.yml
|
130
130
|
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_change_tran_got_error_if_missing_options.yml
|
131
|
+
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_cvs_cancel_gets_data_about_a_transaction.yml
|
131
132
|
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_brandtoken_gets_data_about_a_transaction.yml
|
132
133
|
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_cvs_gets_data_about_a_transaction.yml
|
133
134
|
- fixtures/vcr_cassettes/GMO_Payment_ShopAPI/_entry_tran_cvs_got_error_if_missing_options.yml
|
@@ -216,7 +217,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
216
217
|
version: '0'
|
217
218
|
requirements: []
|
218
219
|
rubyforge_project:
|
219
|
-
rubygems_version: 2.7.
|
220
|
+
rubygems_version: 2.7.6
|
220
221
|
signing_key:
|
221
222
|
specification_version: 4
|
222
223
|
summary: 'GMO Payment API client: Ruby client library for the GMO Payment Platform.'
|