comgate_ruby 0.8.1 → 0.8.3

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: c7882560b8946462a01c78940b5c3f9c1e771418b90123e5de3b4f4e3c8dea2e
4
- data.tar.gz: 47271d5e947abd8f189c42f79e248fd0992d56e3a92eb24b624e3f8559ec09fb
3
+ metadata.gz: f70dc5da596b91029a905c8cdb1987b96e805d9d222f54c3a8896947119ca0c8
4
+ data.tar.gz: 6ffc03ac6e2e119c35bce6aa561bab416c20f63dd8b8748c186969952e3f82ce
5
5
  SHA512:
6
- metadata.gz: 72e412a79248be368f95a76c7a8e3214e7156edb8a2336af3150ac1b652e7d95c2e8614ad1c1e4d1f2a3b7d201a7aa915101a6f05fa6fb7f58497f32dd17fd36
7
- data.tar.gz: 8ce0f483ea79eebd5c25cfac010cc0761b5de48cfd1bb5b36155aabf2621bfc9a834e42428f75dcf4bff89554adec82a6289f34a4af8966ce8e86e2afa841239
6
+ metadata.gz: 994a8c9c9450d07e709da2dfe4e7787cffc72e3176b18ec0a1ac8b10718c6b6f9b848fb83e83a28017c5fc06d36ebf87d51b02b8a7720fe7600a2e40cc3fab9d
7
+ data.tar.gz: 5f512b4a460484552f42304cd539a45dbb233e8c2344f037b8ab5712537e5139f5607293f735e069fb064ca36084b273d199ed10abf9f5e0d1cf4fd9688756e4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## [0.8.3] - 2023-06-27
2
+ - If response from Comgate API is error, but containt "transId" we do not raise exception but pass info up to stack
3
+
4
+ ## [0.8.2] - 2023-06-20
5
+ - If ENV["COMGATE_MIN_LOG_LEVEL"] is set, calls and responses to Comgate are logged at that level. Otherwise `:debug` is used.
6
+
1
7
  ## [0.8.1] - 2023-06-13
2
8
  - Allowed `proxy_uri` param for Comgate::Gateway
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)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -148,7 +148,9 @@ Maximal mixed version looks like:
148
148
  expiration_time: "10h", # input ( use "m" or "h" or "d", but only one of them; allowed rage "30m".."7d")
149
149
  description: "Some description",
150
150
  reccurrence: { init_transaction_id: "12AD-dfsA-4568",
151
- period: 1 } },
151
+ period: 1,
152
+ cycle: :month, # :on_demand
153
+ valid_to: } },
152
154
  },
153
155
  payer: {
154
156
  email: "payer1@gmail.com", # input/output
@@ -189,6 +191,8 @@ This may be refactored in future.
189
191
  ## One more thing
190
192
  This gem extends `Hash` with methods `deep_symbolize_keys` and `deep_merge` (if needed).
191
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
+
192
196
  ## Development
193
197
 
194
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.
@@ -122,9 +122,10 @@ module Comgate
122
122
  def record_api_error
123
123
  return unless api_error?
124
124
 
125
- errors[:api] = ["[Error ##{result[:response_body]["error"]}] #{result[:response_body]["message"]}"]
125
+ msg = [result[:response_body]["message"], result[:response_body]["extraMessage"]].compact.join(" ")
126
+ errors[:api] = ["[Error ##{result[:response_body]["error"]}] #{msg}"]
126
127
  @result[:errors] = { api: { code: result[:response_body]["error"].to_i,
127
- message: result[:response_body]["message"] } }
128
+ message: msg } }
128
129
  end
129
130
 
130
131
  def api_error?
@@ -167,11 +168,13 @@ module Comgate
167
168
  else
168
169
  puts("#{Time.now} [#{forced_log_level(level)}] #{message}")
169
170
  end
171
+ rescue StandardError => e
172
+ puts("#{Time.now} [#{forced_log_level(level)}] #{message} - #{e}")
170
173
  end
171
174
 
172
175
  def forced_log_level(original_level)
173
176
  levels = { debug: 0, info: 1, error: 2 }
174
- minimal_level = :error
177
+ minimal_level = ENV["COMGATE_MIN_LOG_LEVEL"]&.to_sym || :debug
175
178
  levels[original_level] > levels[minimal_level] ? original_level : minimal_level
176
179
  end
177
180
 
@@ -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))
@@ -181,7 +182,7 @@ module Comgate
181
182
  if srv.success?
182
183
  Comgate::Response.new(srv.result, conversion_hash)
183
184
  else
184
- handle_failure_from(srv.errors)
185
+ handle_failure_from(srv)
185
186
  end
186
187
  end
187
188
 
@@ -189,8 +190,11 @@ module Comgate
189
190
  test_from_data.nil? ? test_calls_used? : (test_from_data == true)
190
191
  end
191
192
 
192
- def handle_failure_from(errors)
193
- raise errors.to_s
193
+ def handle_failure_from(srv)
194
+ raise srv.errors.to_s unless srv.result.dig(:response_body, "transId").present?
195
+
196
+ # pretends to be a successfull response, and keep payment check to decide what to do next
197
+ Comgate::Response.new(srv.result, conversion_hash)
194
198
  end
195
199
 
196
200
  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.1"
4
+ VERSION = "0.8.3"
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.1
4
+ version: 0.8.3
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-13 00:00:00.000000000 Z
11
+ date: 2023-06-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Write a longer description or delete this line.
14
14
  email: