processout 2.20.0 → 2.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +52 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Dockerfile +7 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/Makefile +4 -0
- data/README.md +12 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/processout/activity.rb +206 -0
- data/lib/processout/addon.rb +401 -0
- data/lib/processout/alternative_merchant_certificate.rb +115 -0
- data/lib/processout/api_request.rb +295 -0
- data/lib/processout/api_version.rb +92 -0
- data/lib/processout/apple_pay_alternative_merchant_certificates.rb +121 -0
- data/lib/processout/balance.rb +92 -0
- data/lib/processout/balances.rb +111 -0
- data/lib/processout/card.rb +503 -0
- data/lib/processout/card_information.rb +164 -0
- data/lib/processout/coupon.rb +352 -0
- data/lib/processout/customer.rb +755 -0
- data/lib/processout/customer_action.rb +81 -0
- data/lib/processout/discount.rb +360 -0
- data/lib/processout/dunning_action.rb +81 -0
- data/lib/processout/errors/authentication_error.rb +9 -0
- data/lib/processout/errors/generic_error.rb +9 -0
- data/lib/processout/errors/internal_error.rb +9 -0
- data/lib/processout/errors/notfound_error.rb +9 -0
- data/lib/processout/errors/validation_error.rb +9 -0
- data/lib/processout/event.rb +237 -0
- data/lib/processout/gateway.rb +210 -0
- data/lib/processout/gateway_configuration.rb +346 -0
- data/lib/processout/gateway_request.rb +26 -0
- data/lib/processout/invoice.rb +984 -0
- data/lib/processout/invoice_detail.rb +235 -0
- data/lib/processout/invoice_device.rb +92 -0
- data/lib/processout/invoice_external_fraud_tools.rb +70 -0
- data/lib/processout/invoice_risk.rb +81 -0
- data/lib/processout/invoice_shipping.rb +202 -0
- data/lib/processout/invoice_tax.rb +81 -0
- data/lib/processout/networking/request.rb +102 -0
- data/lib/processout/networking/response.rb +67 -0
- data/lib/processout/payment_data_network_authentication.rb +70 -0
- data/lib/processout/payment_data_three_ds_authentication.rb +70 -0
- data/lib/processout/payment_data_three_ds_request.rb +103 -0
- data/lib/processout/payout.rb +379 -0
- data/lib/processout/payout_item.rb +238 -0
- data/lib/processout/plan.rb +368 -0
- data/lib/processout/product.rb +368 -0
- data/lib/processout/project.rb +353 -0
- data/lib/processout/refund.rb +277 -0
- data/lib/processout/subscription.rb +910 -0
- data/lib/processout/three_ds.rb +158 -0
- data/lib/processout/token.rb +493 -0
- data/lib/processout/transaction.rb +905 -0
- data/lib/processout/transaction_operation.rb +418 -0
- data/lib/processout/version.rb +3 -0
- data/lib/processout/webhook.rb +237 -0
- data/lib/processout/webhook_endpoint.rb +149 -0
- data/lib/processout.rb +263 -0
- data/processout.gemspec +26 -0
- metadata +66 -3
@@ -0,0 +1,346 @@
|
|
1
|
+
# The content of this file was automatically generated
|
2
|
+
|
3
|
+
require "cgi"
|
4
|
+
require "json"
|
5
|
+
require "processout/networking/request"
|
6
|
+
require "processout/networking/response"
|
7
|
+
|
8
|
+
module ProcessOut
|
9
|
+
class GatewayConfiguration
|
10
|
+
|
11
|
+
attr_reader :id
|
12
|
+
attr_reader :project
|
13
|
+
attr_reader :project_id
|
14
|
+
attr_reader :gateway
|
15
|
+
attr_reader :gateway_id
|
16
|
+
attr_reader :name
|
17
|
+
attr_reader :default_currency
|
18
|
+
attr_reader :enabled
|
19
|
+
attr_reader :public_keys
|
20
|
+
attr_reader :created_at
|
21
|
+
attr_reader :enabled_at
|
22
|
+
|
23
|
+
|
24
|
+
def id=(val)
|
25
|
+
@id = val
|
26
|
+
end
|
27
|
+
|
28
|
+
def project=(val)
|
29
|
+
if val.nil?
|
30
|
+
@project = val
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
if val.instance_of? Project
|
35
|
+
@project = val
|
36
|
+
else
|
37
|
+
obj = Project.new(@client)
|
38
|
+
obj.fill_with_data(val)
|
39
|
+
@project = obj
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
|
44
|
+
def project_id=(val)
|
45
|
+
@project_id = val
|
46
|
+
end
|
47
|
+
|
48
|
+
def gateway=(val)
|
49
|
+
if val.nil?
|
50
|
+
@gateway = val
|
51
|
+
return
|
52
|
+
end
|
53
|
+
|
54
|
+
if val.instance_of? Gateway
|
55
|
+
@gateway = val
|
56
|
+
else
|
57
|
+
obj = Gateway.new(@client)
|
58
|
+
obj.fill_with_data(val)
|
59
|
+
@gateway = obj
|
60
|
+
end
|
61
|
+
|
62
|
+
end
|
63
|
+
|
64
|
+
def gateway_id=(val)
|
65
|
+
@gateway_id = val
|
66
|
+
end
|
67
|
+
|
68
|
+
def name=(val)
|
69
|
+
@name = val
|
70
|
+
end
|
71
|
+
|
72
|
+
def default_currency=(val)
|
73
|
+
@default_currency = val
|
74
|
+
end
|
75
|
+
|
76
|
+
def enabled=(val)
|
77
|
+
@enabled = val
|
78
|
+
end
|
79
|
+
|
80
|
+
def public_keys=(val)
|
81
|
+
@public_keys = val
|
82
|
+
end
|
83
|
+
|
84
|
+
def created_at=(val)
|
85
|
+
@created_at = val
|
86
|
+
end
|
87
|
+
|
88
|
+
def enabled_at=(val)
|
89
|
+
@enabled_at = val
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
# Initializes the GatewayConfiguration object
|
94
|
+
# Params:
|
95
|
+
# +client+:: +ProcessOut+ client instance
|
96
|
+
# +data+:: data that can be used to fill the object
|
97
|
+
def initialize(client, data = {})
|
98
|
+
@client = client
|
99
|
+
|
100
|
+
self.id = data.fetch(:id, nil)
|
101
|
+
self.project = data.fetch(:project, nil)
|
102
|
+
self.project_id = data.fetch(:project_id, nil)
|
103
|
+
self.gateway = data.fetch(:gateway, nil)
|
104
|
+
self.gateway_id = data.fetch(:gateway_id, nil)
|
105
|
+
self.name = data.fetch(:name, nil)
|
106
|
+
self.default_currency = data.fetch(:default_currency, nil)
|
107
|
+
self.enabled = data.fetch(:enabled, nil)
|
108
|
+
self.public_keys = data.fetch(:public_keys, nil)
|
109
|
+
self.created_at = data.fetch(:created_at, nil)
|
110
|
+
self.enabled_at = data.fetch(:enabled_at, nil)
|
111
|
+
|
112
|
+
end
|
113
|
+
|
114
|
+
# Create a new GatewayConfiguration using the current client
|
115
|
+
def new(data = {})
|
116
|
+
GatewayConfiguration.new(@client, data)
|
117
|
+
end
|
118
|
+
|
119
|
+
# Overrides the JSON marshaller to only send the fields we want
|
120
|
+
def to_json(options)
|
121
|
+
{
|
122
|
+
"id": self.id,
|
123
|
+
"project": self.project,
|
124
|
+
"project_id": self.project_id,
|
125
|
+
"gateway": self.gateway,
|
126
|
+
"gateway_id": self.gateway_id,
|
127
|
+
"name": self.name,
|
128
|
+
"default_currency": self.default_currency,
|
129
|
+
"enabled": self.enabled,
|
130
|
+
"public_keys": self.public_keys,
|
131
|
+
"created_at": self.created_at,
|
132
|
+
"enabled_at": self.enabled_at,
|
133
|
+
}.to_json
|
134
|
+
end
|
135
|
+
|
136
|
+
# Fills the object with data coming from the API
|
137
|
+
# Params:
|
138
|
+
# +data+:: +Hash+ of data coming from the API
|
139
|
+
def fill_with_data(data)
|
140
|
+
if data.nil?
|
141
|
+
return self
|
142
|
+
end
|
143
|
+
if data.include? "id"
|
144
|
+
self.id = data["id"]
|
145
|
+
end
|
146
|
+
if data.include? "project"
|
147
|
+
self.project = data["project"]
|
148
|
+
end
|
149
|
+
if data.include? "project_id"
|
150
|
+
self.project_id = data["project_id"]
|
151
|
+
end
|
152
|
+
if data.include? "gateway"
|
153
|
+
self.gateway = data["gateway"]
|
154
|
+
end
|
155
|
+
if data.include? "gateway_id"
|
156
|
+
self.gateway_id = data["gateway_id"]
|
157
|
+
end
|
158
|
+
if data.include? "name"
|
159
|
+
self.name = data["name"]
|
160
|
+
end
|
161
|
+
if data.include? "default_currency"
|
162
|
+
self.default_currency = data["default_currency"]
|
163
|
+
end
|
164
|
+
if data.include? "enabled"
|
165
|
+
self.enabled = data["enabled"]
|
166
|
+
end
|
167
|
+
if data.include? "public_keys"
|
168
|
+
self.public_keys = data["public_keys"]
|
169
|
+
end
|
170
|
+
if data.include? "created_at"
|
171
|
+
self.created_at = data["created_at"]
|
172
|
+
end
|
173
|
+
if data.include? "enabled_at"
|
174
|
+
self.enabled_at = data["enabled_at"]
|
175
|
+
end
|
176
|
+
|
177
|
+
self
|
178
|
+
end
|
179
|
+
|
180
|
+
# Prefills the object with the data passed as parameters
|
181
|
+
# Params:
|
182
|
+
# +data+:: +Hash+ of data
|
183
|
+
def prefill(data)
|
184
|
+
if data.nil?
|
185
|
+
return self
|
186
|
+
end
|
187
|
+
self.id = data.fetch(:id, self.id)
|
188
|
+
self.project = data.fetch(:project, self.project)
|
189
|
+
self.project_id = data.fetch(:project_id, self.project_id)
|
190
|
+
self.gateway = data.fetch(:gateway, self.gateway)
|
191
|
+
self.gateway_id = data.fetch(:gateway_id, self.gateway_id)
|
192
|
+
self.name = data.fetch(:name, self.name)
|
193
|
+
self.default_currency = data.fetch(:default_currency, self.default_currency)
|
194
|
+
self.enabled = data.fetch(:enabled, self.enabled)
|
195
|
+
self.public_keys = data.fetch(:public_keys, self.public_keys)
|
196
|
+
self.created_at = data.fetch(:created_at, self.created_at)
|
197
|
+
self.enabled_at = data.fetch(:enabled_at, self.enabled_at)
|
198
|
+
|
199
|
+
self
|
200
|
+
end
|
201
|
+
|
202
|
+
# Get all the gateway configurations.
|
203
|
+
# Params:
|
204
|
+
# +options+:: +Hash+ of options
|
205
|
+
def all(options = {})
|
206
|
+
self.prefill(options)
|
207
|
+
|
208
|
+
request = Request.new(@client)
|
209
|
+
path = "/gateway-configurations"
|
210
|
+
data = {
|
211
|
+
"expand_merchant_accounts" => options.fetch(:expand_merchant_accounts, nil)
|
212
|
+
}
|
213
|
+
|
214
|
+
response = Response.new(request.get(path, data, options))
|
215
|
+
return_values = Array.new
|
216
|
+
|
217
|
+
a = Array.new
|
218
|
+
body = response.body
|
219
|
+
for v in body['gateway_configurations']
|
220
|
+
tmp = GatewayConfiguration.new(@client)
|
221
|
+
tmp.fill_with_data(v)
|
222
|
+
a.push(tmp)
|
223
|
+
end
|
224
|
+
|
225
|
+
return_values.push(a)
|
226
|
+
|
227
|
+
|
228
|
+
|
229
|
+
return_values[0]
|
230
|
+
end
|
231
|
+
|
232
|
+
# Find a gateway configuration by its ID.
|
233
|
+
# Params:
|
234
|
+
# +configuration_id+:: ID of the gateway configuration
|
235
|
+
# +options+:: +Hash+ of options
|
236
|
+
def find(configuration_id, options = {})
|
237
|
+
self.prefill(options)
|
238
|
+
|
239
|
+
request = Request.new(@client)
|
240
|
+
path = "/gateway-configurations/" + CGI.escape(configuration_id) + ""
|
241
|
+
data = {
|
242
|
+
|
243
|
+
}
|
244
|
+
|
245
|
+
response = Response.new(request.get(path, data, options))
|
246
|
+
return_values = Array.new
|
247
|
+
|
248
|
+
body = response.body
|
249
|
+
body = body["gateway_configuration"]
|
250
|
+
|
251
|
+
|
252
|
+
obj = GatewayConfiguration.new(@client)
|
253
|
+
return_values.push(obj.fill_with_data(body))
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
return_values[0]
|
258
|
+
end
|
259
|
+
|
260
|
+
# Save the updated gateway configuration attributes and settings.
|
261
|
+
# Params:
|
262
|
+
# +options+:: +Hash+ of options
|
263
|
+
def save(options = {})
|
264
|
+
self.prefill(options)
|
265
|
+
|
266
|
+
request = Request.new(@client)
|
267
|
+
path = "/gateway-configurations/" + CGI.escape(@id) + ""
|
268
|
+
data = {
|
269
|
+
"id" => @id,
|
270
|
+
"name" => @name,
|
271
|
+
"enabled" => @enabled,
|
272
|
+
"default_currency" => @default_currency,
|
273
|
+
"settings" => options.fetch(:settings, nil),
|
274
|
+
"sub_accounts_enabled" => options.fetch(:sub_accounts_enabled, nil)
|
275
|
+
}
|
276
|
+
|
277
|
+
response = Response.new(request.put(path, data, options))
|
278
|
+
return_values = Array.new
|
279
|
+
|
280
|
+
body = response.body
|
281
|
+
body = body["gateway_configuration"]
|
282
|
+
|
283
|
+
|
284
|
+
return_values.push(self.fill_with_data(body))
|
285
|
+
|
286
|
+
|
287
|
+
|
288
|
+
return_values[0]
|
289
|
+
end
|
290
|
+
|
291
|
+
# Delete the gateway configuration.
|
292
|
+
# Params:
|
293
|
+
# +options+:: +Hash+ of options
|
294
|
+
def delete(options = {})
|
295
|
+
self.prefill(options)
|
296
|
+
|
297
|
+
request = Request.new(@client)
|
298
|
+
path = "/gateway-configurations/" + CGI.escape(@id) + ""
|
299
|
+
data = {
|
300
|
+
|
301
|
+
}
|
302
|
+
|
303
|
+
response = Response.new(request.delete(path, data, options))
|
304
|
+
return_values = Array.new
|
305
|
+
|
306
|
+
return_values.push(response.success)
|
307
|
+
|
308
|
+
|
309
|
+
return_values[0]
|
310
|
+
end
|
311
|
+
|
312
|
+
# Create a new gateway configuration.
|
313
|
+
# Params:
|
314
|
+
# +gateway_name+:: Name of the gateway
|
315
|
+
# +options+:: +Hash+ of options
|
316
|
+
def create(gateway_name, options = {})
|
317
|
+
self.prefill(options)
|
318
|
+
|
319
|
+
request = Request.new(@client)
|
320
|
+
path = "/gateways/" + CGI.escape(gateway_name) + "/gateway-configurations"
|
321
|
+
data = {
|
322
|
+
"id" => @id,
|
323
|
+
"name" => @name,
|
324
|
+
"enabled" => @enabled,
|
325
|
+
"default_currency" => @default_currency,
|
326
|
+
"settings" => options.fetch(:settings, nil),
|
327
|
+
"sub_accounts_enabled" => options.fetch(:sub_accounts_enabled, nil)
|
328
|
+
}
|
329
|
+
|
330
|
+
response = Response.new(request.post(path, data, options))
|
331
|
+
return_values = Array.new
|
332
|
+
|
333
|
+
body = response.body
|
334
|
+
body = body["gateway_configuration"]
|
335
|
+
|
336
|
+
|
337
|
+
return_values.push(self.fill_with_data(body))
|
338
|
+
|
339
|
+
|
340
|
+
|
341
|
+
return_values[0]
|
342
|
+
end
|
343
|
+
|
344
|
+
|
345
|
+
end
|
346
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require "base64"
|
2
|
+
require "json"
|
3
|
+
|
4
|
+
module ProcessOut
|
5
|
+
class GatewayRequest
|
6
|
+
attr_accessor :gateway_configuration_id, :method, :url, :headers, :body
|
7
|
+
|
8
|
+
def initialize(gateway_configuration_id, data = {})
|
9
|
+
self.gateway_configuration_id = gateway_configuration_id
|
10
|
+
self.method = data.fetch(:method, nil)
|
11
|
+
self.url = data.fetch(:url, nil)
|
12
|
+
self.headers = data.fetch(:headers, {})
|
13
|
+
self.body = data.fetch(:body, nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
"gway_req_" + Base64.strict_encode64(JSON.generate({
|
18
|
+
gateway_configuration_id: self.gateway_configuration_id,
|
19
|
+
method: self.method,
|
20
|
+
url: self.url,
|
21
|
+
headers: self.headers,
|
22
|
+
body: self.body
|
23
|
+
}))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|