barion 0.5.1 → 0.5.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 +4 -4
- data/README.md +3 -1
- data/app/models/barion/item.rb +1 -1
- data/app/models/barion/payment.rb +3 -3
- data/app/models/barion/payment_transaction.rb +1 -1
- data/config/initializers/barion.rb +2 -1
- data/lib/barion/config.rb +95 -1
- data/lib/barion/engine.rb +4 -4
- data/lib/barion/version.rb +1 -1
- data/lib/barion.rb +140 -4
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18b5fa982b714053631efb5c9827a00d72fa965a9e864f8f4e2e1db810d451c7
|
4
|
+
data.tar.gz: 8edc1391bcb596b9566621fe4b5954188b99808c4840e8cadca8102ef5d567de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9580e31fa373aae0ea5e9f828eaf26133a614f6818ab93ecb6db646d0d4af65339e9e3f7a5328597910a82314c05a15a4d550a74394c88d5fa48e519150f9cce
|
7
|
+
data.tar.gz: 3e9b2780bda61403434b742dc02b29263ae8adeccbab05dc5eed7ff57bc45fc7b08a4fda6b40b9798e88591bd87d75dea7684f766b8dbfcfac4ceea060367ad0
|
data/README.md
CHANGED
@@ -44,6 +44,8 @@ Just create a file in `config/initializers/barion.rb` with the below content:
|
|
44
44
|
end
|
45
45
|
```
|
46
46
|
|
47
|
+
The configuration is also available in the Rail application configuration under ```Rails.application.config.barion```.
|
48
|
+
|
47
49
|
#### POSKey and PublicKey (default: empty)
|
48
50
|
|
49
51
|
You can find your `POSKey` and `PublicKey` at the Barion Shop website:
|
@@ -203,7 +205,7 @@ error.endpoint # Holds the value of Endpoint attribute of the API error
|
|
203
205
|
|
204
206
|
When a payment has been sent to the gateway it will become readonly for Rails. Only the Gateway is allowed to change its state trough the callbacks.
|
205
207
|
|
206
|
-
To achieve this, a
|
208
|
+
To achieve this, a hash is calculated for every payment when validating it. This hash will be stored in the DB and when a record is loaded in Rails it will be checked against the stored hash. If the hash does not match with the stored data a `::Barion::TamperedData` exception will be raised and the record will not be loaded. This basically mean that the data in the DB has been tampered outside this gem and cannot be considered financially safe.
|
207
209
|
|
208
210
|
## Contributing
|
209
211
|
|
data/app/models/barion/item.rb
CHANGED
@@ -168,7 +168,7 @@ module Barion
|
|
168
168
|
|
169
169
|
def poskey=(value = nil)
|
170
170
|
value = ::Barion.config.poskey if value.nil?
|
171
|
-
super
|
171
|
+
super
|
172
172
|
end
|
173
173
|
|
174
174
|
def payment_type=(value)
|
@@ -183,7 +183,7 @@ module Barion
|
|
183
183
|
else
|
184
184
|
raise ArgumentError, "#{value} is not a valid payment_type"
|
185
185
|
end
|
186
|
-
super
|
186
|
+
super
|
187
187
|
end
|
188
188
|
|
189
189
|
def payer_work_phone_number=(number)
|
@@ -281,7 +281,7 @@ module Barion
|
|
281
281
|
|
282
282
|
# rubocop:disable Lint/UselessMethodDefinition
|
283
283
|
def checksum=(value)
|
284
|
-
super
|
284
|
+
super
|
285
285
|
end
|
286
286
|
# rubocop:enable Lint/UselessMethodDefinition
|
287
287
|
|
data/lib/barion/config.rb
CHANGED
@@ -7,18 +7,40 @@ module Barion
|
|
7
7
|
class Config
|
8
8
|
include Singleton
|
9
9
|
|
10
|
-
|
10
|
+
# @!attribute [rw] publickey
|
11
|
+
# Set this to the string provided by Barion registration
|
12
|
+
# @return [String, nil] the public key provided by Barion (default: nil)
|
13
|
+
attr_accessor :publickey
|
14
|
+
# @!attribute [rw] default_payee
|
15
|
+
# Set this to the registered email address of your shop
|
16
|
+
# @return [String, nil] registered email address for your Barion shop (default: nil)
|
17
|
+
attr_accessor :default_payee
|
18
|
+
# @!attribute [w] acronym
|
19
|
+
# Set this to the string provided by Barion registration
|
20
|
+
# @return [String, nil] the acronym provided by Barion (default: '')
|
11
21
|
attr_writer :acronym
|
22
|
+
# @!attribute [r] pixel_id
|
23
|
+
# The pixel ID set up in the initalizer
|
24
|
+
# @return [String, nil] the acronym provided by Barion (default: '')
|
12
25
|
attr_reader :pixel_id
|
13
26
|
|
27
|
+
# @!attribute [r] poskey
|
28
|
+
# The POSKey set up in the initalizer
|
29
|
+
# @return [String, nil] the POSKey provided by Barion (default: nil)
|
14
30
|
def poskey
|
15
31
|
@_poskey || nil
|
16
32
|
end
|
17
33
|
|
34
|
+
# The acronym set up in the initalizer
|
35
|
+
# @return [String] the acronym provided by Barion (default: '')
|
18
36
|
def acronym
|
19
37
|
@acronym || ''
|
20
38
|
end
|
21
39
|
|
40
|
+
# Set the POSKey for the shop
|
41
|
+
#
|
42
|
+
# @param key [String] the POSKey provided by Barion
|
43
|
+
# @raise [ArgumentError] if the key is not a String
|
22
44
|
def poskey=(key)
|
23
45
|
unless key.is_a?(String)
|
24
46
|
raise ArgumentError,
|
@@ -28,25 +50,46 @@ module Barion
|
|
28
50
|
@_poskey = key
|
29
51
|
end
|
30
52
|
|
53
|
+
# Returns the current sandbox mode setting.
|
54
|
+
# Delegates to the sandbox? method to determine the current state.
|
55
|
+
#
|
56
|
+
# @return [Boolean] true if in sandbox mode, false otherwise
|
31
57
|
def sandbox
|
32
58
|
sandbox?
|
33
59
|
end
|
34
60
|
|
61
|
+
# Returns the current sandbox mode setting.
|
62
|
+
#
|
63
|
+
# If the sandbox mode was not set explicitly, it defaults to true.
|
64
|
+
#
|
65
|
+
# @return [Boolean] true if in sandbox mode, false otherwise
|
35
66
|
def sandbox?
|
36
67
|
@_sandbox = true if @_sandbox.nil?
|
37
68
|
@_sandbox
|
38
69
|
end
|
39
70
|
|
71
|
+
# Sets the sandbox mode.
|
72
|
+
#
|
73
|
+
# @param val [Boolean] the desired state for sandbox mode
|
74
|
+
# true to enable sandbox mode, false to disable it
|
40
75
|
def sandbox=(val)
|
41
76
|
@_sandbox = !!val
|
42
77
|
end
|
43
78
|
|
79
|
+
# Sets the Barion Pixel ID.
|
80
|
+
#
|
81
|
+
# Validates that the provided ID is a string and matches the Barion Pixel ID format.
|
82
|
+
#
|
83
|
+
# @param id [String] the Barion Pixel ID to set
|
84
|
+
# @raise [ArgumentError] if the ID is not a string or does not match the expected format
|
44
85
|
def pixel_id=(id)
|
45
86
|
unless id.is_a?(String)
|
46
87
|
raise ArgumentError,
|
47
88
|
"::Barion::Config.pixel_id must be set to a ::String, got #{id.inspect}"
|
48
89
|
end
|
49
90
|
|
91
|
+
return if id.empty?
|
92
|
+
|
50
93
|
if PIXELID_PATTERN.match(id).nil?
|
51
94
|
raise ::ArgumentError,
|
52
95
|
"String:'#{id}' is not in Barion Pixel ID format: 'BP-0000000000-00'"
|
@@ -55,11 +98,25 @@ module Barion
|
|
55
98
|
@pixel_id = id
|
56
99
|
end
|
57
100
|
|
101
|
+
# Returns the REST client endpoint based on the current environment.
|
102
|
+
#
|
103
|
+
# Determines the environment by checking if the sandbox mode is enabled.
|
104
|
+
# If sandbox mode is enabled, the test environment URL is used; otherwise,
|
105
|
+
# the production environment URL is used.
|
106
|
+
#
|
107
|
+
# @return [Object] a new instance of the REST client class initialized with
|
108
|
+
# the appropriate base URL for the current environment.
|
58
109
|
def endpoint
|
59
110
|
env = sandbox? ? :test : :prod
|
60
111
|
rest_client_class.new ::Barion::BASE_URL[env]
|
61
112
|
end
|
62
113
|
|
114
|
+
# Sets the user class used for user authentication.
|
115
|
+
#
|
116
|
+
# Validates that the provided user class is a string.
|
117
|
+
#
|
118
|
+
# @param class_name [String] the user class to use for user authentication
|
119
|
+
# @raise [ArgumentError] if the user class is not a string
|
63
120
|
def user_class=(class_name)
|
64
121
|
unless class_name.is_a?(String)
|
65
122
|
raise ArgumentError, "::Barion:.config.user_class must be set to a ::String, got #{class_name.inspect}"
|
@@ -68,6 +125,9 @@ module Barion
|
|
68
125
|
@_user_class = class_name
|
69
126
|
end
|
70
127
|
|
128
|
+
# Returns the user class set in the initializer.
|
129
|
+
#
|
130
|
+
# @return [Class] the class set in the initializer
|
71
131
|
def user_class
|
72
132
|
# This is nil before the initializer is installed.
|
73
133
|
return nil if @_user_class.nil?
|
@@ -75,6 +135,9 @@ module Barion
|
|
75
135
|
@_user_class.constantize
|
76
136
|
end
|
77
137
|
|
138
|
+
# Sets the class used for item representation.
|
139
|
+
#
|
140
|
+
# @param val [Class] the class to use for item representation
|
78
141
|
def item_class=(class_name)
|
79
142
|
unless class_name.is_a?(String)
|
80
143
|
raise ArgumentError, "::Barion.config.item_class must be set to a ::String, got #{class_name.inspect}"
|
@@ -83,6 +146,11 @@ module Barion
|
|
83
146
|
@_item_class = class_name
|
84
147
|
end
|
85
148
|
|
149
|
+
# Returns the item class set in the initializer.
|
150
|
+
#
|
151
|
+
# This method returns +nil+ until the initializer is installed.
|
152
|
+
#
|
153
|
+
# @return [Class] the class set in the initializer
|
86
154
|
def item_class
|
87
155
|
# This is nil before the initializer is installed.
|
88
156
|
return nil if @_item_class.nil?
|
@@ -90,10 +158,22 @@ module Barion
|
|
90
158
|
@_item_class.constantize
|
91
159
|
end
|
92
160
|
|
161
|
+
# Returns the class used for making REST calls to the Barion API.
|
162
|
+
#
|
163
|
+
# If it was not set explicitly, it defaults to `::RestClient::Resource`.
|
164
|
+
#
|
165
|
+
# @return [Class] the class used for making REST calls
|
93
166
|
def rest_client_class
|
94
167
|
(@_rest_client_class || '::RestClient::Resource').constantize
|
95
168
|
end
|
96
169
|
|
170
|
+
# Sets the class used for making REST calls to the Barion API.
|
171
|
+
#
|
172
|
+
# The class set with this method is used for making REST calls to the Barion API.
|
173
|
+
# It should be set to a class that responds to the same methods as
|
174
|
+
# `::RestClient::Resource`.
|
175
|
+
#
|
176
|
+
# @param class_name [Class, String] the class to use for making REST calls
|
97
177
|
def rest_client_class=(class_name)
|
98
178
|
unless class_name.is_a?(String)
|
99
179
|
raise ArgumentError, "::Barion::Config.rest_client_class must be set to a ::String, got #{class_name.inspect}"
|
@@ -101,5 +181,19 @@ module Barion
|
|
101
181
|
|
102
182
|
@_rest_client_class = class_name
|
103
183
|
end
|
184
|
+
|
185
|
+
# Resets all configuration options to +nil+.
|
186
|
+
#
|
187
|
+
# It is useful when you want to restore the default configuration as the class is a Singleton.
|
188
|
+
def reset
|
189
|
+
@_poskey = nil
|
190
|
+
@_sandbox = nil
|
191
|
+
@_user_class = nil
|
192
|
+
@_item_class = nil
|
193
|
+
@_rest_client_class = nil
|
194
|
+
@acronym = nil
|
195
|
+
@pixel_id = nil
|
196
|
+
@publickey = nil
|
197
|
+
end
|
104
198
|
end
|
105
199
|
end
|
data/lib/barion/engine.rb
CHANGED
@@ -11,6 +11,10 @@ module Barion
|
|
11
11
|
g.fixture_replacement :factory_bot
|
12
12
|
g.factory_bot dir: 'test/factories'
|
13
13
|
end
|
14
|
+
|
15
|
+
initializer 'barion.config', before: :load_config_initializers do |app|
|
16
|
+
app.config.barion = Barion.config
|
17
|
+
end
|
14
18
|
end
|
15
19
|
|
16
20
|
ActiveSupport.on_load(:action_view) do
|
@@ -18,8 +22,4 @@ module Barion
|
|
18
22
|
# so we can call .include
|
19
23
|
include ::Barion::PixelHelper
|
20
24
|
end
|
21
|
-
|
22
|
-
def self.deprecator
|
23
|
-
@deprecator ||= ActiveSupport::Deprecation.new('1.0', 'Barion')
|
24
|
-
end
|
25
25
|
end
|
data/lib/barion/version.rb
CHANGED
data/lib/barion.rb
CHANGED
@@ -13,14 +13,33 @@ module Barion
|
|
13
13
|
|
14
14
|
PIXELID_PATTERN = ::Regexp.new('BP-.{10}-\d{2}').freeze
|
15
15
|
|
16
|
+
# Returns the deprecator instance for the Barion module.
|
17
|
+
#
|
18
|
+
# This is a singleton method that initializes the deprecator
|
19
|
+
# if it hasn't been initialized yet, using ActiveSupport::Deprecation.
|
20
|
+
#
|
21
|
+
# @return [ActiveSupport::Deprecation] the deprecator instance
|
16
22
|
def self.deprecator
|
17
23
|
@deprecator ||= ActiveSupport::Deprecation.new('1.0', 'Barion')
|
18
24
|
end
|
19
25
|
|
20
|
-
|
21
|
-
|
26
|
+
# Configure the Barion engine
|
27
|
+
#
|
28
|
+
# @example
|
29
|
+
# ::Barion.config do |conf|
|
30
|
+
# conf.poskey = 'test'
|
31
|
+
# conf.sandbox = true
|
32
|
+
# end
|
33
|
+
def self.config(&_block)
|
34
|
+
return Barion::Config.instance unless block_given?
|
35
|
+
|
36
|
+
yield(Barion::Config.instance)
|
22
37
|
end
|
23
38
|
|
39
|
+
# Returns whether the Barion engine is in sandbox mode.
|
40
|
+
#
|
41
|
+
# @return [boolean] whether the engine is in sandbox mode
|
42
|
+
# @deprecated
|
24
43
|
def self.sandbox
|
25
44
|
config.sandbox
|
26
45
|
deprecator.warn(
|
@@ -29,6 +48,11 @@ module Barion
|
|
29
48
|
)
|
30
49
|
end
|
31
50
|
|
51
|
+
# Sets whether the Barion engine is in sandbox mode.
|
52
|
+
#
|
53
|
+
# @param val [boolean] the desired state for sandbox mode
|
54
|
+
# true to enable sandbox mode, false to disable it
|
55
|
+
# @deprecated Use ::Barion.config.sandbox= instead
|
32
56
|
def self.sandbox=(val)
|
33
57
|
config.sandbox = val
|
34
58
|
deprecator.warn(
|
@@ -37,6 +61,13 @@ module Barion
|
|
37
61
|
)
|
38
62
|
end
|
39
63
|
|
64
|
+
# Returns whether the Barion engine is in sandbox mode.
|
65
|
+
#
|
66
|
+
# This method delegates to the Barion::Config instance's sandbox? method
|
67
|
+
# to determine the current sandbox mode setting.
|
68
|
+
#
|
69
|
+
# @return [Boolean] true if in sandbox mode, false otherwise
|
70
|
+
# @deprecated Use ::Barion.config.sandbox? instead.
|
40
71
|
def self.sandbox?
|
41
72
|
config.sandbox?
|
42
73
|
deprecator.warn(
|
@@ -45,6 +76,10 @@ module Barion
|
|
45
76
|
)
|
46
77
|
end
|
47
78
|
|
79
|
+
# Returns the current POSKey setting.
|
80
|
+
#
|
81
|
+
# @return [String, nil] the current POSKey setting
|
82
|
+
# @deprecated Use ::Barion.config.poskey instead.
|
48
83
|
def self.poskey
|
49
84
|
config.poskey
|
50
85
|
deprecator.warn(
|
@@ -53,6 +88,10 @@ module Barion
|
|
53
88
|
)
|
54
89
|
end
|
55
90
|
|
91
|
+
# Sets the POSKey for the shop.
|
92
|
+
#
|
93
|
+
# @param val [String] the POSKey provided by Barion
|
94
|
+
# @deprecated Use ::Barion.config.poskey= instead
|
56
95
|
def self.poskey=(val)
|
57
96
|
config.poskey = (val)
|
58
97
|
deprecator.warn(
|
@@ -61,6 +100,9 @@ module Barion
|
|
61
100
|
)
|
62
101
|
end
|
63
102
|
|
103
|
+
# Returns the current PublicKey setting.
|
104
|
+
#
|
105
|
+
# @return [String, nil] the current PublicKey setting
|
64
106
|
def self.publickey
|
65
107
|
config.publickey
|
66
108
|
deprecator.warn(
|
@@ -69,6 +111,9 @@ module Barion
|
|
69
111
|
)
|
70
112
|
end
|
71
113
|
|
114
|
+
# Sets the PublicKey for the shop.
|
115
|
+
#
|
116
|
+
# @param val [String] the PublicKey provided by Barion
|
72
117
|
def self.publickey=(val)
|
73
118
|
config.publickey = (val)
|
74
119
|
deprecator.warn(
|
@@ -77,6 +122,9 @@ module Barion
|
|
77
122
|
)
|
78
123
|
end
|
79
124
|
|
125
|
+
# Returns the current acronym for Barion.
|
126
|
+
#
|
127
|
+
# @return [String] the current acronym setting, empty string by default
|
80
128
|
def self.acronym
|
81
129
|
config.acronym
|
82
130
|
deprecator.warn(
|
@@ -85,6 +133,9 @@ module Barion
|
|
85
133
|
)
|
86
134
|
end
|
87
135
|
|
136
|
+
# Sets the acronym for Barion.
|
137
|
+
#
|
138
|
+
# @param val [String] the desired acronym, empty string by default
|
88
139
|
def self.acronym=(val)
|
89
140
|
config.acronym = val
|
90
141
|
deprecator.warn(
|
@@ -93,6 +144,12 @@ module Barion
|
|
93
144
|
)
|
94
145
|
end
|
95
146
|
|
147
|
+
# Returns the current Barion Pixel ID.
|
148
|
+
#
|
149
|
+
# The Pixel ID is used for tracking and analytics purposes.
|
150
|
+
#
|
151
|
+
# @return [String, nil] the current Pixel ID setting
|
152
|
+
# @deprecated Use ::Barion.config.pixel_id instead.
|
96
153
|
def self.pixel_id
|
97
154
|
config.pixel_id
|
98
155
|
deprecator.warn(
|
@@ -101,6 +158,13 @@ module Barion
|
|
101
158
|
)
|
102
159
|
end
|
103
160
|
|
161
|
+
# Sets the Barion Pixel ID.
|
162
|
+
#
|
163
|
+
# Updates the Barion configuration with the provided Pixel ID.
|
164
|
+
# This method is deprecated and it is recommended to use
|
165
|
+
# `::Barion.config.pixel_id=` instead.
|
166
|
+
#
|
167
|
+
# @param val [String] the Pixel ID to set
|
104
168
|
def self.pixel_id=(val)
|
105
169
|
config.pixel_id = val
|
106
170
|
deprecator.warn(
|
@@ -109,6 +173,13 @@ module Barion
|
|
109
173
|
)
|
110
174
|
end
|
111
175
|
|
176
|
+
# Returns the current default payee for Barion.
|
177
|
+
#
|
178
|
+
# The default payee is the default email address to which the payment
|
179
|
+
# confirmation email is sent.
|
180
|
+
#
|
181
|
+
# @return [String] the current default payee setting, empty string by default
|
182
|
+
# @deprecated Use ::Barion.config.default_payee instead
|
112
183
|
def self.default_payee
|
113
184
|
config.default_payee
|
114
185
|
deprecator.warn(
|
@@ -117,6 +188,14 @@ module Barion
|
|
117
188
|
)
|
118
189
|
end
|
119
190
|
|
191
|
+
# Sets the default payee for Barion.
|
192
|
+
#
|
193
|
+
# Updates the Barion configuration with the provided default payee.
|
194
|
+
# This method is deprecated and it is recommended to use
|
195
|
+
# `::Barion.config.default_payee=` instead.
|
196
|
+
#
|
197
|
+
# @param val [String] the default payee to set
|
198
|
+
# @deprecated Use ::Barion.config.default_payee= instead
|
120
199
|
def self.default_payee=(val)
|
121
200
|
config.default_payee = val
|
122
201
|
deprecator.warn(
|
@@ -125,6 +204,11 @@ module Barion
|
|
125
204
|
)
|
126
205
|
end
|
127
206
|
|
207
|
+
# Returns the class used for user authentication.
|
208
|
+
#
|
209
|
+
# This method is deprecated and it is recommended to use
|
210
|
+
# `::Barion.config.user_class` instead.
|
211
|
+
# @deprecated Use ::Barion.config.user_class instead
|
128
212
|
def self.user_class
|
129
213
|
config.user_class
|
130
214
|
deprecator.warn(
|
@@ -133,6 +217,14 @@ module Barion
|
|
133
217
|
)
|
134
218
|
end
|
135
219
|
|
220
|
+
# Sets the class used for user authentication.
|
221
|
+
#
|
222
|
+
# Updates the Barion configuration with the provided user class.
|
223
|
+
# This method is deprecated and it is recommended to use
|
224
|
+
# `::Barion.config.user_class=` instead.
|
225
|
+
#
|
226
|
+
# @param val [Class] the class to use for user authentication
|
227
|
+
# @deprecated Use ::Barion.config.user_class= instead
|
136
228
|
def self.user_class=(val)
|
137
229
|
config.user_class = val
|
138
230
|
deprecator.warn(
|
@@ -141,6 +233,13 @@ module Barion
|
|
141
233
|
)
|
142
234
|
end
|
143
235
|
|
236
|
+
# Returns the class used for item representation.
|
237
|
+
#
|
238
|
+
# This method is deprecated and it is recommended to use
|
239
|
+
# `::Barion.config.item_class` instead.
|
240
|
+
# @deprecated Use ::Barion.config.item_class instead
|
241
|
+
# @return [Class] the class used for item representation
|
242
|
+
# @deprecated Use ::Barion.config.item_class instead
|
144
243
|
def self.item_class
|
145
244
|
config.item_class
|
146
245
|
deprecator.warn(
|
@@ -149,6 +248,15 @@ module Barion
|
|
149
248
|
)
|
150
249
|
end
|
151
250
|
|
251
|
+
# Sets the class used for item representation.
|
252
|
+
#
|
253
|
+
# Updates the Barion configuration with the provided item class.
|
254
|
+
# This method is deprecated and it is recommended to use
|
255
|
+
# `::Barion.config.item_class=` instead.
|
256
|
+
#
|
257
|
+
# @param val [Class] the class to use for item representation
|
258
|
+
# @deprecated Use ::Barion.config.item_class= instead
|
259
|
+
# @deprecated Use ::Barion.config.item_class= instead
|
152
260
|
def self.item_class=(val)
|
153
261
|
config.item_class = val
|
154
262
|
deprecator.warn(
|
@@ -157,6 +265,12 @@ module Barion
|
|
157
265
|
)
|
158
266
|
end
|
159
267
|
|
268
|
+
# Returns the class used for making REST calls to the Barion API.
|
269
|
+
#
|
270
|
+
# This method is deprecated and it is recommended to use
|
271
|
+
# `::Barion.config.rest_client_class` instead.
|
272
|
+
# @deprecated Use ::Barion.config.rest_client_class instead
|
273
|
+
# @return [Class] the class used for making REST calls
|
160
274
|
def self.rest_client_class
|
161
275
|
config.rest_client_class
|
162
276
|
deprecator.warn(
|
@@ -165,6 +279,14 @@ module Barion
|
|
165
279
|
)
|
166
280
|
end
|
167
281
|
|
282
|
+
# Sets the class used for making REST calls to the Barion API.
|
283
|
+
#
|
284
|
+
# Updates the Barion configuration with the provided REST client class.
|
285
|
+
# This method is deprecated and it is recommended to use
|
286
|
+
# `::Barion.config.rest_client_class=` instead.
|
287
|
+
#
|
288
|
+
# @param val [Class] the class to use for making REST calls
|
289
|
+
# @deprecated Use ::Barion.config.rest_client_class= instead
|
168
290
|
def self.rest_client_class=(val)
|
169
291
|
config.rest_client_class = val
|
170
292
|
deprecator.warn(
|
@@ -179,8 +301,18 @@ module Barion
|
|
179
301
|
|
180
302
|
# Generic error class for Barion module
|
181
303
|
class Error < StandardError
|
182
|
-
attr_reader :title, :error_code, :happened_at, :auth_data, :endpoint, :errors
|
304
|
+
attr_reader :title, :error_code, :happened_at, :auth_data, :endpoint, :errors, :description
|
183
305
|
|
306
|
+
# Creates a new instance of the Barion::Error class. It can hold nested errors.
|
307
|
+
#
|
308
|
+
# @param params [Hash] a hash containing the error data
|
309
|
+
# @option params [String] :Title the title of the error
|
310
|
+
# @option params [Integer] :ErrorCode the error code
|
311
|
+
# @option params [String] :HappenedAt when the error happened in ISO 8601 format
|
312
|
+
# @option params [String] :AuthData authentication data
|
313
|
+
# @option params [String] :Endpoint the endpoint where the error happened
|
314
|
+
# @option params [Array<Hash>] :Errors the errors that happened
|
315
|
+
# @option params [String] :Description the description of the error
|
184
316
|
def initialize(params)
|
185
317
|
@title = params[:Title]
|
186
318
|
@error_code = params[:ErrorCode]
|
@@ -188,9 +320,13 @@ module Barion
|
|
188
320
|
@auth_data = params[:AuthData]
|
189
321
|
@endpoint = params[:Endpoint]
|
190
322
|
@errors = Array(params[:Errors]).map { |e| Barion::Error.new(e) } if params.key? :Errors
|
191
|
-
|
323
|
+
@description = params[:Description]
|
324
|
+
super(@description)
|
192
325
|
end
|
193
326
|
|
327
|
+
# Returns all errors that happened in the request in a single string
|
328
|
+
#
|
329
|
+
# @return [String] all errors that happened in the request
|
194
330
|
def all_errors
|
195
331
|
Array(@errors).map(&:message).join("\n")
|
196
332
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: barion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Péter Nagy
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -89,7 +89,7 @@ licenses:
|
|
89
89
|
- MIT
|
90
90
|
metadata:
|
91
91
|
rubygems_mfa_required: 'true'
|
92
|
-
post_install_message:
|
92
|
+
post_install_message:
|
93
93
|
rdoc_options: []
|
94
94
|
require_paths:
|
95
95
|
- lib
|
@@ -104,8 +104,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '0'
|
106
106
|
requirements: []
|
107
|
-
rubygems_version: 3.
|
108
|
-
signing_key:
|
107
|
+
rubygems_version: 3.2.33
|
108
|
+
signing_key:
|
109
109
|
specification_version: 4
|
110
110
|
summary: Barion payment engine for Ruby on Rails
|
111
111
|
test_files: []
|