comgate_ruby 0.8.2 → 0.8.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/Gemfile.lock +1 -1
- data/lib/comgate/api_caller.rb +18 -3
- data/lib/comgate/gateway.rb +9 -4
- 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: 4a86d9ae209a84c1dd4d9942b70d6bc33724567029891397a1a2fe6aa685b540
|
4
|
+
data.tar.gz: b296ea50f4e2c1ebd450c02e38508b52c15d7e730aedfc2a9200a7ae3093a7a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e88150f9ae6eb61eb202209794ff100df4cf74c7f0201000cce7562476462d6f33c7b077cb76ea01611e818de016db35238936b6481cd79ef9f5ae8420a37a81
|
7
|
+
data.tar.gz: 0a511d5d5b38e465cd48ce14dba204b23f2500e38222f7374ccc69d3bc342ecb5b91f5edba057be1d978aaa5ed2da54c1fee25549fc70d2f342a8eefadcfeef1
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## [0.8.3.1] - 2023-06-28
|
2
|
+
- fixed internal passing errors
|
3
|
+
|
4
|
+
## [0.8.3] - 2023-06-27
|
5
|
+
- If response from Comgate API is error, but contain "transId", we do not raise exception but pass info up to stack
|
6
|
+
|
1
7
|
## [0.8.2] - 2023-06-20
|
2
8
|
- If ENV["COMGATE_MIN_LOG_LEVEL"] is set, calls and responses to Comgate are logged at that level. Otherwise `:debug` is used.
|
3
9
|
|
data/Gemfile.lock
CHANGED
data/lib/comgate/api_caller.rb
CHANGED
@@ -37,8 +37,20 @@ module Comgate
|
|
37
37
|
|
38
38
|
attr_accessor :response
|
39
39
|
|
40
|
+
HttpResponseStubStruct = Struct.new(:code, :body, :uri, :headers, keyword_init: true) do
|
41
|
+
def [](key)
|
42
|
+
headers[key]
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
40
46
|
def call_api
|
41
47
|
self.response = https_conn.request(request)
|
48
|
+
# body =""
|
49
|
+
# binding.pry
|
50
|
+
# self.response = HttpResponseStubStruct.new(code: "200",
|
51
|
+
# body: body,
|
52
|
+
# uri: URI.parse("example.com"),
|
53
|
+
# headers: { "content-type" => "application/x-www-form-urlencoded; charset=UTF-8" })
|
42
54
|
rescue *KNOWN_CONNECTION_ERRORS => e
|
43
55
|
handle_connection_error(e)
|
44
56
|
end
|
@@ -122,9 +134,12 @@ module Comgate
|
|
122
134
|
def record_api_error
|
123
135
|
return unless api_error?
|
124
136
|
|
125
|
-
|
126
|
-
|
127
|
-
|
137
|
+
msg = [result[:response_body]["message"], result[:response_body]["extraMessage"]].compact.join(" ")
|
138
|
+
errors[:api] = ["[Error ##{result[:response_body]["error"]}] #{msg}"]
|
139
|
+
@result[:errors] = { api: [
|
140
|
+
{ code: result[:response_body]["error"].to_i,
|
141
|
+
message: msg }
|
142
|
+
] }
|
128
143
|
end
|
129
144
|
|
130
145
|
def api_error?
|
data/lib/comgate/gateway.rb
CHANGED
@@ -42,6 +42,7 @@ module Comgate
|
|
42
42
|
transferId: %i[transfer_id],
|
43
43
|
code: %i[code],
|
44
44
|
message: %i[message],
|
45
|
+
extraMessage: %i[extra_message],
|
45
46
|
payerId: %i[payer id],
|
46
47
|
payerName: %i[payer account_name],
|
47
48
|
payer_name: %i[payer account_name],
|
@@ -148,7 +149,7 @@ module Comgate
|
|
148
149
|
def process_callback(comgate_params)
|
149
150
|
Comgate::Response.new({ response_body: comgate_params }, DATA_CONVERSION_HASH)
|
150
151
|
end
|
151
|
-
alias process_payment_callback process_callback
|
152
|
+
alias process_payment_callback process_callback # backward compatibility
|
152
153
|
|
153
154
|
def allowed_payment_methods(payment_data)
|
154
155
|
ph = gateway_params.merge(convert_data_to_comgate_params(%i[curr lang country], payment_data, required: false))
|
@@ -178,10 +179,11 @@ module Comgate
|
|
178
179
|
raise "There are errors in pre-api-call phase: #{payload[:errors]}" unless payload[:errors].nil?
|
179
180
|
|
180
181
|
srv = Comgate::ApiCaller.call(url: url, payload: payload, test_call: test_call, proxy_uri: proxy_uri)
|
182
|
+
|
181
183
|
if srv.success?
|
182
184
|
Comgate::Response.new(srv.result, conversion_hash)
|
183
185
|
else
|
184
|
-
handle_failure_from(srv
|
186
|
+
handle_failure_from(srv, conversion_hash)
|
185
187
|
end
|
186
188
|
end
|
187
189
|
|
@@ -189,8 +191,11 @@ module Comgate
|
|
189
191
|
test_from_data.nil? ? test_calls_used? : (test_from_data == true)
|
190
192
|
end
|
191
193
|
|
192
|
-
def handle_failure_from(
|
193
|
-
raise errors.to_s
|
194
|
+
def handle_failure_from(srv, conversion_hash)
|
195
|
+
raise srv.errors.to_s if srv.result.dig(:response_body, "transId").nil?
|
196
|
+
|
197
|
+
# pretends to be a successfull response, and keep payment check to decide what to do next
|
198
|
+
Comgate::Response.new(srv.result, conversion_hash)
|
194
199
|
end
|
195
200
|
|
196
201
|
def single_payment_payload(payment_data)
|
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.3.1
|
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-28 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Write a longer description or delete this line.
|
14
14
|
email:
|