comgate_ruby 0.8.0 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +10 -1
- data/lib/comgate/api_caller.rb +19 -3
- data/lib/comgate/gateway.rb +5 -1
- data/lib/comgate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d020da6b1614a32495b473b497b9931406275e575a5be5012b70c46313a60041
|
4
|
+
data.tar.gz: ff070de8de6f549aaf6482c3a00f07cf7d496e683a6829cbdca7a40854ee8049
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cde1b8d7a8b37148cfa1af8afd799ca9858b565f52a34d265651233ac49a5dd90879ebc2c602097ed654aa1c79ae4cc764b08af0bda7a2047f9a7e3943a6d16d
|
7
|
+
data.tar.gz: 56490bc816c7e2a5afa3b9ca30d36d4603ae388853d157d078b43ffe1e42376e627541e4b8e4b95eb9edccb0d00c96e2304486365f1d286dd7dbbbb01fbab973
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [0.8.2] - 2023-06-20
|
2
|
+
- If ENV["COMGATE_MIN_LOG_LEVEL"] is set, calls and responses to Comgate are logged at that level. Otherwise `:debug` is used.
|
3
|
+
|
4
|
+
## [0.8.1] - 2023-06-13
|
5
|
+
- Allowed `proxy_uri` param for Comgate::Gateway
|
6
|
+
|
1
7
|
## [0.8] - 2023-06-06
|
2
8
|
- Update to conform universal payment interface params (see Readme)
|
3
9
|
- BREAKING: change in repeating params `{transaction_id: "xxx", ....}` is now at `{payment: {reccurrence: { init_transaction_id: "xxx" } } }`
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -21,6 +21,11 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
21
21
|
gateway = Comgate::Gateway.new(merchant_gateway_id: ":comgate_id",
|
22
22
|
test_calls: false,
|
23
23
|
client_secret: ":comgate_secret")
|
24
|
+
# or with proxy
|
25
|
+
gateway = Comgate::Gateway.new(merchant_gateway_id: ":comgate_id",
|
26
|
+
test_calls: false,
|
27
|
+
client_secret: ":comgate_secret",
|
28
|
+
proxy_uri: "http://pxuser:pxpassword@proxy.me:123") # or just "http://proxy.me:123"
|
24
29
|
```
|
25
30
|
|
26
31
|
### 2) prepare endpoint
|
@@ -143,7 +148,9 @@ Maximal mixed version looks like:
|
|
143
148
|
expiration_time: "10h", # input ( use "m" or "h" or "d", but only one of them; allowed rage "30m".."7d")
|
144
149
|
description: "Some description",
|
145
150
|
reccurrence: { init_transaction_id: "12AD-dfsA-4568",
|
146
|
-
period: 1
|
151
|
+
period: 1,
|
152
|
+
cycle: :month, # :on_demand
|
153
|
+
valid_to: } },
|
147
154
|
},
|
148
155
|
payer: {
|
149
156
|
email: "payer1@gmail.com", # input/output
|
@@ -184,6 +191,8 @@ This may be refactored in future.
|
|
184
191
|
## One more thing
|
185
192
|
This gem extends `Hash` with methods `deep_symbolize_keys` and `deep_merge` (if needed).
|
186
193
|
|
194
|
+
Every request to Comgate is logged/printout at `:debug` level. You can change the minimal level with ENV variable "COMGATE_MIN_LOG_LEVEL".
|
195
|
+
|
187
196
|
## Development
|
188
197
|
|
189
198
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/comgate/api_caller.rb
CHANGED
@@ -20,11 +20,12 @@ module Comgate
|
|
20
20
|
|
21
21
|
attr_reader :payload, :url
|
22
22
|
|
23
|
-
def initialize(url:, payload:, test_call: false)
|
23
|
+
def initialize(url:, payload:, test_call: false, proxy_uri: nil)
|
24
24
|
super()
|
25
25
|
@url = url
|
26
26
|
@payload = payload
|
27
27
|
@payload.merge!(test: "true") if test_call
|
28
|
+
@proxy_uri = proxy_uri
|
28
29
|
end
|
29
30
|
|
30
31
|
def build_result
|
@@ -57,7 +58,20 @@ module Comgate
|
|
57
58
|
end
|
58
59
|
|
59
60
|
def https_conn
|
60
|
-
@https_conn ||=
|
61
|
+
@https_conn ||= if @proxy_uri
|
62
|
+
proxy = URI.parse(@proxy_uri)
|
63
|
+
Net::HTTP.start(service_uri.host,
|
64
|
+
service_uri.port,
|
65
|
+
proxy.host,
|
66
|
+
proxy.port,
|
67
|
+
proxy.user,
|
68
|
+
proxy.password,
|
69
|
+
connection_options)
|
70
|
+
else
|
71
|
+
Net::HTTP.start(service_uri.host,
|
72
|
+
service_uri.port,
|
73
|
+
connection_options)
|
74
|
+
end
|
61
75
|
end
|
62
76
|
|
63
77
|
def request
|
@@ -153,11 +167,13 @@ module Comgate
|
|
153
167
|
else
|
154
168
|
puts("#{Time.now} [#{forced_log_level(level)}] #{message}")
|
155
169
|
end
|
170
|
+
rescue StandardError => e
|
171
|
+
puts("#{Time.now} [#{forced_log_level(level)}] #{message} - #{e}")
|
156
172
|
end
|
157
173
|
|
158
174
|
def forced_log_level(original_level)
|
159
175
|
levels = { debug: 0, info: 1, error: 2 }
|
160
|
-
minimal_level = :
|
176
|
+
minimal_level = ENV["COMGATE_MIN_LOG_LEVEL"]&.to_sym || :debug
|
161
177
|
levels[original_level] > levels[minimal_level] ? original_level : minimal_level
|
162
178
|
end
|
163
179
|
|
data/lib/comgate/gateway.rb
CHANGED
@@ -74,6 +74,10 @@ module Comgate
|
|
74
74
|
options[:test_calls] == true
|
75
75
|
end
|
76
76
|
|
77
|
+
def proxy_uri
|
78
|
+
options[:proxy_uri]
|
79
|
+
end
|
80
|
+
|
77
81
|
def start_transaction(payment_data)
|
78
82
|
make_call(url: "#{BASE_URL}/create",
|
79
83
|
payload: single_payment_payload(payment_data),
|
@@ -173,7 +177,7 @@ module Comgate
|
|
173
177
|
def make_call(url:, payload:, test_call:, conversion_hash: DATA_CONVERSION_HASH)
|
174
178
|
raise "There are errors in pre-api-call phase: #{payload[:errors]}" unless payload[:errors].nil?
|
175
179
|
|
176
|
-
srv = Comgate::ApiCaller.call(url: url, payload: payload, test_call: test_call)
|
180
|
+
srv = Comgate::ApiCaller.call(url: url, payload: payload, test_call: test_call, proxy_uri: proxy_uri)
|
177
181
|
if srv.success?
|
178
182
|
Comgate::Response.new(srv.result, conversion_hash)
|
179
183
|
else
|
data/lib/comgate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comgate_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Petr Mlčoch
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-06-
|
11
|
+
date: 2023-06-20 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a longer description or delete this line.
|
14
14
|
email:
|