dacom 1.0.1 → 2.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 +4 -4
- data/.travis.yml +2 -6
- data/README.md +139 -51
- data/dacom.gemspec +6 -9
- data/lib/dacom/client.rb +104 -103
- data/lib/dacom/config.rb +12 -8
- data/lib/dacom/constants.rb +1 -1
- data/lib/dacom/response.rb +2 -2
- data/lib/dacom/version.rb +1 -1
- metadata +8 -38
- data/CODE_OF_CONDUCT.md +0 -49
- data/config/dacom.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9716615797e94128f11211d26b17d51dfc551c14
|
4
|
+
data.tar.gz: f1a6a1621bbd618394587cb782008fc859f03d6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fcedf1d7851b176e524a602ba195cdcda84b7245681e04119e53c87d56d6d7c8752320458fbae66f074f5140fecd39a853461eb1a5e55c4750793800e30238a5
|
7
|
+
data.tar.gz: 84f60df6a9a5b8992a59bd7709dd16531baa9f33935882aab07040d30e1d733ff110817cb60fea5927ca5bdd3b505466200e90921ef19ae331ff1edc20e47189
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,68 +1,156 @@
|
|
1
1
|
## Table of Contents
|
2
2
|
|
3
3
|
* [Scope](#scope)
|
4
|
-
* [
|
4
|
+
* [Workflow](#workflow)
|
5
5
|
* [Client script](#client-script)
|
6
6
|
* [Collecting data](#collecting-data)
|
7
|
-
* [
|
7
|
+
* [Installation](#installation)
|
8
8
|
* [Configuration](#configuration)
|
9
|
-
|
10
|
-
* [
|
11
|
-
* [
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
* [Usage](#usage)
|
10
|
+
* [Load credentials](#load-credentials)
|
11
|
+
* [Manage form data](#manage-form-data)
|
12
|
+
* [Set form data](#set-form-data)
|
13
|
+
* [Submit data](#submit-data)
|
14
|
+
* [Response](#response)
|
15
|
+
* [Rollback and error reporting](#rollback-and-error-reporting)
|
16
|
+
* [Logging](#logging)
|
15
17
|
|
16
18
|
## Scope
|
17
|
-
This gem is a Ruby porting of the XPay client library used by the [Dacom
|
19
|
+
This gem is a Ruby porting of the XPay client library used by the [LGU+ (former Dacom)](http://lgdacom.net/) payment gateway used in Korea.
|
18
20
|
|
19
|
-
##
|
20
|
-
The
|
21
|
-
payment process with
|
21
|
+
## Workflow
|
22
|
+
The LGU+ XPay client is used to generate some unique keys mandatory to complete the
|
23
|
+
payment process with LGU+.
|
22
24
|
|
23
25
|
### Client script
|
24
|
-
The payment
|
25
|
-
|
26
|
+
The payment workflow happens on LGU+ servers by including the following JavaScript:
|
27
|
+
into your checkout page:
|
28
|
+
```
|
29
|
+
https://xpay.lgdacom.net/xpay/js/xpay_crossplatform.js
|
30
|
+
```
|
31
|
+
|
32
|
+
The script is responsible to:
|
33
|
+
* reads the data generated by the ruby library and set some hidden fields present on the checkout page
|
26
34
|
* set the form action
|
27
|
-
* open an iframe
|
28
|
-
* submit the
|
35
|
+
* open an iframe window pointing to the LGU+ server
|
36
|
+
* submit the form with parameters collected by LGU+ upon iframe closure
|
37
|
+
|
38
|
+
The official documentation is kind of private unless you have a valid LGU+ account, by checking the JavaScript source you should figure out how it works ;)
|
29
39
|
|
30
40
|
### Collecting data
|
31
|
-
|
32
|
-
These data has to be send via the Ruby XPay client and the response of the service has to be collected by Site.
|
41
|
+
The data submitted by form need to be processed by the Ruby client and the response of the service has to be collected by Site.
|
33
42
|
|
34
|
-
##
|
35
|
-
|
36
|
-
|
43
|
+
## Installation
|
44
|
+
Add this line to your application's Gemfile:
|
45
|
+
```ruby
|
46
|
+
gem "dacom"
|
47
|
+
```
|
37
48
|
|
49
|
+
And then execute:
|
50
|
+
```shell
|
51
|
+
bundle
|
52
|
+
```
|
53
|
+
|
54
|
+
Or install it yourself as:
|
55
|
+
```shell
|
56
|
+
gem install dacom
|
57
|
+
```
|
38
58
|
### Configuration
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
###
|
68
|
-
|
59
|
+
This library assumes you have valid LGU+ credentials inside yaml file like that:
|
60
|
+
```yaml
|
61
|
+
url: "https://xpayclient.lgdacom.net/xpay/Gateway.do"
|
62
|
+
test_url: "https://xpayclient.lgdacom.net:7443/xpay/Gateway.do"
|
63
|
+
aux_url: "http://xpay.lgdacom.net:7080/xpay/Gateway.do"
|
64
|
+
server_id: "01"
|
65
|
+
timeout: 60
|
66
|
+
verify_cert: true
|
67
|
+
verify_host: true
|
68
|
+
report_error: true
|
69
|
+
auto_rollback: true
|
70
|
+
mert_id: "lgdacomxpay"
|
71
|
+
mert_key: "<your-key>"
|
72
|
+
test_mert_id: "tlgdacomxpay"
|
73
|
+
test_mert_key: "<your_merchant_id>"
|
74
|
+
test_mode: true
|
75
|
+
```
|
76
|
+
|
77
|
+
## Usage
|
78
|
+
|
79
|
+
### Load credentials
|
80
|
+
The `Config` class is responsible to load the LGU+ credentials contained into the yaml file:
|
81
|
+
```ruby
|
82
|
+
require "dacom"
|
83
|
+
|
84
|
+
config = Dacom::Config.new("./dacom.yml") # default to "~/dacom.yml"
|
85
|
+
```
|
86
|
+
|
87
|
+
### Manage form data
|
88
|
+
Once you've collected the form data from the iframe, you need to send them back to LGU+ to complete the purchasing.
|
89
|
+
The `Client` class is responsible to sign the form data with valid authorization codes and communicate them to LGU+:
|
90
|
+
```ruby
|
91
|
+
client = Dacom::Client.new(config: config)
|
92
|
+
```
|
93
|
+
|
94
|
+
#### Set form data
|
95
|
+
In order to fill the client form data with the ones collected by the iframe, you can use the `#set` method:
|
96
|
+
```ruby
|
97
|
+
client.set("LGD_TXNAME", "PaymentByKey")
|
98
|
+
client.set("LGD_AMOUNT", <order_grand_total>)
|
99
|
+
client.set("LGD_AMOUNTCHECKYN", "Y")
|
100
|
+
|
101
|
+
# these data are collected by form hidden fields filled by LGU+ iframe
|
102
|
+
client.set("LGD_PAYKEY", params["LGD_PAYKEY"])
|
103
|
+
client.set("LGD_PAYTYPE", params["LGD_PAYTYPE"])
|
104
|
+
client.set("LGD_FINANCENAME", params["LGD_FINANCENAME"])
|
105
|
+
client.set("LGD_FINANCECODE", params["LGD_FINANCECODE"])
|
106
|
+
client.set("LGD_ACCOUNTOWNER", params["LGD_ACCOUNTOWNER"])
|
107
|
+
```
|
108
|
+
|
109
|
+
#### Submit data
|
110
|
+
Once the form data are set you're ready to communicate them back to LGU+ along with the authorization data:
|
111
|
+
```ruby
|
112
|
+
res = client.tx
|
113
|
+
|
114
|
+
# check response code
|
115
|
+
if res.successful?
|
116
|
+
# process order
|
117
|
+
else
|
118
|
+
# present error page
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
122
|
+
The `tx` method also accept a block yielding request and response objects before any face-lifting:
|
123
|
+
```ruby
|
124
|
+
client.tx do |req, res|
|
125
|
+
p req.body # inspecting the raw body
|
126
|
+
p res # inspecting raw response form LGU+
|
127
|
+
end
|
128
|
+
```
|
129
|
+
|
130
|
+
#### Response
|
131
|
+
The `Response` object is a struct that contains parsed JSON data from LGU+, use it to provide feedback on success/failure:
|
132
|
+
```ruby
|
133
|
+
puts res
|
134
|
+
# "<Dacom::Response:70132949609560, code: \"XC01\", message: \"LGD_TXNAME 필드가 누락되었습니다.\", successful: false>"
|
135
|
+
|
136
|
+
p res.raw # check raw response
|
137
|
+
p res.code # check response LGU+ code (check constants.rb file)
|
138
|
+
p res.message# check message by LGU+ (in KR)
|
139
|
+
```
|
140
|
+
|
141
|
+
#### Rollback and error reporting
|
142
|
+
In case of payment issues the `Client` is responsible to communicate to LGU+ a rollback procedure and to report any error.
|
143
|
+
These options are configurable by yaml values:
|
144
|
+
```yaml
|
145
|
+
report_error: true # set to false to avoid reporting on failure
|
146
|
+
auto_rollback: true # set to false to avoid sending a rollback procedure
|
147
|
+
```
|
148
|
+
|
149
|
+
### Logging
|
150
|
+
By default the `Client` class accepts a logger pointing to `dev/null`.
|
151
|
+
In case you want to replace it with yours, just pass it to the constructor:
|
152
|
+
```ruby
|
153
|
+
my_logger = Logger.new(STDOUT)
|
154
|
+
my_logger.log_level = Logger::WARN
|
155
|
+
client = Dacom::Client.new(config: config, logger: my_logger)
|
156
|
+
```
|
data/dacom.gemspec
CHANGED
@@ -8,19 +8,16 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = Dacom::VERSION
|
9
9
|
s.authors = ["costajob"]
|
10
10
|
s.email = ["costajob@gmail.com"]
|
11
|
-
s.summary =
|
11
|
+
s.summary = "A Ruby port of the Dacom/LGU+ payment library for Korea."
|
12
12
|
s.homepage = "https://github.com/costajob/dacom"
|
13
|
-
s.license = "MIT"
|
14
|
-
s.required_ruby_version = ">= 1.8.7"
|
15
|
-
|
16
13
|
s.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
-
s.bindir = "
|
18
|
-
s.executables =
|
14
|
+
s.bindir = "bin"
|
15
|
+
s.executables = %w[]
|
19
16
|
s.require_paths = ["lib"]
|
17
|
+
s.license = "MIT"
|
18
|
+
s.required_ruby_version = ">= 2.2.2"
|
20
19
|
|
21
|
-
s.
|
22
|
-
s.add_development_dependency "bundler", "~> 1.11"
|
20
|
+
s.add_development_dependency "bundler", "~> 1.15"
|
23
21
|
s.add_development_dependency "rake", "~> 10.0"
|
24
22
|
s.add_development_dependency "minitest", "~> 5.0"
|
25
|
-
s.add_development_dependency "rr", "~> 1.2"
|
26
23
|
end
|
data/lib/dacom/client.rb
CHANGED
@@ -1,42 +1,43 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
6
|
-
require
|
7
|
-
require
|
8
|
-
require
|
1
|
+
require "forwardable"
|
2
|
+
require "json"
|
3
|
+
require "logger"
|
4
|
+
require "net/https"
|
5
|
+
require "openssl"
|
6
|
+
require "securerandom"
|
7
|
+
require "dacom/config"
|
8
|
+
require "dacom/constants"
|
9
|
+
require "dacom/response"
|
9
10
|
|
10
11
|
module Dacom
|
11
12
|
class Client
|
13
|
+
extend Forwardable
|
12
14
|
include Constants
|
13
15
|
|
14
|
-
LOGGER_PATH = File::expand_path("../../../log/dacom.log", __FILE__)
|
15
|
-
|
16
16
|
class ResponseError < StandardError; end
|
17
17
|
class HTTPCodeError < StandardError; end
|
18
18
|
|
19
|
-
|
19
|
+
def_delegators :@config, :server_id, :merchant_id, :merchant_key, :verify_peer?
|
20
|
+
|
21
|
+
attr_reader :http, :response, :reported, :rolled_back
|
20
22
|
|
21
|
-
def initialize(
|
22
|
-
@config =
|
23
|
-
@
|
24
|
-
@
|
25
|
-
@
|
23
|
+
def initialize(config: Config.new, net_klass: Net::HTTP, res_klass: Response, logger: Logger.new(nil), time: Time.now, uuid: SecureRandom.uuid)
|
24
|
+
@config = config
|
25
|
+
@net_klass = net_klass
|
26
|
+
@res_klass = res_klass
|
27
|
+
@logger = logger
|
28
|
+
@time = time
|
29
|
+
@uuid = uuid
|
26
30
|
@auto_rollback = @config.auto_rollback
|
27
31
|
@report_error = @config.report_error
|
28
32
|
@endpoint = @config.url
|
29
|
-
@tx_id = gen_tx_id
|
30
|
-
@auth_code = gen_auth_code
|
31
|
-
@form_data = init_form_data
|
32
33
|
end
|
33
34
|
|
34
|
-
def tx
|
35
|
-
json = do_request
|
35
|
+
def tx(&b)
|
36
|
+
json = Thread.new { do_request(&b) }.value
|
36
37
|
data = parse_response(json)
|
37
|
-
@response =
|
38
|
-
|
39
|
-
|
38
|
+
@response = @res_klass.new(data).tap do |res|
|
39
|
+
@logger.info("RESPONSE: #{res}")
|
40
|
+
end
|
40
41
|
rescue ResponseError => e
|
41
42
|
@logger.error("rescue from ResponseError - #{e.message} \n #{e.backtrace.join("\n")}")
|
42
43
|
rollback
|
@@ -45,74 +46,73 @@ module Dacom
|
|
45
46
|
end
|
46
47
|
|
47
48
|
def set(k, v)
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def rollback
|
54
|
-
return unless @auto_rollback
|
55
|
-
rollback_client = RollbackClient::new(:config => @config,
|
56
|
-
:parent_id => @tx_id,
|
57
|
-
:reason => rollback_reason)
|
58
|
-
Thread::new { rollback_client.tx }
|
49
|
+
form_data[k] = v
|
59
50
|
end
|
60
51
|
|
61
|
-
def
|
62
|
-
|
63
|
-
report_client = ReportClient::new(:config => @config,
|
64
|
-
:status => @response.code,
|
65
|
-
:message => @response.message)
|
66
|
-
Thread::new { report_client.tx }
|
67
|
-
end
|
68
|
-
|
69
|
-
def parse_response(json)
|
70
|
-
JSON::parse(json)
|
71
|
-
rescue JSON::ParserError => e
|
72
|
-
set_response_and_raise(LGD_ERR_JSON_DECODE, e)
|
52
|
+
def form_data
|
53
|
+
@form_data ||= { "LGD_TXID" => tx_id, "LGD_AUTHCODE" => auth_code, "LGD_MID" => merchant_id }
|
73
54
|
end
|
74
55
|
|
75
|
-
def
|
76
|
-
|
56
|
+
private def tx_id
|
57
|
+
@tx_id ||= begin
|
58
|
+
sha = OpenSSL::Digest::SHA1.new
|
59
|
+
sha.update(@uuid)
|
60
|
+
"#{tx_header}#{sha}"
|
61
|
+
end
|
77
62
|
end
|
78
63
|
|
79
|
-
def
|
64
|
+
private def auth_code
|
80
65
|
sha = OpenSSL::Digest::SHA1.new
|
81
|
-
sha.update(
|
82
|
-
"#{tx_header}#{sha}"
|
66
|
+
sha.update("#{tx_id}#{merchant_key}").to_s
|
83
67
|
end
|
84
68
|
|
85
|
-
def
|
86
|
-
|
87
|
-
sha.update("#{@tx_id}#{@mert_key}").to_s
|
69
|
+
private def tx_header
|
70
|
+
"#{merchant_id}-#{server_id}#{timestamp}"
|
88
71
|
end
|
89
72
|
|
90
|
-
def
|
91
|
-
|
73
|
+
private def timestamp
|
74
|
+
@time.utc.strftime("%Y%m%d%H%M%S")
|
92
75
|
end
|
93
76
|
|
94
|
-
def
|
95
|
-
|
77
|
+
private def rollback
|
78
|
+
return unless @auto_rollback
|
79
|
+
RollbackClient.new(config: @config,
|
80
|
+
logger: @logger,
|
81
|
+
net_klass: @net_klass,
|
82
|
+
res_klass: @res_klass,
|
83
|
+
parent_id: tx_id,
|
84
|
+
reason: rollback_reason).tx
|
85
|
+
@rolled_back = true
|
96
86
|
end
|
97
87
|
|
98
|
-
def
|
99
|
-
|
88
|
+
private def report
|
89
|
+
return unless @report_error
|
90
|
+
ReportClient.new(config: @config,
|
91
|
+
logger: @logger,
|
92
|
+
net_klass: @net_klass,
|
93
|
+
res_klass: @res_klass,
|
94
|
+
status: @response.code,
|
95
|
+
message: @response.message).tx
|
96
|
+
@reported = true
|
100
97
|
end
|
101
98
|
|
102
|
-
def
|
103
|
-
|
99
|
+
private def parse_response(json)
|
100
|
+
JSON.parse(json)
|
101
|
+
rescue JSON::ParserError => e
|
102
|
+
set_response_and_raise(LGD_ERR_JSON_DECODE, e)
|
104
103
|
end
|
105
104
|
|
106
|
-
def rollback_reason
|
105
|
+
private def rollback_reason
|
107
106
|
return "Timeout" if @response.code == LGD_ERR_TIMEDOUT
|
108
|
-
return "HTTP #{@http_code}" if
|
107
|
+
return "HTTP #{@http_code}" if http_code_error?
|
109
108
|
@response.message
|
110
109
|
end
|
111
|
-
|
112
|
-
def do_request
|
113
|
-
req, http = prepare_http_client
|
114
|
-
@logger.info("
|
110
|
+
|
111
|
+
private def do_request
|
112
|
+
req, @http = prepare_http_client
|
113
|
+
@logger.info("REQUEST: endpoint=#{@endpoint}; form_data=#{form_data.inspect}")
|
115
114
|
res = http.request(req)
|
115
|
+
yield(req, res) if block_given?
|
116
116
|
set_http_code(res.code)
|
117
117
|
res.body
|
118
118
|
rescue Timeout::Error => e
|
@@ -127,71 +127,72 @@ module Dacom
|
|
127
127
|
set_response_and_raise(LGD_ERR_CONNECT, e)
|
128
128
|
end
|
129
129
|
|
130
|
-
def
|
131
|
-
@response = Response::new(:code => code, :message => e.message)
|
132
|
-
@logger.info("response: #{@response}")
|
133
|
-
@logger.error("rescue from #{e.class} - #{e.message} \n #{e.backtrace.join("\n")}")
|
134
|
-
raise ResponseError, e.message
|
135
|
-
end
|
136
|
-
|
137
|
-
def prepare_http_client
|
130
|
+
private def prepare_http_client
|
138
131
|
url = URI.parse(@endpoint)
|
139
|
-
req =
|
132
|
+
req = @net_klass.const_get("Post").new(url.path)
|
140
133
|
req["User-Agent"] = LGD_USER_AGENT
|
141
|
-
req.set_form_data(
|
142
|
-
http =
|
143
|
-
http.open_timeout =
|
134
|
+
req.set_form_data(form_data)
|
135
|
+
http = @net_klass.new(url.host, url.port)
|
136
|
+
http.open_timeout = @config.timeout
|
137
|
+
http.read_timeout = @config.timeout
|
144
138
|
if url.scheme == "https"
|
145
139
|
http.use_ssl = true
|
146
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_PEER if
|
140
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER if verify_peer?
|
147
141
|
end
|
148
142
|
[req, http]
|
149
143
|
end
|
150
144
|
|
151
|
-
def set_http_code(code)
|
145
|
+
private def set_http_code(code)
|
152
146
|
@http_code = code.to_i
|
153
147
|
fail HTTPCodeError, "invalid HTTP code #{code}" unless http_code_valid?
|
154
148
|
end
|
155
149
|
|
156
|
-
def http_code_valid?
|
157
|
-
(200...300) === @http_code
|
150
|
+
private def http_code_valid?
|
151
|
+
(200...300) === @http_code.to_i
|
152
|
+
end
|
153
|
+
|
154
|
+
private def http_code_error?
|
155
|
+
(500...599) === @http_code.to_i
|
156
|
+
end
|
157
|
+
|
158
|
+
private def set_response_and_raise(code, e)
|
159
|
+
@response = @res_klass.new(code: code, message: e.message)
|
160
|
+
@logger.info("RESPONSE: #{@response}")
|
161
|
+
@logger.error("rescue from #{e.class} - #{e.message} \n #{e.backtrace.join("\n")}")
|
162
|
+
raise ResponseError, e.message
|
158
163
|
end
|
159
164
|
end
|
160
165
|
|
161
166
|
class EventClient < Client
|
162
|
-
def initialize(
|
163
|
-
super(
|
167
|
+
def initialize(config:, logger: Logger.new(nil), net_klass:, res_klass:)
|
168
|
+
super(config: config, logger: logger, net_klass: net_klass, res_klass: res_klass)
|
164
169
|
@auto_rollback = false
|
165
170
|
@report_error = false
|
166
171
|
end
|
167
172
|
end
|
168
173
|
|
169
174
|
class RollbackClient < EventClient
|
170
|
-
def initialize(
|
171
|
-
|
172
|
-
@
|
173
|
-
|
175
|
+
def initialize(config:, logger: Logger.new(nil), net_klass:, res_klass:, parent_id:, reason:)
|
176
|
+
super(config: config, logger: logger, net_klass: net_klass, res_klass: res_klass)
|
177
|
+
@parent_id = parent_id
|
178
|
+
@reason = reason
|
174
179
|
end
|
175
180
|
|
176
|
-
|
177
|
-
|
178
|
-
def init_form_data
|
179
|
-
super.merge({ "LGD_TXID" => @parent_id, "LGD_TXNAME" => "Rollback", "LGD_RB_TXID" => @tx_id, "LGD_RB_REASON" => @reason })
|
181
|
+
def form_data
|
182
|
+
@form_data ||= super.merge({ "LGD_TXID" => @parent_id, "LGD_TXNAME" => "Rollback", "LGD_RB_TXID" => tx_id, "LGD_RB_REASON" => @reason })
|
180
183
|
end
|
181
184
|
end
|
182
185
|
|
183
186
|
class ReportClient < EventClient
|
184
|
-
def initialize(
|
185
|
-
|
186
|
-
@
|
187
|
-
|
187
|
+
def initialize(config:, logger: Logger.new(nil), net_klass:, res_klass:, status:, message:)
|
188
|
+
super(config: config, logger: logger, net_klass: net_klass, res_klass: res_klass)
|
189
|
+
@status = status
|
190
|
+
@message = message
|
188
191
|
@endpoint = @config.aux_url
|
189
192
|
end
|
190
193
|
|
191
|
-
|
192
|
-
|
193
|
-
def init_form_data
|
194
|
-
super.merge({ "LGD_TXNAME" => "Report", "LGD_STATUS" => @status, "LGD_MSG" => @message })
|
194
|
+
def form_data
|
195
|
+
@form_data ||= super.merge({ "LGD_TXNAME" => "Report", "LGD_STATUS" => @status, "LGD_MSG" => @message })
|
195
196
|
end
|
196
197
|
end
|
197
198
|
end
|
data/lib/dacom/config.rb
CHANGED
@@ -1,12 +1,16 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "erb"
|
2
|
+
require "yaml"
|
3
3
|
|
4
4
|
module Dacom
|
5
5
|
class Config
|
6
|
-
|
6
|
+
module Platform
|
7
|
+
%w[test service].each do |platform|
|
8
|
+
Platform.const_set(platform.upcase, platform)
|
9
|
+
end
|
10
|
+
end
|
7
11
|
|
8
|
-
def initialize(path =
|
9
|
-
@path = path
|
12
|
+
def initialize(path = "~/dacom.yml")
|
13
|
+
@path = File.expand_path(path)
|
10
14
|
@config = fetch_config
|
11
15
|
end
|
12
16
|
|
@@ -32,8 +36,8 @@ module Dacom
|
|
32
36
|
end
|
33
37
|
|
34
38
|
def platform
|
35
|
-
return
|
36
|
-
|
39
|
+
return Platform::TEST if test_mode?
|
40
|
+
Platform::SERVICE
|
37
41
|
end
|
38
42
|
|
39
43
|
def verify_peer?
|
@@ -43,7 +47,7 @@ module Dacom
|
|
43
47
|
private
|
44
48
|
|
45
49
|
def test_mode?
|
46
|
-
@config
|
50
|
+
@config["test_mode"]
|
47
51
|
end
|
48
52
|
|
49
53
|
def fetch_config
|
data/lib/dacom/constants.rb
CHANGED
data/lib/dacom/response.rb
CHANGED
data/lib/dacom/version.rb
CHANGED
metadata
CHANGED
@@ -1,43 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dacom
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- costajob
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
-
- !ruby/object:Gem::Dependency
|
14
|
-
name: json
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.8'
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - "~>"
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: '1.8'
|
27
13
|
- !ruby/object:Gem::Dependency
|
28
14
|
name: bundler
|
29
15
|
requirement: !ruby/object:Gem::Requirement
|
30
16
|
requirements:
|
31
17
|
- - "~>"
|
32
18
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1.
|
19
|
+
version: '1.15'
|
34
20
|
type: :development
|
35
21
|
prerelease: false
|
36
22
|
version_requirements: !ruby/object:Gem::Requirement
|
37
23
|
requirements:
|
38
24
|
- - "~>"
|
39
25
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1.
|
26
|
+
version: '1.15'
|
41
27
|
- !ruby/object:Gem::Dependency
|
42
28
|
name: rake
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,20 +52,6 @@ dependencies:
|
|
66
52
|
- - "~>"
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '5.0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rr
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - "~>"
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '1.2'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - "~>"
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '1.2'
|
83
55
|
description:
|
84
56
|
email:
|
85
57
|
- costajob@gmail.com
|
@@ -89,14 +61,12 @@ extra_rdoc_files: []
|
|
89
61
|
files:
|
90
62
|
- ".gitignore"
|
91
63
|
- ".travis.yml"
|
92
|
-
- CODE_OF_CONDUCT.md
|
93
64
|
- Gemfile
|
94
65
|
- LICENSE.txt
|
95
66
|
- README.md
|
96
67
|
- Rakefile
|
97
68
|
- bin/console
|
98
69
|
- bin/setup
|
99
|
-
- config/dacom.yml
|
100
70
|
- dacom.gemspec
|
101
71
|
- lib/dacom.rb
|
102
72
|
- lib/dacom/client.rb
|
@@ -117,7 +87,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
117
87
|
requirements:
|
118
88
|
- - ">="
|
119
89
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
90
|
+
version: 2.2.2
|
121
91
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
122
92
|
requirements:
|
123
93
|
- - ">="
|
@@ -125,8 +95,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
125
95
|
version: '0'
|
126
96
|
requirements: []
|
127
97
|
rubyforge_project:
|
128
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.6.8
|
129
99
|
signing_key:
|
130
100
|
specification_version: 4
|
131
|
-
summary: A Ruby port of the Dacom
|
101
|
+
summary: A Ruby port of the Dacom/LGU+ payment library for Korea.
|
132
102
|
test_files: []
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# Contributor Code of Conduct
|
2
|
-
|
3
|
-
As contributors and maintainers of this project, and in the interest of
|
4
|
-
fostering an open and welcoming community, we pledge to respect all people who
|
5
|
-
contribute through reporting issues, posting feature requests, updating
|
6
|
-
documentation, submitting pull requests or patches, and other activities.
|
7
|
-
|
8
|
-
We are committed to making participation in this project a harassment-free
|
9
|
-
experience for everyone, regardless of level of experience, gender, gender
|
10
|
-
identity and expression, sexual orientation, disability, personal appearance,
|
11
|
-
body size, race, ethnicity, age, religion, or nationality.
|
12
|
-
|
13
|
-
Examples of unacceptable behavior by participants include:
|
14
|
-
|
15
|
-
* The use of sexualized language or imagery
|
16
|
-
* Personal attacks
|
17
|
-
* Trolling or insulting/derogatory comments
|
18
|
-
* Public or private harassment
|
19
|
-
* Publishing other's private information, such as physical or electronic
|
20
|
-
addresses, without explicit permission
|
21
|
-
* Other unethical or unprofessional conduct
|
22
|
-
|
23
|
-
Project maintainers have the right and responsibility to remove, edit, or
|
24
|
-
reject comments, commits, code, wiki edits, issues, and other contributions
|
25
|
-
that are not aligned to this Code of Conduct, or to ban temporarily or
|
26
|
-
permanently any contributor for other behaviors that they deem inappropriate,
|
27
|
-
threatening, offensive, or harmful.
|
28
|
-
|
29
|
-
By adopting this Code of Conduct, project maintainers commit themselves to
|
30
|
-
fairly and consistently applying these principles to every aspect of managing
|
31
|
-
this project. Project maintainers who do not follow or enforce the Code of
|
32
|
-
Conduct may be permanently removed from the project team.
|
33
|
-
|
34
|
-
This code of conduct applies both within project spaces and in public spaces
|
35
|
-
when an individual is representing the project or its community.
|
36
|
-
|
37
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
38
|
-
reported by contacting a project maintainer at costajob@gmail.com. All
|
39
|
-
complaints will be reviewed and investigated and will result in a response that
|
40
|
-
is deemed necessary and appropriate to the circumstances. Maintainers are
|
41
|
-
obligated to maintain confidentiality with regard to the reporter of an
|
42
|
-
incident.
|
43
|
-
|
44
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
45
|
-
version 1.3.0, available at
|
46
|
-
[http://contributor-covenant.org/version/1/3/0/][version]
|
47
|
-
|
48
|
-
[homepage]: http://contributor-covenant.org
|
49
|
-
[version]: http://contributor-covenant.org/version/1/3/0/
|
data/config/dacom.yml
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
url: "https://xpayclient.lgdacom.net/xpay/Gateway.do"
|
2
|
-
test_url: "https://xpayclient.lgdacom.net:7443/xpay/Gateway.do"
|
3
|
-
aux_url: "http://xpay.lgdacom.net:7080/xpay/Gateway.do"
|
4
|
-
server_id: <%= ENV.fetch("SERVER_ID") { "01" } %>
|
5
|
-
timeout: 60
|
6
|
-
verify_cert: false
|
7
|
-
verify_host: false
|
8
|
-
report_error: true
|
9
|
-
auto_rollback: true
|
10
|
-
mert_id: "lgdacomxpay"
|
11
|
-
mert_key: <%= ENV.fetch("MERT_KEY") { "live_key" } %>
|
12
|
-
test_mert_id: "tlgdacomxpay"
|
13
|
-
test_mert_key: <%= ENV.fetch("TEST_MERT_KEY") { "test_key" } %>
|
14
|
-
test_mode: true
|