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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d020da6b1614a32495b473b497b9931406275e575a5be5012b70c46313a60041
4
- data.tar.gz: ff070de8de6f549aaf6482c3a00f07cf7d496e683a6829cbdca7a40854ee8049
3
+ metadata.gz: 4a86d9ae209a84c1dd4d9942b70d6bc33724567029891397a1a2fe6aa685b540
4
+ data.tar.gz: b296ea50f4e2c1ebd450c02e38508b52c15d7e730aedfc2a9200a7ae3093a7a0
5
5
  SHA512:
6
- metadata.gz: cde1b8d7a8b37148cfa1af8afd799ca9858b565f52a34d265651233ac49a5dd90879ebc2c602097ed654aa1c79ae4cc764b08af0bda7a2047f9a7e3943a6d16d
7
- data.tar.gz: 56490bc816c7e2a5afa3b9ca30d36d4603ae388853d157d078b43ffe1e42376e627541e4b8e4b95eb9edccb0d00c96e2304486365f1d286dd7dbbbb01fbab973
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comgate_ruby (0.8.1)
4
+ comgate_ruby (0.8.3.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -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
- errors[:api] = ["[Error ##{result[:response_body]["error"]}] #{result[:response_body]["message"]}"]
126
- @result[:errors] = { api: { code: result[:response_body]["error"].to_i,
127
- message: result[:response_body]["message"] } }
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?
@@ -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 # backward compatibility
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.errors)
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(errors)
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)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Comgate
4
- VERSION = "0.8.2"
4
+ VERSION = "0.8.3.1"
5
5
  end
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.2
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-20 00:00:00.000000000 Z
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: