onlinepayments-sdk-ruby 4.16.0 → 4.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/onlinepayments/sdk/communicator.rb +10 -2
- data/lib/onlinepayments/sdk/defaultimpl/default_connection.rb +75 -9
- data/lib/onlinepayments/sdk/domain/acquirer_information.rb +8 -0
- data/lib/onlinepayments/sdk/domain/acquirer_selection_information.rb +34 -0
- data/lib/onlinepayments/sdk/domain/create_hosted_tokenization_request.rb +8 -0
- data/lib/onlinepayments/sdk/domain/create_payment_link_request.rb +3 -3
- data/lib/onlinepayments/sdk/domain/credit_card_specific_input_hosted_tokenization.rb +30 -0
- data/lib/onlinepayments/sdk/domain/credit_card_validation_rules_hosted_tokenization.rb +30 -0
- data/lib/onlinepayments/sdk/domain/discount.rb +26 -0
- data/lib/onlinepayments/sdk/domain/order.rb +8 -0
- data/lib/onlinepayments/sdk/domain/{payment_link_order.rb → payment_link_order_input.rb} +1 -1
- data/lib/onlinepayments/sdk/domain/payment_link_order_output.rb +34 -0
- data/lib/onlinepayments/sdk/domain/payment_link_response.rb +3 -3
- data/lib/onlinepayments/sdk/multipart_form_data_object.rb +44 -0
- data/lib/onlinepayments/sdk/multipart_form_data_request.rb +9 -0
- data/lib/onlinepayments/sdk/uploadable_file.rb +30 -0
- data/onlinepayments-sdk-ruby.gemspec +1 -1
- metadata +11 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f1aab6a893b021fd2acde88f65013a106b27c4162a8a22c296226861e4ea3163
|
4
|
+
data.tar.gz: 1d40d4e758bc1b80f9d37e037784a8e8bcc75fea8f1ab921d276749abb084317
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7d5ae1806549be6c3759e3b29f8205a307d3f251bdd60a9f13559fd9ba9b8074aaf34bfef35e310f1fed429a2c0e4ad51a7fcde5c070fce7fedd1bc6ebdf4516
|
7
|
+
data.tar.gz: 39730866a212efbb6322d24a46425a39a51ffcde6f01bee86b672384b638ca69b69c869b8a7bfc35a1541f484f2cfed12e3076fe04c05e7284785eee072e135d
|
@@ -104,7 +104,8 @@ module OnlinePayments::SDK
|
|
104
104
|
# @param relative_path [String] Path relative to the API endpoint
|
105
105
|
# @param request_headers [Array<OnlinePayments::SDK::RequestHeader>, nil] Optional array of request headers
|
106
106
|
# @param request_parameters [OnlinePayments::SDK::ParamRequest, nil] Optional request parameters
|
107
|
-
# @param request_body [OnlinePayments::SDK::DataObject
|
107
|
+
# @param request_body [OnlinePayments::SDK::DataObject, OnlinePayments::SDK::MultipartFormDataObject, OnlinePayments::SDK::MultipartFormDataRequest]
|
108
|
+
# The optional request body
|
108
109
|
# @param response_type [Type] The response type.
|
109
110
|
# @param context [OnlinePayments::SDK::CallContext, nil] Optional call context.
|
110
111
|
# @return The response of the POST request as the given response type
|
@@ -119,7 +120,14 @@ module OnlinePayments::SDK
|
|
119
120
|
request_headers ||= []
|
120
121
|
|
121
122
|
body = nil
|
122
|
-
if request_body
|
123
|
+
if request_body.is_a? MultipartFormDataObject
|
124
|
+
request_headers.push(RequestHeader.new('Content-Type', request_body.content_type))
|
125
|
+
body = request_body
|
126
|
+
elsif request_body.is_a? MultipartFormDataRequest
|
127
|
+
multipart = request_body.to_multipart_form_data_object
|
128
|
+
request_headers.push(RequestHeader.new('Content-Type', multipart.content_type))
|
129
|
+
body = multipart
|
130
|
+
elsif request_body
|
123
131
|
request_headers.push(RequestHeader.new('Content-Type', 'application/json'))
|
124
132
|
body = @marshaller.marshal(request_body)
|
125
133
|
else
|
@@ -19,6 +19,7 @@ module OnlinePayments::SDK
|
|
19
19
|
using RefineHTTPClient
|
20
20
|
|
21
21
|
CONTENT_TYPE = 'Content-Type'.freeze
|
22
|
+
X_REQUEST_ID_HEADER = 'X-Request-Id'.freeze
|
22
23
|
JSON_CONTENT_TYPE = 'application/json'.freeze
|
23
24
|
|
24
25
|
# @param args [Hash] the parameters to initialize the connection with
|
@@ -144,12 +145,16 @@ module OnlinePayments::SDK
|
|
144
145
|
# @param method [String] 'GET', 'DELETE', 'POST' or 'PUT' depending on the HTTP method being used.
|
145
146
|
# @param uri [URI::HTTP] full URI of the location the request is targeted at, including query parameters.
|
146
147
|
# @param request_headers [Array<OnlinePayments::SDK::RequestHeader>] list of headers that should be used as HTTP headers in the request.
|
147
|
-
# @param body [String] request body.
|
148
|
+
# @param body [String, OnlinePayments::SDK::MultipartFormDataObject] request body.
|
148
149
|
# @yield (Integer, Array<OnlinePayments::SDK::ResponseHeader>, IO) The status code, headers and body of the response.
|
149
150
|
# @raise [OnlinePayments::SDK::CommunicationException] when communication with the Online Payments platform was not successful.
|
150
151
|
def request(method, uri, request_headers, body = nil)
|
151
152
|
request_headers = convert_from_headers(request_headers)
|
152
153
|
request_id = SecureRandom.uuid
|
154
|
+
|
155
|
+
# set X-Request-Id for better traceability
|
156
|
+
request_headers[X_REQUEST_ID_HEADER] = request_id
|
157
|
+
|
153
158
|
content_type = request_headers[CONTENT_TYPE]
|
154
159
|
|
155
160
|
info = { headers: request_headers, content_type: content_type }
|
@@ -163,14 +168,29 @@ module OnlinePayments::SDK
|
|
163
168
|
response_status_code = nil
|
164
169
|
response_content_type = nil
|
165
170
|
response_body = ''
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
171
|
+
|
172
|
+
if body.is_a? OnlinePayments::SDK::MultipartFormDataObject
|
173
|
+
multipart_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|
|
174
|
+
response_headers = headers
|
175
|
+
response_status_code = status_code
|
176
|
+
response_content_type = r_content_type
|
177
|
+
unless binary_content_type? response_content_type
|
178
|
+
response_body = r_body.read.force_encoding('UTF-8')
|
179
|
+
r_body = StringIO.new(response_body)
|
180
|
+
end
|
181
|
+
|
182
|
+
yield status_code, headers, r_body
|
183
|
+
end
|
184
|
+
else
|
185
|
+
raw_request(method, uri, request_headers, body) do |status_code, headers, r_content_type, r_body|
|
186
|
+
response_headers = headers
|
187
|
+
response_status_code = status_code
|
188
|
+
response_content_type = r_content_type
|
189
|
+
response_body = r_body.read.force_encoding('UTF-8')
|
190
|
+
r_body = StringIO.new(response_body)
|
191
|
+
|
192
|
+
yield status_code, headers, r_body
|
193
|
+
end
|
174
194
|
end
|
175
195
|
|
176
196
|
log_response(request_id, response_status_code, start_time,
|
@@ -290,6 +310,52 @@ module OnlinePayments::SDK
|
|
290
310
|
pipe.close
|
291
311
|
end
|
292
312
|
end
|
313
|
+
|
314
|
+
# Makes a request using the specified method
|
315
|
+
#
|
316
|
+
# Yields a status code, an array of {OnlinePayments::SDK::ResponseHeader},
|
317
|
+
# the content_type and body
|
318
|
+
def multipart_request(method, uri, headers, body = nil)
|
319
|
+
unless body.is_a? OnlinePayments::SDK::MultipartFormDataObject
|
320
|
+
raise ArgumentError, 'body should be a MultipartFormDataObject'
|
321
|
+
end
|
322
|
+
|
323
|
+
if method != 'post' && method != 'put'
|
324
|
+
raise ArgumentError, "method #{method} is not supported"
|
325
|
+
end
|
326
|
+
|
327
|
+
connection = @http_client.send method + '_async',
|
328
|
+
uri,
|
329
|
+
body: multipart_request_body(body),
|
330
|
+
header: headers
|
331
|
+
|
332
|
+
response = connection.pop
|
333
|
+
pipe = response.content
|
334
|
+
response_headers = convert_to_sdk_response_headers(response.headers)
|
335
|
+
|
336
|
+
begin
|
337
|
+
yield response.status_code, response_headers, response.content_type, pipe
|
338
|
+
ensure
|
339
|
+
pipe.close
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
# Creates a request body for the multipart request
|
344
|
+
def multipart_request_body( body )
|
345
|
+
request_body = []
|
346
|
+
body.files.each do |k, v|
|
347
|
+
request_body.push :content => v.content,
|
348
|
+
'Content-Type' => v.content_type,
|
349
|
+
'Content-Disposition' => "form-data; name=\"#{k}\"; filename=\"#{v.file_name}\"",
|
350
|
+
'Content-Transfer-Encoding' => 'binary'
|
351
|
+
end
|
352
|
+
|
353
|
+
body.values.each do |k, v|
|
354
|
+
request_body << { :content => v,
|
355
|
+
'Content-Disposition' => "form-data; name=\"#{k}\"" }
|
356
|
+
end
|
357
|
+
request_body
|
358
|
+
end
|
293
359
|
end
|
294
360
|
end
|
295
361
|
end
|
@@ -2,23 +2,31 @@
|
|
2
2
|
# This class was auto-generated.
|
3
3
|
#
|
4
4
|
require 'onlinepayments/sdk/data_object'
|
5
|
+
require 'onlinepayments/sdk/domain/acquirer_selection_information'
|
5
6
|
|
6
7
|
module OnlinePayments::SDK
|
7
8
|
module Domain
|
8
9
|
|
10
|
+
# @attr [OnlinePayments::SDK::Domain::AcquirerSelectionInformation] acquirer_selection_information
|
9
11
|
# @attr [String] name
|
10
12
|
class AcquirerInformation < OnlinePayments::SDK::DataObject
|
13
|
+
attr_accessor :acquirer_selection_information
|
11
14
|
attr_accessor :name
|
12
15
|
|
13
16
|
# @return (Hash)
|
14
17
|
def to_h
|
15
18
|
hash = super
|
19
|
+
hash['acquirerSelectionInformation'] = @acquirer_selection_information.to_h if @acquirer_selection_information
|
16
20
|
hash['name'] = @name unless @name.nil?
|
17
21
|
hash
|
18
22
|
end
|
19
23
|
|
20
24
|
def from_hash(hash)
|
21
25
|
super
|
26
|
+
if hash.key? 'acquirerSelectionInformation'
|
27
|
+
raise TypeError, "value '%s' is not a Hash" % [hash['acquirerSelectionInformation']] unless hash['acquirerSelectionInformation'].is_a? Hash
|
28
|
+
@acquirer_selection_information = OnlinePayments::SDK::Domain::AcquirerSelectionInformation.new_from_hash(hash['acquirerSelectionInformation'])
|
29
|
+
end
|
22
30
|
@name = hash['name'] if hash.key? 'name'
|
23
31
|
end
|
24
32
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# This class was auto-generated.
|
3
|
+
#
|
4
|
+
require 'onlinepayments/sdk/data_object'
|
5
|
+
|
6
|
+
module OnlinePayments::SDK
|
7
|
+
module Domain
|
8
|
+
|
9
|
+
# @attr [Integer] fallback_level
|
10
|
+
# @attr [String] result
|
11
|
+
# @attr [String] rule_name
|
12
|
+
class AcquirerSelectionInformation < OnlinePayments::SDK::DataObject
|
13
|
+
attr_accessor :fallback_level
|
14
|
+
attr_accessor :result
|
15
|
+
attr_accessor :rule_name
|
16
|
+
|
17
|
+
# @return (Hash)
|
18
|
+
def to_h
|
19
|
+
hash = super
|
20
|
+
hash['fallbackLevel'] = @fallback_level unless @fallback_level.nil?
|
21
|
+
hash['result'] = @result unless @result.nil?
|
22
|
+
hash['ruleName'] = @rule_name unless @rule_name.nil?
|
23
|
+
hash
|
24
|
+
end
|
25
|
+
|
26
|
+
def from_hash(hash)
|
27
|
+
super
|
28
|
+
@fallback_level = hash['fallbackLevel'] if hash.key? 'fallbackLevel'
|
29
|
+
@result = hash['result'] if hash.key? 'result'
|
30
|
+
@rule_name = hash['ruleName'] if hash.key? 'ruleName'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -2,18 +2,21 @@
|
|
2
2
|
# This class was auto-generated.
|
3
3
|
#
|
4
4
|
require 'onlinepayments/sdk/data_object'
|
5
|
+
require 'onlinepayments/sdk/domain/credit_card_specific_input_hosted_tokenization'
|
5
6
|
require 'onlinepayments/sdk/domain/payment_product_filters_hosted_tokenization'
|
6
7
|
|
7
8
|
module OnlinePayments::SDK
|
8
9
|
module Domain
|
9
10
|
|
10
11
|
# @attr [true/false] ask_consumer_consent
|
12
|
+
# @attr [OnlinePayments::SDK::Domain::CreditCardSpecificInputHostedTokenization] credit_card_specific_input
|
11
13
|
# @attr [String] locale
|
12
14
|
# @attr [OnlinePayments::SDK::Domain::PaymentProductFiltersHostedTokenization] payment_product_filters
|
13
15
|
# @attr [String] tokens
|
14
16
|
# @attr [String] variant
|
15
17
|
class CreateHostedTokenizationRequest < OnlinePayments::SDK::DataObject
|
16
18
|
attr_accessor :ask_consumer_consent
|
19
|
+
attr_accessor :credit_card_specific_input
|
17
20
|
attr_accessor :locale
|
18
21
|
attr_accessor :payment_product_filters
|
19
22
|
attr_accessor :tokens
|
@@ -23,6 +26,7 @@ module OnlinePayments::SDK
|
|
23
26
|
def to_h
|
24
27
|
hash = super
|
25
28
|
hash['askConsumerConsent'] = @ask_consumer_consent unless @ask_consumer_consent.nil?
|
29
|
+
hash['creditCardSpecificInput'] = @credit_card_specific_input.to_h if @credit_card_specific_input
|
26
30
|
hash['locale'] = @locale unless @locale.nil?
|
27
31
|
hash['paymentProductFilters'] = @payment_product_filters.to_h if @payment_product_filters
|
28
32
|
hash['tokens'] = @tokens unless @tokens.nil?
|
@@ -33,6 +37,10 @@ module OnlinePayments::SDK
|
|
33
37
|
def from_hash(hash)
|
34
38
|
super
|
35
39
|
@ask_consumer_consent = hash['askConsumerConsent'] if hash.key? 'askConsumerConsent'
|
40
|
+
if hash.key? 'creditCardSpecificInput'
|
41
|
+
raise TypeError, "value '%s' is not a Hash" % [hash['creditCardSpecificInput']] unless hash['creditCardSpecificInput'].is_a? Hash
|
42
|
+
@credit_card_specific_input = OnlinePayments::SDK::Domain::CreditCardSpecificInputHostedTokenization.new_from_hash(hash['creditCardSpecificInput'])
|
43
|
+
end
|
36
44
|
@locale = hash['locale'] if hash.key? 'locale'
|
37
45
|
if hash.key? 'paymentProductFilters'
|
38
46
|
raise TypeError, "value '%s' is not a Hash" % [hash['paymentProductFilters']] unless hash['paymentProductFilters'].is_a? Hash
|
@@ -2,14 +2,14 @@
|
|
2
2
|
# This class was auto-generated.
|
3
3
|
#
|
4
4
|
require 'onlinepayments/sdk/data_object'
|
5
|
-
require 'onlinepayments/sdk/domain/
|
5
|
+
require 'onlinepayments/sdk/domain/payment_link_order_input'
|
6
6
|
|
7
7
|
module OnlinePayments::SDK
|
8
8
|
module Domain
|
9
9
|
|
10
10
|
# @attr [String] description
|
11
11
|
# @attr [String] expiration_date
|
12
|
-
# @attr [OnlinePayments::SDK::Domain::
|
12
|
+
# @attr [OnlinePayments::SDK::Domain::PaymentLinkOrderInput] payment_link_order
|
13
13
|
# @attr [String] recipient_name
|
14
14
|
class CreatePaymentLinkRequest < OnlinePayments::SDK::DataObject
|
15
15
|
attr_accessor :description
|
@@ -33,7 +33,7 @@ module OnlinePayments::SDK
|
|
33
33
|
@expiration_date = hash['expirationDate'] if hash.key? 'expirationDate'
|
34
34
|
if hash.key? 'paymentLinkOrder'
|
35
35
|
raise TypeError, "value '%s' is not a Hash" % [hash['paymentLinkOrder']] unless hash['paymentLinkOrder'].is_a? Hash
|
36
|
-
@payment_link_order = OnlinePayments::SDK::Domain::
|
36
|
+
@payment_link_order = OnlinePayments::SDK::Domain::PaymentLinkOrderInput.new_from_hash(hash['paymentLinkOrder'])
|
37
37
|
end
|
38
38
|
@recipient_name = hash['recipientName'] if hash.key? 'recipientName'
|
39
39
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# This class was auto-generated.
|
3
|
+
#
|
4
|
+
require 'onlinepayments/sdk/data_object'
|
5
|
+
require 'onlinepayments/sdk/domain/credit_card_validation_rules_hosted_tokenization'
|
6
|
+
|
7
|
+
module OnlinePayments::SDK
|
8
|
+
module Domain
|
9
|
+
|
10
|
+
# @attr [OnlinePayments::SDK::Domain::CreditCardValidationRulesHostedTokenization] validation_rules
|
11
|
+
class CreditCardSpecificInputHostedTokenization < OnlinePayments::SDK::DataObject
|
12
|
+
attr_accessor :validation_rules
|
13
|
+
|
14
|
+
# @return (Hash)
|
15
|
+
def to_h
|
16
|
+
hash = super
|
17
|
+
hash['ValidationRules'] = @validation_rules.to_h if @validation_rules
|
18
|
+
hash
|
19
|
+
end
|
20
|
+
|
21
|
+
def from_hash(hash)
|
22
|
+
super
|
23
|
+
if hash.key? 'ValidationRules'
|
24
|
+
raise TypeError, "value '%s' is not a Hash" % [hash['ValidationRules']] unless hash['ValidationRules'].is_a? Hash
|
25
|
+
@validation_rules = OnlinePayments::SDK::Domain::CreditCardValidationRulesHostedTokenization.new_from_hash(hash['ValidationRules'])
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#
|
2
|
+
# This class was auto-generated.
|
3
|
+
#
|
4
|
+
require 'onlinepayments/sdk/data_object'
|
5
|
+
|
6
|
+
module OnlinePayments::SDK
|
7
|
+
module Domain
|
8
|
+
|
9
|
+
# @attr [true/false] cvv_mandatory_for_existing_token
|
10
|
+
# @attr [true/false] cvv_mandatory_for_new_token
|
11
|
+
class CreditCardValidationRulesHostedTokenization < OnlinePayments::SDK::DataObject
|
12
|
+
attr_accessor :cvv_mandatory_for_existing_token
|
13
|
+
attr_accessor :cvv_mandatory_for_new_token
|
14
|
+
|
15
|
+
# @return (Hash)
|
16
|
+
def to_h
|
17
|
+
hash = super
|
18
|
+
hash['cvvMandatoryForExistingToken'] = @cvv_mandatory_for_existing_token unless @cvv_mandatory_for_existing_token.nil?
|
19
|
+
hash['cvvMandatoryForNewToken'] = @cvv_mandatory_for_new_token unless @cvv_mandatory_for_new_token.nil?
|
20
|
+
hash
|
21
|
+
end
|
22
|
+
|
23
|
+
def from_hash(hash)
|
24
|
+
super
|
25
|
+
@cvv_mandatory_for_existing_token = hash['cvvMandatoryForExistingToken'] if hash.key? 'cvvMandatoryForExistingToken'
|
26
|
+
@cvv_mandatory_for_new_token = hash['cvvMandatoryForNewToken'] if hash.key? 'cvvMandatoryForNewToken'
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
#
|
2
|
+
# This class was auto-generated.
|
3
|
+
#
|
4
|
+
require 'onlinepayments/sdk/data_object'
|
5
|
+
|
6
|
+
module OnlinePayments::SDK
|
7
|
+
module Domain
|
8
|
+
|
9
|
+
# @attr [Long] amount
|
10
|
+
class Discount < OnlinePayments::SDK::DataObject
|
11
|
+
attr_accessor :amount
|
12
|
+
|
13
|
+
# @return (Hash)
|
14
|
+
def to_h
|
15
|
+
hash = super
|
16
|
+
hash['amount'] = @amount unless @amount.nil?
|
17
|
+
hash
|
18
|
+
end
|
19
|
+
|
20
|
+
def from_hash(hash)
|
21
|
+
super
|
22
|
+
@amount = hash['amount'] if hash.key? 'amount'
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -5,6 +5,7 @@ require 'onlinepayments/sdk/data_object'
|
|
5
5
|
require 'onlinepayments/sdk/domain/additional_order_input'
|
6
6
|
require 'onlinepayments/sdk/domain/amount_of_money'
|
7
7
|
require 'onlinepayments/sdk/domain/customer'
|
8
|
+
require 'onlinepayments/sdk/domain/discount'
|
8
9
|
require 'onlinepayments/sdk/domain/order_references'
|
9
10
|
require 'onlinepayments/sdk/domain/shipping'
|
10
11
|
require 'onlinepayments/sdk/domain/shopping_cart'
|
@@ -16,6 +17,7 @@ module OnlinePayments::SDK
|
|
16
17
|
# @attr [OnlinePayments::SDK::Domain::AdditionalOrderInput] additional_input
|
17
18
|
# @attr [OnlinePayments::SDK::Domain::AmountOfMoney] amount_of_money
|
18
19
|
# @attr [OnlinePayments::SDK::Domain::Customer] customer
|
20
|
+
# @attr [OnlinePayments::SDK::Domain::Discount] discount
|
19
21
|
# @attr [OnlinePayments::SDK::Domain::OrderReferences] references
|
20
22
|
# @attr [OnlinePayments::SDK::Domain::Shipping] shipping
|
21
23
|
# @attr [OnlinePayments::SDK::Domain::ShoppingCart] shopping_cart
|
@@ -24,6 +26,7 @@ module OnlinePayments::SDK
|
|
24
26
|
attr_accessor :additional_input
|
25
27
|
attr_accessor :amount_of_money
|
26
28
|
attr_accessor :customer
|
29
|
+
attr_accessor :discount
|
27
30
|
attr_accessor :references
|
28
31
|
attr_accessor :shipping
|
29
32
|
attr_accessor :shopping_cart
|
@@ -35,6 +38,7 @@ module OnlinePayments::SDK
|
|
35
38
|
hash['additionalInput'] = @additional_input.to_h if @additional_input
|
36
39
|
hash['amountOfMoney'] = @amount_of_money.to_h if @amount_of_money
|
37
40
|
hash['customer'] = @customer.to_h if @customer
|
41
|
+
hash['discount'] = @discount.to_h if @discount
|
38
42
|
hash['references'] = @references.to_h if @references
|
39
43
|
hash['shipping'] = @shipping.to_h if @shipping
|
40
44
|
hash['shoppingCart'] = @shopping_cart.to_h if @shopping_cart
|
@@ -56,6 +60,10 @@ module OnlinePayments::SDK
|
|
56
60
|
raise TypeError, "value '%s' is not a Hash" % [hash['customer']] unless hash['customer'].is_a? Hash
|
57
61
|
@customer = OnlinePayments::SDK::Domain::Customer.new_from_hash(hash['customer'])
|
58
62
|
end
|
63
|
+
if hash.key? 'discount'
|
64
|
+
raise TypeError, "value '%s' is not a Hash" % [hash['discount']] unless hash['discount'].is_a? Hash
|
65
|
+
@discount = OnlinePayments::SDK::Domain::Discount.new_from_hash(hash['discount'])
|
66
|
+
end
|
59
67
|
if hash.key? 'references'
|
60
68
|
raise TypeError, "value '%s' is not a Hash" % [hash['references']] unless hash['references'].is_a? Hash
|
61
69
|
@references = OnlinePayments::SDK::Domain::OrderReferences.new_from_hash(hash['references'])
|
@@ -9,7 +9,7 @@ module OnlinePayments::SDK
|
|
9
9
|
|
10
10
|
# @attr [OnlinePayments::SDK::Domain::AmountOfMoney] amount
|
11
11
|
# @attr [String] merchant_reference
|
12
|
-
class
|
12
|
+
class PaymentLinkOrderInput < OnlinePayments::SDK::DataObject
|
13
13
|
attr_accessor :amount
|
14
14
|
attr_accessor :merchant_reference
|
15
15
|
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#
|
2
|
+
# This class was auto-generated.
|
3
|
+
#
|
4
|
+
require 'onlinepayments/sdk/data_object'
|
5
|
+
require 'onlinepayments/sdk/domain/amount_of_money'
|
6
|
+
|
7
|
+
module OnlinePayments::SDK
|
8
|
+
module Domain
|
9
|
+
|
10
|
+
# @attr [OnlinePayments::SDK::Domain::AmountOfMoney] amount
|
11
|
+
# @attr [String] merchant_reference
|
12
|
+
class PaymentLinkOrderOutput < OnlinePayments::SDK::DataObject
|
13
|
+
attr_accessor :amount
|
14
|
+
attr_accessor :merchant_reference
|
15
|
+
|
16
|
+
# @return (Hash)
|
17
|
+
def to_h
|
18
|
+
hash = super
|
19
|
+
hash['amount'] = @amount.to_h if @amount
|
20
|
+
hash['merchantReference'] = @merchant_reference unless @merchant_reference.nil?
|
21
|
+
hash
|
22
|
+
end
|
23
|
+
|
24
|
+
def from_hash(hash)
|
25
|
+
super
|
26
|
+
if hash.key? 'amount'
|
27
|
+
raise TypeError, "value '%s' is not a Hash" % [hash['amount']] unless hash['amount'].is_a? Hash
|
28
|
+
@amount = OnlinePayments::SDK::Domain::AmountOfMoney.new_from_hash(hash['amount'])
|
29
|
+
end
|
30
|
+
@merchant_reference = hash['merchantReference'] if hash.key? 'merchantReference'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#
|
4
4
|
require 'onlinepayments/sdk/data_object'
|
5
5
|
require 'onlinepayments/sdk/domain/payment_link_event'
|
6
|
-
require 'onlinepayments/sdk/domain/
|
6
|
+
require 'onlinepayments/sdk/domain/payment_link_order_output'
|
7
7
|
|
8
8
|
module OnlinePayments::SDK
|
9
9
|
module Domain
|
@@ -12,7 +12,7 @@ module OnlinePayments::SDK
|
|
12
12
|
# @attr [String] payment_id
|
13
13
|
# @attr [Array<OnlinePayments::SDK::Domain::PaymentLinkEvent>] payment_link_events
|
14
14
|
# @attr [String] payment_link_id
|
15
|
-
# @attr [OnlinePayments::SDK::Domain::
|
15
|
+
# @attr [OnlinePayments::SDK::Domain::PaymentLinkOrderOutput] payment_link_order
|
16
16
|
# @attr [String] recipient_name
|
17
17
|
# @attr [String] redirection_url
|
18
18
|
# @attr [String] status
|
@@ -54,7 +54,7 @@ module OnlinePayments::SDK
|
|
54
54
|
@payment_link_id = hash['paymentLinkId'] if hash.key? 'paymentLinkId'
|
55
55
|
if hash.key? 'paymentLinkOrder'
|
56
56
|
raise TypeError, "value '%s' is not a Hash" % [hash['paymentLinkOrder']] unless hash['paymentLinkOrder'].is_a? Hash
|
57
|
-
@payment_link_order = OnlinePayments::SDK::Domain::
|
57
|
+
@payment_link_order = OnlinePayments::SDK::Domain::PaymentLinkOrderOutput.new_from_hash(hash['paymentLinkOrder'])
|
58
58
|
end
|
59
59
|
@recipient_name = hash['recipientName'] if hash.key? 'recipientName'
|
60
60
|
@redirection_url = hash['redirectionUrl'] if hash.key? 'redirectionUrl'
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module OnlinePayments::SDK
|
4
|
+
|
5
|
+
# A representation of a multipart/form-data object
|
6
|
+
class MultipartFormDataObject
|
7
|
+
def initialize
|
8
|
+
@boundary = SecureRandom.uuid
|
9
|
+
@content_type = 'multipart/form-data; boundary=' + @boundary
|
10
|
+
@values = {}
|
11
|
+
@files = {}
|
12
|
+
end
|
13
|
+
|
14
|
+
attr_reader :boundary
|
15
|
+
attr_reader :content_type
|
16
|
+
attr_reader :values
|
17
|
+
attr_reader :files
|
18
|
+
|
19
|
+
def add_value(parameter_name, value)
|
20
|
+
if parameter_name.nil? || parameter_name.strip.empty?
|
21
|
+
raise ArgumentError, 'parameter_name is required'
|
22
|
+
end
|
23
|
+
raise ArgumentError, 'value is required' if value.nil?
|
24
|
+
if @values.include?(parameter_name) || @files.include?(parameter_name)
|
25
|
+
raise ArgumentError, 'duplicate parameterName: ' + parameter_name
|
26
|
+
end
|
27
|
+
|
28
|
+
@values[parameter_name] = value
|
29
|
+
end
|
30
|
+
|
31
|
+
# Adds a file to the multipart Form Data Object
|
32
|
+
def add_file(parameter_name, uploadable_file)
|
33
|
+
if parameter_name.nil? || parameter_name.strip.empty?
|
34
|
+
raise ArgumentError, 'parameter_name is required'
|
35
|
+
end
|
36
|
+
raise ArgumentError, 'uploadable_file is required' if uploadable_file.nil?
|
37
|
+
if @values.include?(parameter_name) || @files.include?(parameter_name)
|
38
|
+
raise ArgumentError, 'duplicate parameterName: ' + parameter_name
|
39
|
+
end
|
40
|
+
|
41
|
+
@files[parameter_name] = uploadable_file
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module OnlinePayments::SDK
|
2
|
+
|
3
|
+
# A file that can be uploaded
|
4
|
+
#
|
5
|
+
# The allowed forms of content are defined by the Connection implementation
|
6
|
+
# The default implementation supports file paths and IO objects.
|
7
|
+
#
|
8
|
+
# @attr_reader [String] file_name The name of the file.
|
9
|
+
# @attr_reader [String, IO] content The file's content.
|
10
|
+
# @attr_reader [String] content_type The file's content type.
|
11
|
+
# @attr_reader [Integer] content_length The file's content length, or -1 if not known.
|
12
|
+
class UploadableFile
|
13
|
+
|
14
|
+
def initialize(file_name, content, content_type, content_length=-1)
|
15
|
+
raise ArgumentError.new("file_name is required") if file_name.nil? or !file_name.strip
|
16
|
+
raise ArgumentError.new("content is required") if content.nil?
|
17
|
+
raise ArgumentError.new("content_type is required") if content_type.nil? or !content_type.strip
|
18
|
+
|
19
|
+
@file_name = file_name
|
20
|
+
@content = content
|
21
|
+
@content_type = content_type
|
22
|
+
@content_length = [content_length, -1].max
|
23
|
+
end
|
24
|
+
|
25
|
+
attr_reader :file_name
|
26
|
+
attr_reader :content
|
27
|
+
attr_reader :content_type
|
28
|
+
attr_reader :content_length
|
29
|
+
end
|
30
|
+
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = 'onlinepayments-sdk-ruby'
|
3
|
-
spec.version = '4.
|
3
|
+
spec.version = '4.18.0'
|
4
4
|
spec.authors = ['Worldline Direct support team']
|
5
5
|
spec.email = ['82139942+worldline-direct-support-team@users.noreply.github.com']
|
6
6
|
spec.summary = %q{SDK to communicate with the Online Payments platform using the Online Payments Server API}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onlinepayments-sdk-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Worldline Direct support team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: httpclient
|
@@ -151,6 +151,7 @@ files:
|
|
151
151
|
- lib/onlinepayments/sdk/domain/account_on_file_attribute.rb
|
152
152
|
- lib/onlinepayments/sdk/domain/account_on_file_display_hints.rb
|
153
153
|
- lib/onlinepayments/sdk/domain/acquirer_information.rb
|
154
|
+
- lib/onlinepayments/sdk/domain/acquirer_selection_information.rb
|
154
155
|
- lib/onlinepayments/sdk/domain/additional_order_input.rb
|
155
156
|
- lib/onlinepayments/sdk/domain/address.rb
|
156
157
|
- lib/onlinepayments/sdk/domain/address_personal.rb
|
@@ -203,6 +204,8 @@ files:
|
|
203
204
|
- lib/onlinepayments/sdk/domain/create_token_request.rb
|
204
205
|
- lib/onlinepayments/sdk/domain/created_payment_output.rb
|
205
206
|
- lib/onlinepayments/sdk/domain/created_token_response.rb
|
207
|
+
- lib/onlinepayments/sdk/domain/credit_card_specific_input_hosted_tokenization.rb
|
208
|
+
- lib/onlinepayments/sdk/domain/credit_card_validation_rules_hosted_tokenization.rb
|
206
209
|
- lib/onlinepayments/sdk/domain/currency_conversion.rb
|
207
210
|
- lib/onlinepayments/sdk/domain/currency_conversion_input.rb
|
208
211
|
- lib/onlinepayments/sdk/domain/currency_conversion_request.rb
|
@@ -222,6 +225,7 @@ files:
|
|
222
225
|
- lib/onlinepayments/sdk/domain/dcc_proposal.rb
|
223
226
|
- lib/onlinepayments/sdk/domain/decrypted_payment_data.rb
|
224
227
|
- lib/onlinepayments/sdk/domain/directory_entry.rb
|
228
|
+
- lib/onlinepayments/sdk/domain/discount.rb
|
225
229
|
- lib/onlinepayments/sdk/domain/empty_validator.rb
|
226
230
|
- lib/onlinepayments/sdk/domain/error_response.rb
|
227
231
|
- lib/onlinepayments/sdk/domain/external_cardholder_authentication_data.rb
|
@@ -275,7 +279,8 @@ files:
|
|
275
279
|
- lib/onlinepayments/sdk/domain/payment_details_response.rb
|
276
280
|
- lib/onlinepayments/sdk/domain/payment_error_response.rb
|
277
281
|
- lib/onlinepayments/sdk/domain/payment_link_event.rb
|
278
|
-
- lib/onlinepayments/sdk/domain/
|
282
|
+
- lib/onlinepayments/sdk/domain/payment_link_order_input.rb
|
283
|
+
- lib/onlinepayments/sdk/domain/payment_link_order_output.rb
|
279
284
|
- lib/onlinepayments/sdk/domain/payment_link_response.rb
|
280
285
|
- lib/onlinepayments/sdk/domain/payment_output.rb
|
281
286
|
- lib/onlinepayments/sdk/domain/payment_product.rb
|
@@ -416,6 +421,8 @@ files:
|
|
416
421
|
- lib/onlinepayments/sdk/merchant/tokens/tokens_client.rb
|
417
422
|
- lib/onlinepayments/sdk/meta_data_provider.rb
|
418
423
|
- lib/onlinepayments/sdk/modules.rb
|
424
|
+
- lib/onlinepayments/sdk/multipart_form_data_object.rb
|
425
|
+
- lib/onlinepayments/sdk/multipart_form_data_request.rb
|
419
426
|
- lib/onlinepayments/sdk/not_found_exception.rb
|
420
427
|
- lib/onlinepayments/sdk/param_request.rb
|
421
428
|
- lib/onlinepayments/sdk/payment_platform_exception.rb
|
@@ -426,6 +433,7 @@ files:
|
|
426
433
|
- lib/onlinepayments/sdk/request_param.rb
|
427
434
|
- lib/onlinepayments/sdk/response_exception.rb
|
428
435
|
- lib/onlinepayments/sdk/response_header.rb
|
436
|
+
- lib/onlinepayments/sdk/uploadable_file.rb
|
429
437
|
- lib/onlinepayments/sdk/validation_exception.rb
|
430
438
|
- lib/onlinepayments/sdk/webhooks.rb
|
431
439
|
- lib/onlinepayments/sdk/webhooks/api_version_mismatch_exception.rb
|