comgate_ruby 0.5.0 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a7d8a030a101f774292a7f3214a1d3338238afa11fbc9c98e348db15259d6fde
4
- data.tar.gz: 6253ba9e4d7e3a1737f491b3efccbd82bd85afc1c802c97c4939e3114dcc88ed
3
+ metadata.gz: 72f2698e92aee79da30f44ca5e7bff94f91fd2e5040e592376ed5da708917357
4
+ data.tar.gz: 3da9f58a4a35c420d2b1297352caacbcef7def37e00765fa3029362ef597a631
5
5
  SHA512:
6
- metadata.gz: 47713672ee0beed059c9e26b90bbaebded0cdc29db78f08e20c9e406678c2ffd59562a439f81c8b5a2a9d0716ab7b637af9dcc86068a9010df0e0350c4984ff9
7
- data.tar.gz: 9d2a09ac2489566918c5f131764636c34113bfb92cc57be659b72d349bbd78c7ebbec0fb7c2d5108e28261a4f728dc6ef4ca312dc684f331a12981ad7c6cf988
6
+ metadata.gz: bebb119abe984f6f30f03d4ed37481fbff9ca749f74978cc54456c2e16c132de0ddddc1d3587555659b392a7952ca554bb61e5a401c7025610764771fcb2c933
7
+ data.tar.gz: e65fc6812ceaa251f0d3a730cf71ad243485118941462dfcc30f11122be90f16dd081f0df3a22a65115bcccd165a2e294d58b60638d12d95980fa45999da5efa
data/CHANGELOG.md CHANGED
@@ -3,3 +3,8 @@
3
3
  - Initial release
4
4
 
5
5
 
6
+ ## [0.7.0] - 2023-04-27
7
+
8
+ - better handling errors not in "error" param from Comgate
9
+ - renamed `check_state` to `check_transaction` (and keep backward compatibility)
10
+ - renamed `process_payment_callback` to `process_callback` (and keep backward compatibility)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- comgate_ruby (0.5.0)
4
+ comgate_ruby (0.6.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -18,13 +18,13 @@ If bundler is not being used to manage dependencies, install the gem by executin
18
18
  ### 1) set gateway object
19
19
  As singleton on app init or for each transaction:
20
20
  ```ruby
21
- gateway = Commgate::Gateway.new(merchant_gateway_id: ":comgate_id",
22
- test_calls: false,
23
- secret: ":comgate_secret")
21
+ gateway = Comgate::Gateway.new(merchant_gateway_id: ":comgate_id",
22
+ test_calls: false,
23
+ client_secret: ":comgate_secret")
24
24
  ```
25
25
 
26
26
  ### 2) prepare endpoint
27
- Comgate sends POST requests to your app about transactions updates. The URL of it needs to be setup in Comgate Client portal. At endpoint, just call `gateway.process_payment_callback(params)`, which will return
27
+ Comgate sends POST requests to your app about transactions updates. The URL of it needs to be setup in Comgate Client portal. At endpoint, just call `gateway.process_callback(params)`, which will return
28
28
  `{state: :paid, transaction_id: ":transID"}` (at least). See bullets 4) and 5) in Single payment process bellow.
29
29
  ### 3) call appropriate method
30
30
  (see bellow)
@@ -83,7 +83,7 @@ If bundler is not being used to manage dependencies, install the gem by executin
83
83
 
84
84
  ### Check payment state (ad-hoc)
85
85
  0) The endpoint must be always implemented, this is just additional way to check payment state
86
- 1) Call `gateway.check_state(transaction_id: ":transID")`. It will return `{state: :paid, transaction_id: ":transID"}` and some more infos.
86
+ 1) Call `gateway.check_transaction(transaction_id: ":transID")`. It will return `{state: :paid, transaction_id: ":transID"}` and some more infos.
87
87
  2) Handle status change like bullet 5) in single payment
88
88
 
89
89
  ### Get payment methods allowed to merchant
@@ -115,8 +115,14 @@ module Comgate
115
115
 
116
116
  def api_error?
117
117
  return false unless decoded_response_body.is_a?(Hash)
118
+ return true if decoded_response_body["error"].to_i.positive?
118
119
 
119
- decoded_response_body["error"].to_i.positive?
120
+ if decoded_response_body["code"].to_i.positive?
121
+ decoded_response_body["error"] = decoded_response_body["code"]
122
+ return true
123
+ end
124
+
125
+ false
120
126
  end
121
127
 
122
128
  def handle_connection_error(error)
@@ -25,6 +25,18 @@ module Comgate
25
25
  preauth: %i[payment preauthorization],
26
26
  verification: %i[payment verification_payment],
27
27
 
28
+ ## not used for Comgate, but for other Gateway payments they are needed
29
+ ## so here they are for evidence
30
+ # firstName: %i[payer first_name],
31
+ # lastName: %i[payer last_name],
32
+ # street: %i[payer street_line],
33
+ # city: %i[payer city],
34
+ # postalCode: %i[payer postal_code],
35
+ # payerCountryCode: %i[payer country_code],
36
+ # description: %i[payment description],
37
+ # returnUrl: %i[options shop_return_url],
38
+ # callbackUrl: %i[options callback_url],
39
+
28
40
  # responses
29
41
  transId: %i[transaction_id],
30
42
  transferId: %i[transfer_id],
@@ -53,9 +65,9 @@ module Comgate
53
65
 
54
66
  def initialize(options)
55
67
  @options = options
56
- return unless options[:merchant_gateway_id].nil? || options[:secret].nil? || options[:test_calls].nil?
68
+ return unless options[:merchant_gateway_id].nil? || options[:client_secret].nil? || options[:test_calls].nil?
57
69
 
58
- raise ArgumentError "options have to include :merchant_gateway_id, :secret and :test_calls"
70
+ raise ArgumentError, "options have to include :merchant_gateway_id, :client_secret and :test_calls"
59
71
  end
60
72
 
61
73
  def test_calls_used?
@@ -122,15 +134,16 @@ module Comgate
122
134
  test_call: false)
123
135
  end
124
136
 
125
- def check_state(transaction_id:)
137
+ def check_transaction(transaction_id:)
126
138
  make_call(url: "#{BASE_URL}/status",
127
139
  payload: gateway_params.merge(transId: transaction_id),
128
140
  test_call: false)
129
141
  end
130
142
 
131
- def process_payment_callback(comgate_params)
143
+ def process_callback(comgate_params)
132
144
  Comgate::Response.new({ response_body: comgate_params }, DATA_CONVERSION_HASH)
133
145
  end
146
+ alias process_payment_callback process_callback # backward compatibility
134
147
 
135
148
  def allowed_payment_methods(payment_data)
136
149
  ph = gateway_params.merge(convert_data_to_comgate_params(%i[curr lang country], payment_data, required: false))
@@ -189,7 +202,7 @@ module Comgate
189
202
 
190
203
  def gateway_params
191
204
  { merchant: options[:merchant_gateway_id],
192
- secret: options[:secret] }
205
+ secret: options[:client_secret] }
193
206
  end
194
207
 
195
208
  def convert_data_to_comgate_params(comgate_keys, data, required:)
@@ -31,7 +31,7 @@ module Comgate
31
31
  1500 => "unexpected error"
32
32
  }.freeze
33
33
 
34
- attr_accessor :http_code, :redirect_to, :hash, :array, :errors
34
+ attr_accessor :http_code, :transaction_id, :redirect_to, :hash, :array, :errors
35
35
  attr_reader :params_conversion_hash
36
36
 
37
37
  def initialize(caller_result, params_conversion_hash = {})
@@ -46,6 +46,7 @@ module Comgate
46
46
  case converted_body
47
47
  when Hash
48
48
  @hash = converted_body
49
+ @transaction_id = converted_body[:transaction_id]
49
50
  @array = nil
50
51
  when Array
51
52
  @array = converted_body
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Comgate
4
- VERSION = "0.5.0"
4
+ VERSION = "0.7"
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.5.0
4
+ version: '0.7'
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-04-20 00:00:00.000000000 Z
11
+ date: 2023-04-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Write a longer description or delete this line.
14
14
  email: