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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 255d7316fe101cf1f6e94a0dc64ae9744d60da29
4
- data.tar.gz: bf05adf92a000bb60ede19664adb4a42756013ea
3
+ metadata.gz: 9716615797e94128f11211d26b17d51dfc551c14
4
+ data.tar.gz: f1a6a1621bbd618394587cb782008fc859f03d6f
5
5
  SHA512:
6
- metadata.gz: 5cd4d8d703e0386516128debf08c01a2989b6f2c33e59e8a112ff29ed4dbca445b3de6319a84c1b8e4740d9db45363e56d036f5d7d079a3d58afebf1d999b1dd
7
- data.tar.gz: 544fe3578700c09956979278d6459f06e4815ac53cb2aaf87566b0f8508c61dee4b691d0198235d5822ac7438afb0b775bc30dd496adbc8f86b29de736008d08
6
+ metadata.gz: fcedf1d7851b176e524a602ba195cdcda84b7245681e04119e53c87d56d6d7c8752320458fbae66f074f5140fecd39a853461eb1a5e55c4750793800e30238a5
7
+ data.tar.gz: 84f60df6a9a5b8992a59bd7709dd16531baa9f33935882aab07040d30e1d733ff110817cb60fea5927ca5bdd3b505466200e90921ef19ae331ff1edc20e47189
@@ -1,10 +1,6 @@
1
1
  language: ruby
2
2
  rvm:
3
- - 1.8.7
4
- - 1.9.2
5
- - 1.9.3
6
- - 2.0.0
7
- - 2.1.8
8
- - 2.2.1
3
+ - 2.2.2
9
4
  - 2.3.0
5
+ - 2.4.0
10
6
  before_install: gem install bundler -v 1.11.2
data/README.md CHANGED
@@ -1,68 +1,156 @@
1
1
  ## Table of Contents
2
2
 
3
3
  * [Scope](#scope)
4
- * [Payment process](#payment-process)
4
+ * [Workflow](#workflow)
5
5
  * [Client script](#client-script)
6
6
  * [Collecting data](#collecting-data)
7
- * [API](#api)
7
+ * [Installation](#installation)
8
8
  * [Configuration](#configuration)
9
- * [Constructor](#constructor)
10
- * [Response](#Response)
11
- * [Catch all](#catch-all)
12
- * [Constants](#constants)
13
- * [Rollback](#rollback)
14
- * [Report](#report)
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 LGD](http://lgdacom.net/) payment gateway for Korea.
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
- ## Payment process
20
- The LGD XPay client is used to generate some unique keys mandatory to complete the
21
- payment process with LGD.
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 work flow happens on LGD servers by including a [JavaScript](https://xpay.lgdacom.net/xpay/js/xpay_crossplatform.js) in the page that:
25
- * reads the data generated by the ruby library and set some hidden fields of a form
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 windows pointing to the LGD platform
28
- * submit the forms with parameters collected by the iframe
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
- Once the payment is completed, the iframe is closed and some data retruned to the parent site.
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
- ## API
35
- The API of the client is pretty small. The library expose one single public method, called *tx*, used to communicate the data to LGD server.
36
- The data are collected by using a hash object, then submitted as the form-data attribute.
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
- Some configuration, such as the merchant key, id and other options, are fetched by a YML file.
40
- Some configuration keys are available for the test environment too.
41
-
42
- ### Constructor
43
- Several instance variables are instantiated at construction time:
44
- * the data fetched by the configuration collaborator
45
- * the hashed keys created by using the SHA1 digest
46
- * the hash object used to set the request form data
47
-
48
- ### Response
49
- A response object collaborator is used and always returned by the library.
50
- The data of the response are collected by parsing the JSON returned by LGD or by
51
- rescuing from an error.
52
- The object is always filled with a code and a message attributes.
53
-
54
- ### Catch all
55
- The library does not halt on exceptions, but on the higher ones (aka system failure).
56
- This design is used to allow returning meaningful responses basing on the kind of errors raised (JSON parse, timeout, SSL error, etc).
57
- All exceptions are wrapped by a general one, then rescued by the *tx* method.
58
- I know using exceptions as control flow is not terrific, but i tried to mimic as much as possible the original behaviour of the PHP/Java versions.
59
- To mitigate i log every error on a custom collaborator.
60
-
61
- ### Constants
62
- A set of constants are defined by an external module. They identifies the error codes to be used in case of exceptions and are set on the response object.
63
-
64
- ### Rollback
65
- In case of issues the library notifies LGD with a rollback request. The object subclass the Client one, since it needs to initialize the same hash keys.
66
-
67
- ### Report
68
- The same approach is used to report LGD about the failure. Both communications happens inside a separate thread of execution to have less impact on the system.
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
+ ```
@@ -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 = %q{A Ruby port of the Dacom (LGU+) XPay client library}
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 = "exe"
18
- s.executables = s.files.grep(%r{^exe/}) { |f| File.basename(f) }
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.add_runtime_dependency "json", "~> 1.8"
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
@@ -1,42 +1,43 @@
1
- require 'net/https'
2
- require 'uri'
3
- require 'openssl'
4
- require 'json'
5
- require 'logger'
6
- require 'dacom/config'
7
- require 'dacom/constants'
8
- require 'dacom/response'
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
- attr_reader :response, :form_data
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(options = {})
22
- @config = options.fetch(:config) { Config::new }
23
- @logger = options.fetch(:logger) { Logger::new(LOGGER_PATH) }
24
- @mid = @config.merchant_id
25
- @mert_key = @config.merchant_key
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 = Response::new(data)
38
- @logger.info("response: #{@response}")
39
- @response
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
- @form_data[k] = v
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 report
62
- return unless @report_error
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 init_form_data
76
- { "LGD_TXID" => @tx_id, "LGD_AUTHCODE" => @auth_code, "LGD_MID" => @mid }
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 gen_tx_id
64
+ private def auth_code
80
65
  sha = OpenSSL::Digest::SHA1.new
81
- sha.update(get_unique)
82
- "#{tx_header}#{sha}"
66
+ sha.update("#{tx_id}#{merchant_key}").to_s
83
67
  end
84
68
 
85
- def gen_auth_code
86
- sha = OpenSSL::Digest::SHA1.new
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 tx_header
91
- "#{@mid}-#{@config.server_id}#{timestamp}"
73
+ private def timestamp
74
+ @time.utc.strftime("%Y%m%d%H%M%S")
92
75
  end
93
76
 
94
- def get_unique
95
- "#{timestamp}#{rand_three_digits}"
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 rand_three_digits
99
- "%03d" % rand(1000)
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 timestamp
103
- Time.now.getutc.strftime("%Y%m%d%H%M%S")
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 (500...599) === @http_code.to_i
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("request: #{@endpoint} - #{@form_data.inspect}")
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 set_response_and_raise(code, e)
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 = Net::HTTP::Post.new(url.path)
132
+ req = @net_klass.const_get("Post").new(url.path)
140
133
  req["User-Agent"] = LGD_USER_AGENT
141
- req.set_form_data(@form_data)
142
- http = Net::HTTP.new(url.host, url.port)
143
- http.open_timeout = http.read_timeout = @config.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 @config.verify_peer?
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(options = {})
163
- super(options)
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(options = {})
171
- @parent_id = options.fetch(:parent_id) { fail ArgumentError, "missing parent ID" }
172
- @reason = options.fetch(:reason) { fail ArgumentError, "missing parent reason" }
173
- super(options)
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
- private
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(options = {})
185
- @status = options.fetch(:status) { fail ArgumentError, "missing status" }
186
- @message = options.fetch(:message) { fail ArgumentError, "missing message" }
187
- super(options)
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
- private
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
@@ -1,12 +1,16 @@
1
- require 'yaml'
2
- require 'erb'
1
+ require "erb"
2
+ require "yaml"
3
3
 
4
4
  module Dacom
5
5
  class Config
6
- CONFIG_PATH = File::expand_path("../../../config/dacom.yml", __FILE__)
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 = CONFIG_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 "test".freeze if test_mode?
36
- "service".freeze
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.fetch("test_mode") { false }
50
+ @config["test_mode"]
47
51
  end
48
52
 
49
53
  def fetch_config
@@ -32,7 +32,7 @@ module Dacom
32
32
 
33
33
  def included(klass)
34
34
  all.each do |k,v|
35
- klass::const_set(k.upcase, v.freeze)
35
+ klass::const_set(k.upcase, v)
36
36
  end
37
37
  end
38
38
  end
@@ -1,8 +1,8 @@
1
1
  module Dacom
2
2
  class Response
3
- attr_reader :code, :message, :raw
3
+ SUCCESS_CODE = "0000"
4
4
 
5
- SUCCESS_CODE = "0000".freeze
5
+ attr_reader :code, :message, :raw
6
6
 
7
7
  def initialize(data = {})
8
8
  @code = data.fetch("LGD_RESPCODE") { data[:code] }
@@ -1,3 +1,3 @@
1
1
  module Dacom
2
- VERSION = "1.0.1"
2
+ VERSION = "2.0.0"
3
3
  end
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: 1.0.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - costajob
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-22 00:00:00.000000000 Z
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.11'
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.11'
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: 1.8.7
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.5.1
98
+ rubygems_version: 2.6.8
129
99
  signing_key:
130
100
  specification_version: 4
131
- summary: A Ruby port of the Dacom (LGU+) XPay client library
101
+ summary: A Ruby port of the Dacom/LGU+ payment library for Korea.
132
102
  test_files: []
@@ -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/
@@ -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