processout 2.20.0 → 2.21.0

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.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +52 -0
  3. data/.rspec +2 -0
  4. data/.travis.yml +5 -0
  5. data/Dockerfile +7 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +21 -0
  8. data/Makefile +4 -0
  9. data/README.md +12 -0
  10. data/Rakefile +6 -0
  11. data/bin/console +14 -0
  12. data/bin/setup +8 -0
  13. data/lib/processout/activity.rb +206 -0
  14. data/lib/processout/addon.rb +401 -0
  15. data/lib/processout/alternative_merchant_certificate.rb +115 -0
  16. data/lib/processout/api_request.rb +295 -0
  17. data/lib/processout/api_version.rb +92 -0
  18. data/lib/processout/apple_pay_alternative_merchant_certificates.rb +121 -0
  19. data/lib/processout/balance.rb +92 -0
  20. data/lib/processout/balances.rb +111 -0
  21. data/lib/processout/card.rb +503 -0
  22. data/lib/processout/card_information.rb +164 -0
  23. data/lib/processout/coupon.rb +352 -0
  24. data/lib/processout/customer.rb +755 -0
  25. data/lib/processout/customer_action.rb +81 -0
  26. data/lib/processout/discount.rb +360 -0
  27. data/lib/processout/dunning_action.rb +81 -0
  28. data/lib/processout/errors/authentication_error.rb +9 -0
  29. data/lib/processout/errors/generic_error.rb +9 -0
  30. data/lib/processout/errors/internal_error.rb +9 -0
  31. data/lib/processout/errors/notfound_error.rb +9 -0
  32. data/lib/processout/errors/validation_error.rb +9 -0
  33. data/lib/processout/event.rb +237 -0
  34. data/lib/processout/gateway.rb +210 -0
  35. data/lib/processout/gateway_configuration.rb +346 -0
  36. data/lib/processout/gateway_request.rb +26 -0
  37. data/lib/processout/invoice.rb +984 -0
  38. data/lib/processout/invoice_detail.rb +235 -0
  39. data/lib/processout/invoice_device.rb +92 -0
  40. data/lib/processout/invoice_external_fraud_tools.rb +70 -0
  41. data/lib/processout/invoice_risk.rb +81 -0
  42. data/lib/processout/invoice_shipping.rb +202 -0
  43. data/lib/processout/invoice_tax.rb +81 -0
  44. data/lib/processout/networking/request.rb +102 -0
  45. data/lib/processout/networking/response.rb +67 -0
  46. data/lib/processout/payment_data_network_authentication.rb +70 -0
  47. data/lib/processout/payment_data_three_ds_authentication.rb +70 -0
  48. data/lib/processout/payment_data_three_ds_request.rb +103 -0
  49. data/lib/processout/payout.rb +379 -0
  50. data/lib/processout/payout_item.rb +238 -0
  51. data/lib/processout/plan.rb +368 -0
  52. data/lib/processout/product.rb +368 -0
  53. data/lib/processout/project.rb +353 -0
  54. data/lib/processout/refund.rb +277 -0
  55. data/lib/processout/subscription.rb +910 -0
  56. data/lib/processout/three_ds.rb +158 -0
  57. data/lib/processout/token.rb +493 -0
  58. data/lib/processout/transaction.rb +905 -0
  59. data/lib/processout/transaction_operation.rb +418 -0
  60. data/lib/processout/version.rb +3 -0
  61. data/lib/processout/webhook.rb +237 -0
  62. data/lib/processout/webhook_endpoint.rb +149 -0
  63. data/lib/processout.rb +263 -0
  64. data/processout.gemspec +26 -0
  65. metadata +66 -3
@@ -0,0 +1,81 @@
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 InvoiceTax
10
+
11
+ attr_reader :amount
12
+ attr_reader :rate
13
+
14
+
15
+ def amount=(val)
16
+ @amount = val
17
+ end
18
+
19
+ def rate=(val)
20
+ @rate = val
21
+ end
22
+
23
+
24
+ # Initializes the InvoiceTax object
25
+ # Params:
26
+ # +client+:: +ProcessOut+ client instance
27
+ # +data+:: data that can be used to fill the object
28
+ def initialize(client, data = {})
29
+ @client = client
30
+
31
+ self.amount = data.fetch(:amount, nil)
32
+ self.rate = data.fetch(:rate, nil)
33
+
34
+ end
35
+
36
+ # Create a new InvoiceTax using the current client
37
+ def new(data = {})
38
+ InvoiceTax.new(@client, data)
39
+ end
40
+
41
+ # Overrides the JSON marshaller to only send the fields we want
42
+ def to_json(options)
43
+ {
44
+ "amount": self.amount,
45
+ "rate": self.rate,
46
+ }.to_json
47
+ end
48
+
49
+ # Fills the object with data coming from the API
50
+ # Params:
51
+ # +data+:: +Hash+ of data coming from the API
52
+ def fill_with_data(data)
53
+ if data.nil?
54
+ return self
55
+ end
56
+ if data.include? "amount"
57
+ self.amount = data["amount"]
58
+ end
59
+ if data.include? "rate"
60
+ self.rate = data["rate"]
61
+ end
62
+
63
+ self
64
+ end
65
+
66
+ # Prefills the object with the data passed as parameters
67
+ # Params:
68
+ # +data+:: +Hash+ of data
69
+ def prefill(data)
70
+ if data.nil?
71
+ return self
72
+ end
73
+ self.amount = data.fetch(:amount, self.amount)
74
+ self.rate = data.fetch(:rate, self.rate)
75
+
76
+ self
77
+ end
78
+
79
+
80
+ end
81
+ end
@@ -0,0 +1,102 @@
1
+ require "net/http"
2
+ require "net/https"
3
+ require "json"
4
+
5
+ module ProcessOut
6
+ class Request
7
+ def initialize(client)
8
+ @client = client
9
+ end
10
+
11
+ # ApplyHeaders applies the pre-defined headers to the request
12
+ def apply_headers(req, options)
13
+ req.basic_auth @client.project_id, @client.project_secret
14
+ req.content_type = "application/json"
15
+ req["API-Version"] = "1.4.0.0"
16
+ req["User-Agent"] = "ProcessOut Ruby-Bindings/2.21.0"
17
+
18
+ unless options.nil?
19
+ req["Idempotency-Key"] = options.fetch(:idempotency_key, "")
20
+ req["Disable-Logging"] = options.fetch(:disable_logging, "")
21
+ end
22
+ end
23
+ protected :apply_headers
24
+
25
+ # ComputeData computes the data to be sent in the request
26
+ def compute_data(data, options)
27
+ unless options.nil?
28
+ data["expand"] = options.fetch(:expand, [])
29
+ data["filter"] = options.fetch(:filter, "")
30
+ data["limit"] = options.fetch(:limit, "")
31
+ data["end_before"] = options.fetch(:end_before, "")
32
+ data["start_after"] = options.fetch(:start_after, "")
33
+ end
34
+ data
35
+ end
36
+ protected :compute_data
37
+
38
+ # GET sends a get request to the API
39
+ def get(path, data, options)
40
+ uri = URI(@client.host + path)
41
+ uri.query = URI.encode_www_form(self.compute_data(data, options))
42
+ req = Net::HTTP::Get.new(uri)
43
+ self.apply_headers(req, options)
44
+
45
+ Net::HTTP.start(uri.hostname, uri.port,
46
+ :open_timeout => 5,
47
+ :read_timeout => 65,
48
+ :use_ssl => true) do |http|
49
+
50
+ http.request(req)
51
+ end
52
+ end
53
+
54
+ # POST sends a post request to the API
55
+ def post(path, data, options)
56
+ uri = URI(@client.host + path)
57
+ req = Net::HTTP::Post.new(uri)
58
+ req.body = self.compute_data(data, options).to_json
59
+ self.apply_headers(req, options)
60
+
61
+ Net::HTTP.start(uri.hostname, uri.port,
62
+ :open_timeout => 5,
63
+ :read_timeout => 65,
64
+ :use_ssl => true) do |http|
65
+
66
+ http.request(req)
67
+ end
68
+ end
69
+
70
+ # PUT sends a put request to the API
71
+ def put(path, data, options)
72
+ uri = URI(@client.host + path)
73
+ req = Net::HTTP::Put.new(uri)
74
+ req.body = self.compute_data(data, options).to_json
75
+ self.apply_headers(req, options)
76
+
77
+ Net::HTTP.start(uri.hostname, uri.port,
78
+ :open_timeout => 5,
79
+ :read_timeout => 65,
80
+ :use_ssl => true) do |http|
81
+
82
+ http.request(req)
83
+ end
84
+ end
85
+
86
+ # DELETE sends a delete request to the API
87
+ def delete(path, data, options)
88
+ uri = URI(@client.host + path)
89
+ uri.query = URI.encode_www_form(self.compute_data(data, options))
90
+ req = Net::HTTP::Delete.new(uri)
91
+ self.apply_headers(req, options)
92
+
93
+ Net::HTTP.start(uri.hostname, uri.port,
94
+ :open_timeout => 5,
95
+ :read_timeout => 65,
96
+ :use_ssl => true) do |http|
97
+
98
+ http.request(req)
99
+ end
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,67 @@
1
+ require "net/http"
2
+ require "json"
3
+
4
+ require "processout/errors/authentication_error"
5
+ require "processout/errors/generic_error"
6
+ require "processout/errors/internal_error"
7
+ require "processout/errors/notfound_error"
8
+ require "processout/errors/validation_error"
9
+
10
+ module ProcessOut
11
+ class Response
12
+ attr_reader :body
13
+
14
+ def initialize(resp)
15
+ @resp = resp
16
+ @status = resp.code.to_i
17
+ @body = JSON.parse(resp.body)
18
+ self.check
19
+ end
20
+
21
+ # Success returns whether or not the response returned a successful message
22
+ def success
23
+ if @body.include? "success"
24
+ return @body["success"]
25
+ end
26
+ false
27
+ end
28
+
29
+ # Code returns the error code contained in the response, if any
30
+ def code
31
+ if @body.include? "error_type"
32
+ return @body["error_type"]
33
+ end
34
+ ""
35
+ end
36
+
37
+ # Message returns the error message contained in the response, if any
38
+ def message
39
+ if @body.include? "message"
40
+ return @body["message"]
41
+ end
42
+ ""
43
+ end
44
+
45
+ # Check checks the response didn't contain any error, or raises an
46
+ # error if one was found
47
+ def check
48
+ unless self.success
49
+ if @status == 404
50
+ raise NotFoundError.new(self.code, self.message)
51
+ end
52
+ if @status == 401
53
+ raise AuthenticationError.new(self.code, self.message)
54
+ end
55
+ if @status == 400
56
+ raise ValidationError.new(self.code, self.message)
57
+ end
58
+ if @status >= 500
59
+ raise InternalError.new(self.code, self.message)
60
+ end
61
+
62
+ raise GenericError.new(self.code, self.message)
63
+ end
64
+ end
65
+ protected :check
66
+ end
67
+ end
@@ -0,0 +1,70 @@
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 PaymentDataNetworkAuthentication
10
+
11
+ attr_reader :cavv
12
+
13
+
14
+ def cavv=(val)
15
+ @cavv = val
16
+ end
17
+
18
+
19
+ # Initializes the PaymentDataNetworkAuthentication object
20
+ # Params:
21
+ # +client+:: +ProcessOut+ client instance
22
+ # +data+:: data that can be used to fill the object
23
+ def initialize(client, data = {})
24
+ @client = client
25
+
26
+ self.cavv = data.fetch(:cavv, nil)
27
+
28
+ end
29
+
30
+ # Create a new PaymentDataNetworkAuthentication using the current client
31
+ def new(data = {})
32
+ PaymentDataNetworkAuthentication.new(@client, data)
33
+ end
34
+
35
+ # Overrides the JSON marshaller to only send the fields we want
36
+ def to_json(options)
37
+ {
38
+ "cavv": self.cavv,
39
+ }.to_json
40
+ end
41
+
42
+ # Fills the object with data coming from the API
43
+ # Params:
44
+ # +data+:: +Hash+ of data coming from the API
45
+ def fill_with_data(data)
46
+ if data.nil?
47
+ return self
48
+ end
49
+ if data.include? "cavv"
50
+ self.cavv = data["cavv"]
51
+ end
52
+
53
+ self
54
+ end
55
+
56
+ # Prefills the object with the data passed as parameters
57
+ # Params:
58
+ # +data+:: +Hash+ of data
59
+ def prefill(data)
60
+ if data.nil?
61
+ return self
62
+ end
63
+ self.cavv = data.fetch(:cavv, self.cavv)
64
+
65
+ self
66
+ end
67
+
68
+
69
+ end
70
+ end
@@ -0,0 +1,70 @@
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 PaymentDataThreeDSAuthentication
10
+
11
+ attr_reader :xid
12
+
13
+
14
+ def xid=(val)
15
+ @xid = val
16
+ end
17
+
18
+
19
+ # Initializes the PaymentDataThreeDSAuthentication object
20
+ # Params:
21
+ # +client+:: +ProcessOut+ client instance
22
+ # +data+:: data that can be used to fill the object
23
+ def initialize(client, data = {})
24
+ @client = client
25
+
26
+ self.xid = data.fetch(:xid, nil)
27
+
28
+ end
29
+
30
+ # Create a new PaymentDataThreeDSAuthentication using the current client
31
+ def new(data = {})
32
+ PaymentDataThreeDSAuthentication.new(@client, data)
33
+ end
34
+
35
+ # Overrides the JSON marshaller to only send the fields we want
36
+ def to_json(options)
37
+ {
38
+ "XID": self.xid,
39
+ }.to_json
40
+ end
41
+
42
+ # Fills the object with data coming from the API
43
+ # Params:
44
+ # +data+:: +Hash+ of data coming from the API
45
+ def fill_with_data(data)
46
+ if data.nil?
47
+ return self
48
+ end
49
+ if data.include? "XID"
50
+ self.xid = data["XID"]
51
+ end
52
+
53
+ self
54
+ end
55
+
56
+ # Prefills the object with the data passed as parameters
57
+ # Params:
58
+ # +data+:: +Hash+ of data
59
+ def prefill(data)
60
+ if data.nil?
61
+ return self
62
+ end
63
+ self.xid = data.fetch(:xid, self.xid)
64
+
65
+ self
66
+ end
67
+
68
+
69
+ end
70
+ end
@@ -0,0 +1,103 @@
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 PaymentDataThreeDSRequest
10
+
11
+ attr_reader :acs_url
12
+ attr_reader :pareq
13
+ attr_reader :md
14
+ attr_reader :term_url
15
+
16
+
17
+ def acs_url=(val)
18
+ @acs_url = val
19
+ end
20
+
21
+ def pareq=(val)
22
+ @pareq = val
23
+ end
24
+
25
+ def md=(val)
26
+ @md = val
27
+ end
28
+
29
+ def term_url=(val)
30
+ @term_url = val
31
+ end
32
+
33
+
34
+ # Initializes the PaymentDataThreeDSRequest object
35
+ # Params:
36
+ # +client+:: +ProcessOut+ client instance
37
+ # +data+:: data that can be used to fill the object
38
+ def initialize(client, data = {})
39
+ @client = client
40
+
41
+ self.acs_url = data.fetch(:acs_url, nil)
42
+ self.pareq = data.fetch(:pareq, nil)
43
+ self.md = data.fetch(:md, nil)
44
+ self.term_url = data.fetch(:term_url, nil)
45
+
46
+ end
47
+
48
+ # Create a new PaymentDataThreeDSRequest using the current client
49
+ def new(data = {})
50
+ PaymentDataThreeDSRequest.new(@client, data)
51
+ end
52
+
53
+ # Overrides the JSON marshaller to only send the fields we want
54
+ def to_json(options)
55
+ {
56
+ "acs_url": self.acs_url,
57
+ "pareq": self.pareq,
58
+ "md": self.md,
59
+ "term_url": self.term_url,
60
+ }.to_json
61
+ end
62
+
63
+ # Fills the object with data coming from the API
64
+ # Params:
65
+ # +data+:: +Hash+ of data coming from the API
66
+ def fill_with_data(data)
67
+ if data.nil?
68
+ return self
69
+ end
70
+ if data.include? "acs_url"
71
+ self.acs_url = data["acs_url"]
72
+ end
73
+ if data.include? "pareq"
74
+ self.pareq = data["pareq"]
75
+ end
76
+ if data.include? "md"
77
+ self.md = data["md"]
78
+ end
79
+ if data.include? "term_url"
80
+ self.term_url = data["term_url"]
81
+ end
82
+
83
+ self
84
+ end
85
+
86
+ # Prefills the object with the data passed as parameters
87
+ # Params:
88
+ # +data+:: +Hash+ of data
89
+ def prefill(data)
90
+ if data.nil?
91
+ return self
92
+ end
93
+ self.acs_url = data.fetch(:acs_url, self.acs_url)
94
+ self.pareq = data.fetch(:pareq, self.pareq)
95
+ self.md = data.fetch(:md, self.md)
96
+ self.term_url = data.fetch(:term_url, self.term_url)
97
+
98
+ self
99
+ end
100
+
101
+
102
+ end
103
+ end