gmo-pg 1.0.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 +7 -0
- data/.gitignore +56 -0
- data/.rspec +3 -0
- data/Gemfile +18 -0
- data/Guardfile +20 -0
- data/LICENSE.txt +21 -0
- data/README.md +68 -0
- data/Rakefile +6 -0
- data/bin/console +10 -0
- data/gmo-pg.gemspec +22 -0
- data/lib/gmo-pg.rb +28 -0
- data/lib/gmo-pg/api_endpoint.rb +25 -0
- data/lib/gmo-pg/api_endpoint/alter_tran.rb +28 -0
- data/lib/gmo-pg/api_endpoint/change_tran.rb +26 -0
- data/lib/gmo-pg/api_endpoint/delete_card.rb +19 -0
- data/lib/gmo-pg/api_endpoint/delete_member.rb +17 -0
- data/lib/gmo-pg/api_endpoint/entry_tran.rb +24 -0
- data/lib/gmo-pg/api_endpoint/exec_tran.rb +51 -0
- data/lib/gmo-pg/api_endpoint/save_card.rb +34 -0
- data/lib/gmo-pg/api_endpoint/save_member.rb +18 -0
- data/lib/gmo-pg/api_endpoint/search_card.rb +31 -0
- data/lib/gmo-pg/api_endpoint/search_card_detail.rb +29 -0
- data/lib/gmo-pg/api_endpoint/search_member.rb +19 -0
- data/lib/gmo-pg/api_endpoint/search_trade.rb +37 -0
- data/lib/gmo-pg/api_endpoint/secure_tran.rb +27 -0
- data/lib/gmo-pg/api_endpoint/traded_card.rb +25 -0
- data/lib/gmo-pg/api_endpoint/update_member.rb +18 -0
- data/lib/gmo-pg/dispatcher.rb +79 -0
- data/lib/gmo-pg/dispatcher/shorthands.rb +31 -0
- data/lib/gmo-pg/error.rb +76 -0
- data/lib/gmo-pg/http_resource.rb +4 -0
- data/lib/gmo-pg/http_resource/errors.rb +28 -0
- data/lib/gmo-pg/http_resource/generic_request.rb +36 -0
- data/lib/gmo-pg/http_resource/generic_response.rb +23 -0
- data/lib/gmo-pg/http_resource/payload.rb +84 -0
- data/lib/gmo-pg/http_resource/payload/typecast.rb +87 -0
- data/lib/gmo-pg/version.rb +5 -0
- data/wercker.yml +8 -0
- metadata +82 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 8c7e203d1ae1c7fc0ada9c84574b19e5fefe8be6
|
|
4
|
+
data.tar.gz: f0eaf4e532c378ed4a29c1aedf11f92c48804acd
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: b35c8c333ae5b0e9a7ffe4cdcbcdb31a3e6f2a67f231c5fa9614a3fea56dbd61b764b81b3d7873a53df72614956bb8439434ac5633a653c8e54ad1a347d5ae8a
|
|
7
|
+
data.tar.gz: 401e3442a26e3863503728e1fae4b3fa2a0a55e3be89b63aed48bddff774642508221ea6eba984afb726423b2e96cac36d036494087526c25704757d98695a27
|
data/.gitignore
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
|
|
2
|
+
# Created by https://www.gitignore.io/api/ruby
|
|
3
|
+
|
|
4
|
+
### Ruby ###
|
|
5
|
+
*.gem
|
|
6
|
+
*.rbc
|
|
7
|
+
/.config
|
|
8
|
+
/coverage/
|
|
9
|
+
/InstalledFiles
|
|
10
|
+
/pkg/
|
|
11
|
+
/spec/reports/
|
|
12
|
+
/spec/examples.txt
|
|
13
|
+
/test/tmp/
|
|
14
|
+
/test/version_tmp/
|
|
15
|
+
/tmp/
|
|
16
|
+
|
|
17
|
+
# Used by dotenv library to load environment variables.
|
|
18
|
+
# .env
|
|
19
|
+
|
|
20
|
+
## Specific to RubyMotion:
|
|
21
|
+
.dat*
|
|
22
|
+
.repl_history
|
|
23
|
+
build/
|
|
24
|
+
*.bridgesupport
|
|
25
|
+
build-iPhoneOS/
|
|
26
|
+
build-iPhoneSimulator/
|
|
27
|
+
|
|
28
|
+
## Specific to RubyMotion (use of CocoaPods):
|
|
29
|
+
#
|
|
30
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
|
31
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
|
32
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
|
33
|
+
#
|
|
34
|
+
# vendor/Pods/
|
|
35
|
+
|
|
36
|
+
## Documentation cache and generated files:
|
|
37
|
+
/.yardoc/
|
|
38
|
+
/_yardoc/
|
|
39
|
+
/doc/
|
|
40
|
+
/rdoc/
|
|
41
|
+
|
|
42
|
+
## Environment normalization:
|
|
43
|
+
/.bundle/
|
|
44
|
+
/vendor/bundle
|
|
45
|
+
/lib/bundler/man/
|
|
46
|
+
|
|
47
|
+
# for a library or gem, you might want to ignore these files since the code is
|
|
48
|
+
# intended to run in multiple environments; otherwise, check them in:
|
|
49
|
+
Gemfile.lock
|
|
50
|
+
.ruby-version
|
|
51
|
+
.ruby-gemset
|
|
52
|
+
|
|
53
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
|
54
|
+
.rvmrc
|
|
55
|
+
|
|
56
|
+
# End of https://www.gitignore.io/api/ruby
|
data/.rspec
ADDED
data/Gemfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
source 'https://rubygems.org'
|
|
2
|
+
|
|
3
|
+
# Specify your gem's dependencies in gmo-pg.gemspec
|
|
4
|
+
gemspec
|
|
5
|
+
|
|
6
|
+
group :development do
|
|
7
|
+
gem 'rake', '~> 10.0'
|
|
8
|
+
gem 'rspec', '~> 3.0'
|
|
9
|
+
gem 'turnip', '~> 2.1'
|
|
10
|
+
gem 'webmock', '~> 2.0'
|
|
11
|
+
gem 'vcr', '~> 3.0'
|
|
12
|
+
gem 'pry'
|
|
13
|
+
gem 'pry-byebug'
|
|
14
|
+
gem 'guard'
|
|
15
|
+
gem 'guard-rspec'
|
|
16
|
+
gem 'fuubar'
|
|
17
|
+
gem 'yard'
|
|
18
|
+
end
|
data/Guardfile
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
guard :rspec, cmd: 'bundle exec rspec --format Fuubar' do
|
|
2
|
+
require 'guard/rspec/dsl'
|
|
3
|
+
dsl = Guard::RSpec::Dsl.new(self)
|
|
4
|
+
|
|
5
|
+
# RSpec files
|
|
6
|
+
rspec = dsl.rspec
|
|
7
|
+
watch(rspec.spec_helper) { rspec.spec_dir }
|
|
8
|
+
watch(rspec.spec_support) { rspec.spec_dir }
|
|
9
|
+
watch(rspec.spec_files)
|
|
10
|
+
|
|
11
|
+
# Ruby files
|
|
12
|
+
ruby = dsl.ruby
|
|
13
|
+
dsl.watch_spec_files_for(ruby.lib_files)
|
|
14
|
+
|
|
15
|
+
# Turnip features and steps
|
|
16
|
+
watch(%r{^spec/acceptance/(.+)\.feature$})
|
|
17
|
+
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) do |m|
|
|
18
|
+
Dir[File.join("**/#{m[1]}.feature")][0] || "spec/acceptance"
|
|
19
|
+
end
|
|
20
|
+
end
|
data/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2016 kissy2go
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# GMO-PG
|
|
2
|
+
|
|
3
|
+
[](https://github.com/kissy2go/gmo-pg)
|
|
4
|
+
|
|
5
|
+
[](https://badge.fury.io/rb/gmo-pg)
|
|
6
|
+
[](https://app.wercker.com/project/byKey/1eb7ae8fcece997421923ffe8dc46ec7)
|
|
7
|
+
[](#license)
|
|
8
|
+
|
|
9
|
+
The GMO-PG Ruby bindings provide a simple SDK for convenient access to the GMO-PG Multi-Payment API from application written in the Ruby language.
|
|
10
|
+
|
|
11
|
+
## Installation
|
|
12
|
+
|
|
13
|
+
Add this line to your application's Gemfile:
|
|
14
|
+
|
|
15
|
+
```ruby
|
|
16
|
+
gem 'gmo-pg'
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
And then execute:
|
|
20
|
+
|
|
21
|
+
$ bundle
|
|
22
|
+
|
|
23
|
+
Or install it yourself as:
|
|
24
|
+
|
|
25
|
+
$ gem install gmo-pg
|
|
26
|
+
|
|
27
|
+
## Usage
|
|
28
|
+
|
|
29
|
+
For example, to check card availability, like this:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
GMO::PG.base_url = 'https://...' # required
|
|
33
|
+
|
|
34
|
+
GMO::PG.connect do |dispatcher|
|
|
35
|
+
dispatcher #=> #<GMO::PG::Dispatcher>
|
|
36
|
+
|
|
37
|
+
credential = dispatcher.dispatch_entry_tran(
|
|
38
|
+
shop_id: YOUR_SHOP_ID,
|
|
39
|
+
shop_pass: YOUR_SHOP_PASS,
|
|
40
|
+
order_id: order_id,
|
|
41
|
+
job_cd: :CHECK,
|
|
42
|
+
)
|
|
43
|
+
credential #=> #<GMO::PG::EntryTran::Response>
|
|
44
|
+
|
|
45
|
+
result = dispatcher.dispatch_entry_tran(
|
|
46
|
+
access_id: credential.access_id,
|
|
47
|
+
access_pass: credential.access_pass,
|
|
48
|
+
order_id: order_id,
|
|
49
|
+
card_no: '...',
|
|
50
|
+
expire: '...',
|
|
51
|
+
security_code: '...',
|
|
52
|
+
)
|
|
53
|
+
result #=> #<GMO::PG::ExecTran::Response>
|
|
54
|
+
end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
## Development
|
|
58
|
+
|
|
59
|
+
After checking out the repo, install dependencies via bundler. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
|
60
|
+
|
|
61
|
+
## Contributing
|
|
62
|
+
|
|
63
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/kissy2go/gmo-pg. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
## License
|
|
67
|
+
|
|
68
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
data/gmo-pg.gemspec
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
|
+
require 'gmo-pg/version'
|
|
5
|
+
|
|
6
|
+
Gem::Specification.new do |spec|
|
|
7
|
+
spec.name = 'gmo-pg'
|
|
8
|
+
spec.version = GMO::PG::VERSION
|
|
9
|
+
spec.authors = %w{ kissy2go }
|
|
10
|
+
spec.email = %w{ kissy2go@gmail.com }
|
|
11
|
+
|
|
12
|
+
spec.summary = 'Ruby bindings for GMO-PG Multi-Payment Service'
|
|
13
|
+
spec.description = 'GMO-PG is No.1 Payment Gateway in Japan. See https://www.gmo-pg.com for details.'
|
|
14
|
+
spec.homepage = 'https://github.com/kissy2go/gmo-pg'
|
|
15
|
+
spec.license = 'MIT'
|
|
16
|
+
|
|
17
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^spec/}) }
|
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
19
|
+
spec.require_paths = %{ lib }
|
|
20
|
+
|
|
21
|
+
spec.required_ruby_version = Gem::Requirement.new('>= 2.2.0')
|
|
22
|
+
end
|
data/lib/gmo-pg.rb
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require 'gmo-pg/version'
|
|
2
|
+
|
|
3
|
+
require 'gmo-pg/http_resource'
|
|
4
|
+
require 'gmo-pg/api_endpoint'
|
|
5
|
+
require 'gmo-pg/dispatcher'
|
|
6
|
+
require 'gmo-pg/error'
|
|
7
|
+
|
|
8
|
+
module GMO
|
|
9
|
+
module PG
|
|
10
|
+
@open_timeout = 60
|
|
11
|
+
@read_timeout = 90
|
|
12
|
+
@raise_on_api_error = true
|
|
13
|
+
|
|
14
|
+
class << self
|
|
15
|
+
attr_accessor :base_url, :open_timeout, :read_timeout, :proxy, :raise_on_api_error
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.connect(&block)
|
|
19
|
+
dispatcher = Dispatcher.new(base_url) do |d|
|
|
20
|
+
d.open_timeout = open_timeout
|
|
21
|
+
d.read_timeout = read_timeout
|
|
22
|
+
d.raise_on_api_error = raise_on_api_error
|
|
23
|
+
d.use_proxy proxy if proxy
|
|
24
|
+
end
|
|
25
|
+
dispatcher.connect(&block)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module APIEndpoint
|
|
4
|
+
def endpoint_path
|
|
5
|
+
"/payment/#{self.name.split('::')[-1]}.idPass"
|
|
6
|
+
end
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
require 'gmo-pg/api_endpoint/entry_tran'
|
|
12
|
+
require 'gmo-pg/api_endpoint/exec_tran'
|
|
13
|
+
require 'gmo-pg/api_endpoint/secure_tran'
|
|
14
|
+
require 'gmo-pg/api_endpoint/save_member'
|
|
15
|
+
require 'gmo-pg/api_endpoint/update_member'
|
|
16
|
+
require 'gmo-pg/api_endpoint/delete_member'
|
|
17
|
+
require 'gmo-pg/api_endpoint/search_member'
|
|
18
|
+
require 'gmo-pg/api_endpoint/save_card'
|
|
19
|
+
require 'gmo-pg/api_endpoint/delete_card'
|
|
20
|
+
require 'gmo-pg/api_endpoint/search_card'
|
|
21
|
+
require 'gmo-pg/api_endpoint/alter_tran'
|
|
22
|
+
require 'gmo-pg/api_endpoint/change_tran'
|
|
23
|
+
require 'gmo-pg/api_endpoint/search_trade'
|
|
24
|
+
require 'gmo-pg/api_endpoint/traded_card'
|
|
25
|
+
require 'gmo-pg/api_endpoint/search_card_detail'
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module AlterTran
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :ShopID, :shop_id
|
|
8
|
+
bind_attribute :ShopPass, :shop_pass
|
|
9
|
+
bind_attribute :AccessID, :access_id
|
|
10
|
+
bind_attribute :AccessPass, :access_pass
|
|
11
|
+
bind_attribute :JobCd, :job_cd
|
|
12
|
+
bind_attribute :Amount, :amount, typecast: :integer
|
|
13
|
+
bind_attribute :Tax, :tax, typecast: :integer
|
|
14
|
+
bind_attribute :Method, :method
|
|
15
|
+
bind_attribute :PayTimes, :pay_times, typecast: :integer
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Response < GMO::PG::GenericResponse
|
|
19
|
+
bind_attribute :AccessID, :access_id
|
|
20
|
+
bind_attribute :AccessPass, :access_pass
|
|
21
|
+
bind_attribute :Forward, :forward
|
|
22
|
+
bind_attribute :Approve, :approve
|
|
23
|
+
bind_attribute :TranID, :tran_id
|
|
24
|
+
bind_attribute :TranDate, :tran_date, typecast: :epoch_time
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module ChangeTran
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :ShopID, :shop_id
|
|
8
|
+
bind_attribute :ShopPass, :shop_pass
|
|
9
|
+
bind_attribute :AccessID, :access_id
|
|
10
|
+
bind_attribute :AccessPass, :access_pass
|
|
11
|
+
bind_attribute :JobCd, :job_cd
|
|
12
|
+
bind_attribute :Amount, :amount, typecast: :integer
|
|
13
|
+
bind_attribute :Tax, :tax, typecast: :integer
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
class Response < GMO::PG::GenericResponse
|
|
17
|
+
bind_attribute :AccessID, :access_id
|
|
18
|
+
bind_attribute :AccessPass, :access_pass
|
|
19
|
+
bind_attribute :Forward, :forward
|
|
20
|
+
bind_attribute :Approve, :approve
|
|
21
|
+
bind_attribute :TranID, :tran_id
|
|
22
|
+
bind_attribute :TranDate, :tran_date, typecast: :epoch_time
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module DeleteCard
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
bind_attribute :SeqMode, :seq_mode
|
|
11
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class Response < GMO::PG::GenericResponse
|
|
15
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module DeleteMember
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Response < GMO::PG::GenericResponse
|
|
13
|
+
bind_attribute :MemberID, :member_id
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module EntryTran
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :ShopID, :shop_id
|
|
8
|
+
bind_attribute :ShopPass, :shop_pass
|
|
9
|
+
bind_attribute :OrderID, :order_id
|
|
10
|
+
bind_attribute :JobCd, :job_cd
|
|
11
|
+
bind_attribute :ItemCode, :item_code
|
|
12
|
+
bind_attribute :Amount, :amount, typecast: :integer
|
|
13
|
+
bind_attribute :Tax, :tax, typecast: :integer
|
|
14
|
+
bind_attribute :TdFlag, :td_flag
|
|
15
|
+
bind_attribute :TdTenantName, :td_tenant_name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Response < GMO::PG::GenericResponse
|
|
19
|
+
bind_attribute :AccessID, :access_id
|
|
20
|
+
bind_attribute :AccessPass, :access_pass
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module ExecTran
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :AccessID, :access_id
|
|
8
|
+
bind_attribute :AccessPass, :access_pass
|
|
9
|
+
bind_attribute :OrderID, :order_id
|
|
10
|
+
bind_attribute :Method, :method
|
|
11
|
+
bind_attribute :PayTimes, :pay_times, typecast: :integer
|
|
12
|
+
bind_attribute :CardNo, :card_no
|
|
13
|
+
bind_attribute :Expire, :expire
|
|
14
|
+
bind_attribute :SiteID, :site_id
|
|
15
|
+
bind_attribute :SitePass, :site_pass
|
|
16
|
+
bind_attribute :MemberID, :member_id
|
|
17
|
+
bind_attribute :SeqMode, :seq_mode
|
|
18
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
19
|
+
bind_attribute :CardPass, :card_pass
|
|
20
|
+
bind_attribute :SecurityCode, :security_code
|
|
21
|
+
bind_attribute :Token, :token
|
|
22
|
+
bind_attribute :PIN, :pin
|
|
23
|
+
bind_attribute :HttpAccept, :http_accept
|
|
24
|
+
bind_attribute :HttpUserAgent, :http_user_agent
|
|
25
|
+
bind_attribute :DeviceCategory, :device_category
|
|
26
|
+
bind_attribute :ClientField1, :client_field_1
|
|
27
|
+
bind_attribute :ClientField2, :client_field_2
|
|
28
|
+
bind_attribute :ClientField3, :client_field_3
|
|
29
|
+
bind_attribute :ClientFieldFlag, :client_field_flag
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
class Response < GMO::PG::GenericResponse
|
|
33
|
+
bind_attribute :ACS, :acs
|
|
34
|
+
bind_attribute :OrderID, :order_id
|
|
35
|
+
bind_attribute :Forward, :forward
|
|
36
|
+
bind_attribute :Method, :method
|
|
37
|
+
bind_attribute :PayTimes, :pay_times, typecast: :integer
|
|
38
|
+
bind_attribute :Approve, :approve
|
|
39
|
+
bind_attribute :TranID, :tran_id
|
|
40
|
+
bind_attribute :TranDate, :tran_date, typecast: :epoch_time
|
|
41
|
+
bind_attribute :CheckString, :check_string
|
|
42
|
+
bind_attribute :ClientField1, :client_field_1
|
|
43
|
+
bind_attribute :ClientField2, :client_field_2
|
|
44
|
+
bind_attribute :ClientField3, :client_field_3
|
|
45
|
+
bind_attribute :ACSUrl, :acs_url
|
|
46
|
+
bind_attribute :PaReq, :pa_req
|
|
47
|
+
bind_attribute :MD, :md
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SaveCard
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
bind_attribute :SeqMode, :seq_mode
|
|
11
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
12
|
+
bind_attribute :DefaultFlag, :default_flag
|
|
13
|
+
bind_attribute :CardName, :card_name
|
|
14
|
+
bind_attribute :CardNo, :card_no
|
|
15
|
+
bind_attribute :CardPass, :card_pass
|
|
16
|
+
bind_attribute :Expire, :expire
|
|
17
|
+
bind_attribute :HolderName, :holder_name
|
|
18
|
+
bind_attribute :Token, :token
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Response < GMO::PG::GenericResponse
|
|
22
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
23
|
+
bind_attribute :CardNo, :card_no
|
|
24
|
+
bind_attribute :Forward, :forward
|
|
25
|
+
bind_attribute :Brand, :brand
|
|
26
|
+
bind_attribute :DomesticFlag, :domestic_flag
|
|
27
|
+
bind_attribute :IssuerCode, :issuer_code
|
|
28
|
+
bind_attribute :DebitPrepaidFlag, :debit_prepaid_flag
|
|
29
|
+
bind_attribute :DebitPrepaidIssuerName, :debit_prepaid_issuer_name
|
|
30
|
+
bind_attribute :ForwardFinal, :forward_final
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SaveMember
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
bind_attribute :MemberName, :member_name
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Response < GMO::PG::GenericResponse
|
|
14
|
+
bind_attribute :MemberID, :member_id
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SearchCard
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
bind_attribute :SeqMode, :seq_mode
|
|
11
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
class Response < GMO::PG::GenericResponse
|
|
15
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
16
|
+
bind_attribute :DefaultFlag, :default_flag
|
|
17
|
+
bind_attribute :CardName, :card_name
|
|
18
|
+
bind_attribute :CardNo, :card_no
|
|
19
|
+
bind_attribute :Expire, :expire
|
|
20
|
+
bind_attribute :HolderName, :holder_name
|
|
21
|
+
bind_attribute :DeleteFlag, :delete_flag
|
|
22
|
+
bind_attribute :Brand, :brand
|
|
23
|
+
bind_attribute :DomesticFlag, :domestic_flag
|
|
24
|
+
bind_attribute :IssuerCode, :issuer_code
|
|
25
|
+
bind_attribute :DebitPrepaidFlag, :debit_prepaid_flag
|
|
26
|
+
bind_attribute :DebitPrepaidIssuerName, :debit_prepaid_issuer_name
|
|
27
|
+
bind_attribute :ForwardFinal, :forward_final
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SearchCardDetail
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :ShopID, :shop_id
|
|
8
|
+
bind_attribute :ShopPass, :shop_pass
|
|
9
|
+
bind_attribute :CardNo, :card_no
|
|
10
|
+
bind_attribute :OrderID, :order_id
|
|
11
|
+
bind_attribute :SiteID, :site_id
|
|
12
|
+
bind_attribute :SitePass, :site_pass
|
|
13
|
+
bind_attribute :MemberID, :member_id
|
|
14
|
+
bind_attribute :SeqMode, :seq_mode
|
|
15
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Response < GMO::PG::GenericResponse
|
|
19
|
+
bind_attribute :CardNo, :card_no
|
|
20
|
+
bind_attribute :Brand, :brand
|
|
21
|
+
bind_attribute :DomesticFlag, :domestic_flag
|
|
22
|
+
bind_attribute :IssuerCode, :issuer_code
|
|
23
|
+
bind_attribute :DebitPrepaidFlag, :debit_prepaid_flag
|
|
24
|
+
bind_attribute :DebitPrepaidIssuerName, :debit_prepaid_issuer_name
|
|
25
|
+
bind_attribute :ForwardFinal, :forward_final
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SearchMember
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Response < GMO::PG::GenericResponse
|
|
13
|
+
bind_attribute :MemberID, :member_id
|
|
14
|
+
bind_attribute :MemberName, :member_name
|
|
15
|
+
bind_attribute :DeleteFlag, :delete_flag
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SearchTrade
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :ShopID, :shop_id
|
|
8
|
+
bind_attribute :ShopPass, :shop_pass
|
|
9
|
+
bind_attribute :OrderID, :order_id
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
class Response < GMO::PG::GenericResponse
|
|
13
|
+
bind_attribute :OrderID, :order_id
|
|
14
|
+
bind_attribute :Status, :status
|
|
15
|
+
bind_attribute :ProcessDate, :process_date, typecast: :epoch_time
|
|
16
|
+
bind_attribute :JobCd, :job_cd
|
|
17
|
+
bind_attribute :AccessID, :access_id
|
|
18
|
+
bind_attribute :AccessPass, :access_pass
|
|
19
|
+
bind_attribute :ItemCode, :item_code
|
|
20
|
+
bind_attribute :Amount, :amount, typecast: :integer
|
|
21
|
+
bind_attribute :Tax, :tax, typecast: :integer
|
|
22
|
+
bind_attribute :SiteID, :site_id
|
|
23
|
+
bind_attribute :MemberID, :member_id
|
|
24
|
+
bind_attribute :CardNo, :card_no
|
|
25
|
+
bind_attribute :Expire, :expire
|
|
26
|
+
bind_attribute :Method, :method
|
|
27
|
+
bind_attribute :PayTimes, :pay_times, typecast: :integer
|
|
28
|
+
bind_attribute :Forward, :forward
|
|
29
|
+
bind_attribute :TranID, :tran_id
|
|
30
|
+
bind_attribute :Approve, :approve
|
|
31
|
+
bind_attribute :ClientField1, :client_field_1
|
|
32
|
+
bind_attribute :ClientField2, :client_field_2
|
|
33
|
+
bind_attribute :ClientField3, :client_field_3
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module SecureTran
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :PaRes, :pa_res
|
|
8
|
+
bind_attribute :MD, :md
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
class Response < GMO::PG::GenericResponse
|
|
12
|
+
bind_attribute :OrderID, :order_id
|
|
13
|
+
bind_attribute :Forward, :forward
|
|
14
|
+
bind_attribute :Method, :method
|
|
15
|
+
bind_attribute :PayTimes, :pay_times, typecast: :integer
|
|
16
|
+
bind_attribute :Approve, :approve
|
|
17
|
+
bind_attribute :TranID, :tran_id
|
|
18
|
+
bind_attribute :TranDate, :tran_date, typecast: :epoch_time
|
|
19
|
+
bind_attribute :CheckString, :check_string
|
|
20
|
+
bind_attribute :ClientField1, :client_field_1
|
|
21
|
+
bind_attribute :ClientField2, :client_field_2
|
|
22
|
+
bind_attribute :ClientField3, :client_field_3
|
|
23
|
+
bind_attribute :ClientField3, :client_field_3
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module TradedCard
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :ShopID, :shop_id
|
|
8
|
+
bind_attribute :ShopPass, :shop_pass
|
|
9
|
+
bind_attribute :OrderID, :order_id
|
|
10
|
+
bind_attribute :SiteID, :site_id
|
|
11
|
+
bind_attribute :SitePass, :site_pass
|
|
12
|
+
bind_attribute :MemberID, :member_id
|
|
13
|
+
bind_attribute :SeqMode, :seq_mode
|
|
14
|
+
bind_attribute :DefaultFlag, :default_flag
|
|
15
|
+
bind_attribute :HolderName, :holder_name
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Response < GMO::PG::GenericResponse
|
|
19
|
+
bind_attribute :CardSeq, :card_seq, typecast: :integer
|
|
20
|
+
bind_attribute :CardNo, :card_no
|
|
21
|
+
bind_attribute :Forward, :forward
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
module UpdateMember
|
|
4
|
+
extend APIEndpoint
|
|
5
|
+
|
|
6
|
+
class Request < GMO::PG::GenericRequest
|
|
7
|
+
bind_attribute :SiteID, :site_id
|
|
8
|
+
bind_attribute :SitePass, :site_pass
|
|
9
|
+
bind_attribute :MemberID, :member_id
|
|
10
|
+
bind_attribute :MemberName, :member_name
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class Response < GMO::PG::GenericResponse
|
|
14
|
+
bind_attribute :MemberID, :member_id
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
require 'gmo-pg/dispatcher/shorthands'
|
|
2
|
+
|
|
3
|
+
module GMO
|
|
4
|
+
module PG
|
|
5
|
+
class Dispatcher
|
|
6
|
+
extend Forwardable
|
|
7
|
+
include Shorthands
|
|
8
|
+
|
|
9
|
+
attr_reader :base_url
|
|
10
|
+
attr_accessor :raise_on_api_error
|
|
11
|
+
|
|
12
|
+
def_delegators :@http,
|
|
13
|
+
:open_timeout, :open_timeout=,
|
|
14
|
+
:read_timeout, :read_timeout=,
|
|
15
|
+
:proxy_address, :proxy_port, :proxy_user, :proxy_pass
|
|
16
|
+
def_delegator :@http, :started?, :connected?
|
|
17
|
+
|
|
18
|
+
def initialize(base_url)
|
|
19
|
+
@base_url = base_url
|
|
20
|
+
url = URI.parse(@base_url)
|
|
21
|
+
@http = Net::HTTP.new(url.host, url.port)
|
|
22
|
+
@http.use_ssl = true if url.scheme == 'https'
|
|
23
|
+
yield self if block_given?
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def use_proxy(address: :ENV, port: nil, user: nil, pass: nil)
|
|
27
|
+
@http.proxy_from_env = (address == :ENV)
|
|
28
|
+
@http.proxy_address = address
|
|
29
|
+
@http.proxy_port = port
|
|
30
|
+
@http.proxy_user = user
|
|
31
|
+
@http.proxy_pass = pass
|
|
32
|
+
self
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def connect
|
|
36
|
+
handle_http_error do
|
|
37
|
+
@http.start { yield self if block_given? }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def dispatch(request)
|
|
42
|
+
req = Net::HTTP::Post.new(request.path)
|
|
43
|
+
req.body = GMO::PG::Payload.encode(request.payload)
|
|
44
|
+
|
|
45
|
+
handle_http_error do
|
|
46
|
+
res = @http.request(req)
|
|
47
|
+
case res
|
|
48
|
+
when Net::HTTPSuccess
|
|
49
|
+
payload = GMO::PG::Payload.decode(res.body)
|
|
50
|
+
response = request.class.corresponding_response_class.new(payload)
|
|
51
|
+
handle_api_error request, response if @raise_on_api_error
|
|
52
|
+
response
|
|
53
|
+
else
|
|
54
|
+
res.value # raise Net::XxxError
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
private
|
|
60
|
+
|
|
61
|
+
def handle_http_error
|
|
62
|
+
begin
|
|
63
|
+
yield if block_given?
|
|
64
|
+
rescue => e
|
|
65
|
+
raise GMO::PG::Error.from_http_error(e)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def handle_api_error(request, response)
|
|
70
|
+
return response unless response.error?
|
|
71
|
+
|
|
72
|
+
raise response.errors.first.to_error.tap do |e|
|
|
73
|
+
e.request = request
|
|
74
|
+
e.response = response
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
class Dispatcher
|
|
4
|
+
module Shorthands
|
|
5
|
+
private
|
|
6
|
+
|
|
7
|
+
def self.register_shorthand(endpoint, name)
|
|
8
|
+
define_method :"dispatch_#{name}" do |attributes|
|
|
9
|
+
dispatch(endpoint::Request.new(attributes))
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
register_shorthand GMO::PG::EntryTran, :entry_tran
|
|
14
|
+
register_shorthand GMO::PG::ExecTran, :exec_tran
|
|
15
|
+
register_shorthand GMO::PG::SecureTran, :secure_tran
|
|
16
|
+
register_shorthand GMO::PG::SaveMember, :save_member
|
|
17
|
+
register_shorthand GMO::PG::UpdateMember, :update_member
|
|
18
|
+
register_shorthand GMO::PG::DeleteMember, :delete_member
|
|
19
|
+
register_shorthand GMO::PG::SearchMember, :search_member
|
|
20
|
+
register_shorthand GMO::PG::SaveCard, :save_card
|
|
21
|
+
register_shorthand GMO::PG::DeleteCard, :delete_card
|
|
22
|
+
register_shorthand GMO::PG::SearchCard, :search_card
|
|
23
|
+
register_shorthand GMO::PG::AlterTran, :alter_tran
|
|
24
|
+
register_shorthand GMO::PG::ChangeTran, :change_tran
|
|
25
|
+
register_shorthand GMO::PG::SearchTrade, :search_trade
|
|
26
|
+
register_shorthand GMO::PG::TradedCard, :traded_card
|
|
27
|
+
register_shorthand GMO::PG::SearchCardDetail, :search_card_detail
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
data/lib/gmo-pg/error.rb
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
class Error < StandardError
|
|
4
|
+
def self.from_http_error(e)
|
|
5
|
+
case e
|
|
6
|
+
when Timeout::Error
|
|
7
|
+
GMO::PG::ConnectionError.new(e.message)
|
|
8
|
+
when Net::HTTPError,
|
|
9
|
+
Net::HTTPRetriableError,
|
|
10
|
+
Net::HTTPServerException,
|
|
11
|
+
Net::HTTPFatalError,
|
|
12
|
+
Net::HTTPBadResponse,
|
|
13
|
+
Net::HTTPHeaderSyntaxError
|
|
14
|
+
GMO::PG::HTTPError.new(e.message)
|
|
15
|
+
else
|
|
16
|
+
new(e.message)
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def self.from_api_error(err_code, err_info)
|
|
21
|
+
case err_info
|
|
22
|
+
when /\AE01(01|02|03|19|20|21)/
|
|
23
|
+
# E0101: Invalid ShopID
|
|
24
|
+
# E0102: Invalid ShopPass
|
|
25
|
+
# E0103: Invalid ShopID and/or ShopPass
|
|
26
|
+
# E0119: Invalid SiteID
|
|
27
|
+
# E0120: Invalid SitePass
|
|
28
|
+
# E0121: Invalid SiteID and/or SitePass
|
|
29
|
+
GMO::PG::AuthorizationError.new("Authorization error (#{err_code}|#{err_info})")
|
|
30
|
+
when /\AE01(17|18|25|26|27|46|48)/, /\AE41/
|
|
31
|
+
# E0117: Invalid CardNo
|
|
32
|
+
# E0118: Invalid Expire
|
|
33
|
+
# E0125: Invalid CardPass
|
|
34
|
+
# E0126: Invalid Method
|
|
35
|
+
# E0127: Invalid PayTimes
|
|
36
|
+
# E0146: Invalid SecurityCode
|
|
37
|
+
# E0148: Invalid HolderName
|
|
38
|
+
# E41 : Incorrect card
|
|
39
|
+
GMO::PG::CardError.new("Card error (#{err_code}|#{err_info})")
|
|
40
|
+
when /\A(E61|E91|E92)/
|
|
41
|
+
# E61: Shop configuration error
|
|
42
|
+
# E91: System error
|
|
43
|
+
# E92: Temporary unavailable
|
|
44
|
+
GMO::PG::APIServerError.new("Temporary unavailable (#{err_code}|#{err_info})")
|
|
45
|
+
else
|
|
46
|
+
GMO::PG::APIError.new("API error (#{err_code}|#{err_info})")
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class ConnectionError < Error
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class HTTPError < Error
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class APIError < Error
|
|
58
|
+
attr_accessor :request, :response
|
|
59
|
+
|
|
60
|
+
def initialize(message, request = nil, response = nil)
|
|
61
|
+
super(message)
|
|
62
|
+
@request = request
|
|
63
|
+
@response = response
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
class AuthorizationError < APIError
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
class CardError < APIError
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
class APIServerError < APIError
|
|
74
|
+
end
|
|
75
|
+
end
|
|
76
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
class Errors
|
|
4
|
+
class Record < Struct.new(:err_code, :err_info)
|
|
5
|
+
def to_error
|
|
6
|
+
GMO::PG::Error.from_api_error(err_code, err_info)
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
include Enumerable
|
|
11
|
+
|
|
12
|
+
SEPARATOR = '|'
|
|
13
|
+
|
|
14
|
+
def initialize(err_code, err_info)
|
|
15
|
+
@err_code = err_code.split(SEPARATOR) unless err_code.nil?
|
|
16
|
+
@err_info = err_info.split(SEPARATOR) unless err_info.nil?
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def each
|
|
20
|
+
return to_enum unless block_given?
|
|
21
|
+
return nil if @err_code.nil? && @err_info.nil?
|
|
22
|
+
@err_code.zip(@err_info).each do |(err_code, err_info)|
|
|
23
|
+
yield Record.new(err_code, err_info)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
class GenericRequest < Payload
|
|
4
|
+
attr_accessor :path
|
|
5
|
+
|
|
6
|
+
def self.corresponding_response_class
|
|
7
|
+
@corresponding_response_class ||= detect_corresponding_response_class
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def path
|
|
11
|
+
@path ||= self.class.detect_endpoint_path
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
private
|
|
15
|
+
|
|
16
|
+
def self.detect_endpoint_module
|
|
17
|
+
endpoint = Object.const_get(self.name.split('::')[0...-1].join('::'))
|
|
18
|
+
endpoint.is_a?(GMO::PG::APIEndpoint) ? endpoint : nil
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def self.detect_endpoint_path
|
|
22
|
+
endpoint = detect_endpoint_module
|
|
23
|
+
endpoint ? endpoint.endpoint_path : nil
|
|
24
|
+
rescue NameError
|
|
25
|
+
nil
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.detect_corresponding_response_class
|
|
29
|
+
endpoint = detect_endpoint_module
|
|
30
|
+
endpoint ? endpoint.const_get(:Response) : nil
|
|
31
|
+
rescue NameError
|
|
32
|
+
nil
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
class GenericResponse < Payload
|
|
4
|
+
def error?
|
|
5
|
+
!!(err_code || err_info)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def errors
|
|
9
|
+
GMO::PG::Errors.new(err_code, err_info) if error?
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
private
|
|
13
|
+
|
|
14
|
+
def self.inherited(inherited)
|
|
15
|
+
super
|
|
16
|
+
inherited.class_eval do
|
|
17
|
+
bind_attribute :ErrCode, :err_code
|
|
18
|
+
bind_attribute :ErrInfo, :err_info
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
require 'gmo-pg/http_resource/payload/typecast'
|
|
2
|
+
|
|
3
|
+
module GMO
|
|
4
|
+
module PG
|
|
5
|
+
class Payload
|
|
6
|
+
def self.encode(payload)
|
|
7
|
+
URI.encode_www_form(payload)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def self.decode(body)
|
|
11
|
+
Hash[URI.decode_www_form(body)]
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def initialize(attributes = {})
|
|
15
|
+
@attributes = {}
|
|
16
|
+
attributes.each do |name, value|
|
|
17
|
+
self[name] = value
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def []=(name, value)
|
|
22
|
+
param_name, _, options = self.class.detect_bind_attribute(name)
|
|
23
|
+
@attributes[param_name] = Typecast.detect(options[:typecast]).new(value)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def [](name)
|
|
27
|
+
param_name = self.class.detect_param_name(name)
|
|
28
|
+
return unless @attributes.key?(param_name)
|
|
29
|
+
@attributes[param_name].to_attribute
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def payload
|
|
33
|
+
@attributes.each_with_object({}) do |(param_name, value), payload|
|
|
34
|
+
payload[param_name] = value.to_payload
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def to_hash
|
|
39
|
+
@attributes.each_with_object({}) do |(param_name, value), hash|
|
|
40
|
+
hash[self.class.detect_attribute_name(param_name)] = value.to_attribute
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def inspect
|
|
45
|
+
'#<%s:%014x "%s">' % [
|
|
46
|
+
self.class.name,
|
|
47
|
+
object_id << 1, # @see http://stackoverflow.com/questions/2818602/in-ruby-why-does-inspect-print-out-some-kind-of-object-id-which-is-different
|
|
48
|
+
self.class.encode(payload),
|
|
49
|
+
]
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
private
|
|
53
|
+
|
|
54
|
+
def self.inherited(inherited)
|
|
55
|
+
inherited.class_eval do
|
|
56
|
+
@bind_attributes = []
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
def self.bind_attribute(param_name, attr_name, typecast: nil)
|
|
61
|
+
@bind_attributes << [param_name, attr_name, { typecast: typecast }]
|
|
62
|
+
|
|
63
|
+
define_method(:"#{attr_name}") { self[attr_name] }
|
|
64
|
+
define_method(:"#{attr_name}=") { |value| self[attr_name] = value }
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.detect_bind_attribute(name)
|
|
68
|
+
name = name.respond_to?(:to_sym) ? name.to_sym : name
|
|
69
|
+
@bind_attributes.each do |(param_name, attr_name, options)|
|
|
70
|
+
return [param_name, attr_name, options] if name == param_name || name == attr_name
|
|
71
|
+
end
|
|
72
|
+
[name, name, {}]
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.detect_attribute_name(name)
|
|
76
|
+
detect_bind_attribute(name)[1]
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
def self.detect_param_name(name)
|
|
80
|
+
detect_bind_attribute(name)[0]
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
module GMO
|
|
2
|
+
module PG
|
|
3
|
+
class Payload
|
|
4
|
+
module Typecast
|
|
5
|
+
def self.detect(typecast_option)
|
|
6
|
+
case typecast_option
|
|
7
|
+
when /\Ainteger\z/ then TypecastableInteger
|
|
8
|
+
when /\Aepoch_time\Z/ then TypecastableEpochTime
|
|
9
|
+
when Hash then TypecastableValue.from_hash(typecast_option)
|
|
10
|
+
else TypecastableValue
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class TypecastableValue
|
|
16
|
+
attr_accessor :value
|
|
17
|
+
|
|
18
|
+
def self.from_hash(typecast_option)
|
|
19
|
+
Class.new(self) do
|
|
20
|
+
define_method :to_attribute do
|
|
21
|
+
return super() unless typecast_option[:to_attribute].is_a?(Proc)
|
|
22
|
+
typecast_option[:to_attribute].call(@value) rescue super()
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
define_method :to_payload do
|
|
26
|
+
return super() unless typecast_option[:to_payload].is_a?(Proc)
|
|
27
|
+
typecast_option[:to_payload].call(@value) rescue super()
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def initialize(value)
|
|
33
|
+
@value = value
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
def to_attribute
|
|
37
|
+
@value.dup
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def to_payload
|
|
41
|
+
@value.dup.to_s
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def ==(other)
|
|
45
|
+
other_value = other.is_a?(self.class) ? other.to_payload : other
|
|
46
|
+
to_payload == other_value
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class TypecastableInteger < TypecastableValue
|
|
51
|
+
def to_attribute
|
|
52
|
+
@value.respond_to?(:to_i) ? @value.to_i : @value
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def to_payload
|
|
56
|
+
to_attribute.to_s
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class TypecastableEpochTime < TypecastableInteger
|
|
61
|
+
TIME_ZONE = '+09:00'
|
|
62
|
+
FORMAT = '%Y%m%d%H%M%S'
|
|
63
|
+
|
|
64
|
+
def format
|
|
65
|
+
FORMAT
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
def to_attribute
|
|
69
|
+
time =
|
|
70
|
+
case @value
|
|
71
|
+
when Time
|
|
72
|
+
@value
|
|
73
|
+
when DateTime
|
|
74
|
+
Time.new(@value.year, @value.month, @value.day, @value.hour, @value.min, @value.sec)
|
|
75
|
+
else
|
|
76
|
+
Time.strptime(@value, format) rescue return super
|
|
77
|
+
end
|
|
78
|
+
time.to_i rescue super
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def to_payload
|
|
82
|
+
Time.at(to_attribute).localtime(TIME_ZONE).strftime(format) rescue super
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
data/wercker.yml
ADDED
metadata
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: gmo-pg
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 1.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- kissy2go
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2017-01-25 00:00:00.000000000 Z
|
|
12
|
+
dependencies: []
|
|
13
|
+
description: GMO-PG is No.1 Payment Gateway in Japan. See https://www.gmo-pg.com for
|
|
14
|
+
details.
|
|
15
|
+
email:
|
|
16
|
+
- kissy2go@gmail.com
|
|
17
|
+
executables: []
|
|
18
|
+
extensions: []
|
|
19
|
+
extra_rdoc_files: []
|
|
20
|
+
files:
|
|
21
|
+
- ".gitignore"
|
|
22
|
+
- ".rspec"
|
|
23
|
+
- Gemfile
|
|
24
|
+
- Guardfile
|
|
25
|
+
- LICENSE.txt
|
|
26
|
+
- README.md
|
|
27
|
+
- Rakefile
|
|
28
|
+
- bin/console
|
|
29
|
+
- gmo-pg.gemspec
|
|
30
|
+
- lib/gmo-pg.rb
|
|
31
|
+
- lib/gmo-pg/api_endpoint.rb
|
|
32
|
+
- lib/gmo-pg/api_endpoint/alter_tran.rb
|
|
33
|
+
- lib/gmo-pg/api_endpoint/change_tran.rb
|
|
34
|
+
- lib/gmo-pg/api_endpoint/delete_card.rb
|
|
35
|
+
- lib/gmo-pg/api_endpoint/delete_member.rb
|
|
36
|
+
- lib/gmo-pg/api_endpoint/entry_tran.rb
|
|
37
|
+
- lib/gmo-pg/api_endpoint/exec_tran.rb
|
|
38
|
+
- lib/gmo-pg/api_endpoint/save_card.rb
|
|
39
|
+
- lib/gmo-pg/api_endpoint/save_member.rb
|
|
40
|
+
- lib/gmo-pg/api_endpoint/search_card.rb
|
|
41
|
+
- lib/gmo-pg/api_endpoint/search_card_detail.rb
|
|
42
|
+
- lib/gmo-pg/api_endpoint/search_member.rb
|
|
43
|
+
- lib/gmo-pg/api_endpoint/search_trade.rb
|
|
44
|
+
- lib/gmo-pg/api_endpoint/secure_tran.rb
|
|
45
|
+
- lib/gmo-pg/api_endpoint/traded_card.rb
|
|
46
|
+
- lib/gmo-pg/api_endpoint/update_member.rb
|
|
47
|
+
- lib/gmo-pg/dispatcher.rb
|
|
48
|
+
- lib/gmo-pg/dispatcher/shorthands.rb
|
|
49
|
+
- lib/gmo-pg/error.rb
|
|
50
|
+
- lib/gmo-pg/http_resource.rb
|
|
51
|
+
- lib/gmo-pg/http_resource/errors.rb
|
|
52
|
+
- lib/gmo-pg/http_resource/generic_request.rb
|
|
53
|
+
- lib/gmo-pg/http_resource/generic_response.rb
|
|
54
|
+
- lib/gmo-pg/http_resource/payload.rb
|
|
55
|
+
- lib/gmo-pg/http_resource/payload/typecast.rb
|
|
56
|
+
- lib/gmo-pg/version.rb
|
|
57
|
+
- wercker.yml
|
|
58
|
+
homepage: https://github.com/kissy2go/gmo-pg
|
|
59
|
+
licenses:
|
|
60
|
+
- MIT
|
|
61
|
+
metadata: {}
|
|
62
|
+
post_install_message:
|
|
63
|
+
rdoc_options: []
|
|
64
|
+
require_paths:
|
|
65
|
+
- " lib "
|
|
66
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
67
|
+
requirements:
|
|
68
|
+
- - ">="
|
|
69
|
+
- !ruby/object:Gem::Version
|
|
70
|
+
version: 2.2.0
|
|
71
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
requirements: []
|
|
77
|
+
rubyforge_project:
|
|
78
|
+
rubygems_version: 2.4.5.1
|
|
79
|
+
signing_key:
|
|
80
|
+
specification_version: 4
|
|
81
|
+
summary: Ruby bindings for GMO-PG Multi-Payment Service
|
|
82
|
+
test_files: []
|