pcp-server-ruby-sdk 1.13.0 → 1.14.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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/api-definition.yaml +384 -13
- data/lib/PCP-server-Ruby-SDK/endpoints/pay_by_link_api_client.rb +33 -0
- data/lib/PCP-server-Ruby-SDK/models/authentication_token.rb +6 -183
- data/lib/PCP-server-Ruby-SDK/models/create_pay_by_link_request.rb +12 -0
- data/lib/PCP-server-Ruby-SDK/models/create_pay_by_link_response.rb +13 -0
- data/lib/PCP-server-Ruby-SDK/models/create_payment_intent.rb +1 -1
- data/lib/PCP-server-Ruby-SDK/models/pay_link_status_value.rb +20 -0
- data/lib/PCP-server-Ruby-SDK/models/payment_information_response.rb +4 -0
- data/lib/PCP-server-Ruby-SDK/models/payment_link_order.rb +10 -0
- data/lib/PCP-server-Ruby-SDK/models/payment_link_specific_input.rb +19 -0
- data/lib/PCP-server-Ruby-SDK/models/payment_product840_customer_account_for_intent.rb +12 -0
- data/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output.rb +5 -6
- data/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output_for_intent.rb +5 -6
- data/lib/PCP-server-Ruby-SDK/models/payment_references_for_payment_intent.rb +11 -0
- data/lib/PCP-server-Ruby-SDK/queries/get_checkouts_query.rb +5 -1
- data/lib/PCP-server-Ruby-SDK/version.rb +1 -1
- data/lib/PCP-server-Ruby-SDK.rb +8 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- data/spec/endpoints/pay_by_link_api_client_spec.rb +38 -0
- data/spec/endpoints/payment_information_api_client_spec.rb +9 -2
- data/spec/endpoints/payment_intent_api_client_spec.rb +3 -1
- data/spec/models/pay_by_link_models_spec.rb +50 -0
- data/spec/models/payment_intent_models_spec.rb +26 -0
- data/spec/queries/get_checkouts_query_spec.rb +15 -0
- metadata +20 -9
- data/lib/PCP-server-Ruby-SDK/models/payment_product840_specific_output_data.rb +0 -11
|
@@ -1,189 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
require 'json'
|
|
4
|
-
require 'date'
|
|
5
|
-
require 'securerandom'
|
|
1
|
+
require_relative 'model_base'
|
|
6
2
|
|
|
7
3
|
module PCPServerSDK
|
|
8
4
|
module Models
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
attr_accessor :expiration_date
|
|
15
|
-
|
|
16
|
-
def self.attribute_map
|
|
17
|
-
{
|
|
18
|
-
:'token' => :'token',
|
|
19
|
-
:'id' => :'id',
|
|
20
|
-
:'creation_date' => :'creationDate',
|
|
21
|
-
:'expiration_date' => :'expirationDate'
|
|
22
|
-
}
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
def self.acceptable_attributes
|
|
26
|
-
attribute_map.values
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def self.openapi_types
|
|
30
|
-
{
|
|
31
|
-
:'token' => :'String',
|
|
32
|
-
:'id' => :'String',
|
|
33
|
-
:'creation_date' => :'Time',
|
|
34
|
-
:'expiration_date' => :'Time'
|
|
35
|
-
}
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
def self.openapi_nullable
|
|
39
|
-
Set.new([])
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def initialize(attributes = {})
|
|
43
|
-
if (!attributes.is_a?(Hash))
|
|
44
|
-
fail ArgumentError, "The input argument (attributes) must be a hash in `AuthenticationToken` initialize method"
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
attributes = attributes.each_with_object({}) { |(k, v), h|
|
|
48
|
-
if (!self.class.attribute_map.key?(k.to_sym))
|
|
49
|
-
fail ArgumentError, "`#{k}` is not a valid attribute in `AuthenticationToken`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
|
|
50
|
-
end
|
|
51
|
-
h[k.to_sym] = v
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if attributes.key?(:'token')
|
|
55
|
-
self.token = attributes[:'token']
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
if attributes.key?(:'id')
|
|
59
|
-
self.id = attributes[:'id']
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
if attributes.key?(:'creation_date')
|
|
63
|
-
self.creation_date = attributes[:'creation_date'].is_a?(String) ? Time.parse(attributes[:'creation_date']) : attributes[:'creation_date']
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
if attributes.key?(:'expiration_date')
|
|
67
|
-
self.expiration_date = attributes[:'expiration_date'].is_a?(String) ? Time.parse(attributes[:'expiration_date']) : attributes[:'expiration_date']
|
|
68
|
-
end
|
|
69
|
-
end
|
|
70
|
-
|
|
71
|
-
def self.from_json(json_str)
|
|
72
|
-
data = JSON.parse(json_str)
|
|
73
|
-
new(data)
|
|
74
|
-
end
|
|
75
|
-
|
|
76
|
-
def self.build_from_hash(attributes)
|
|
77
|
-
return nil unless attributes.is_a?(Hash)
|
|
78
|
-
attributes = attributes.transform_keys(&:to_sym)
|
|
79
|
-
transformed_hash = {}
|
|
80
|
-
openapi_types.each_pair do |key, type|
|
|
81
|
-
if attributes.key?(attribute_map[key]) && attributes[attribute_map[key]].nil?
|
|
82
|
-
transformed_hash[key] = nil
|
|
83
|
-
elsif type =~ /\AArray<(.*)>/i
|
|
84
|
-
if attributes[attribute_map[key]].is_a?(Array)
|
|
85
|
-
transformed_hash[key] = attributes[attribute_map[key]].map { |v| _deserialize($1, v) }
|
|
86
|
-
end
|
|
87
|
-
elsif !attributes[attribute_map[key]].nil?
|
|
88
|
-
transformed_hash[key] = _deserialize(type, attributes[attribute_map[key]])
|
|
89
|
-
end
|
|
90
|
-
end
|
|
91
|
-
new(transformed_hash)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def self._deserialize(type, value)
|
|
95
|
-
case type.to_sym
|
|
96
|
-
when :Time
|
|
97
|
-
Time.parse(value)
|
|
98
|
-
when :Date
|
|
99
|
-
Date.parse(value)
|
|
100
|
-
when :String
|
|
101
|
-
value.to_s
|
|
102
|
-
when :Integer
|
|
103
|
-
value.to_i
|
|
104
|
-
when :Float
|
|
105
|
-
value.to_f
|
|
106
|
-
when :Boolean
|
|
107
|
-
if value.to_s =~ /\A(true|t|yes|y|1)\z/i
|
|
108
|
-
true
|
|
109
|
-
else
|
|
110
|
-
false
|
|
111
|
-
end
|
|
112
|
-
when :Object
|
|
113
|
-
value
|
|
114
|
-
when /\AArray<(?<inner_type>.+)>/i
|
|
115
|
-
inner_type = Regexp.last_match[:inner_type]
|
|
116
|
-
value.map { |v| _deserialize(inner_type, v) }
|
|
117
|
-
when /\AHash<(?<k_type>.+?), (?<v_type>.+)>/i
|
|
118
|
-
k_type = Regexp.last_match[:k_type]
|
|
119
|
-
v_type = Regexp.last_match[:v_type]
|
|
120
|
-
{}.tap do |hash|
|
|
121
|
-
value.each do |k, v|
|
|
122
|
-
hash[_deserialize(k_type, k)] = _deserialize(v_type, v)
|
|
123
|
-
end
|
|
124
|
-
end
|
|
125
|
-
else
|
|
126
|
-
# models (e.g. Pet) or oneOf
|
|
127
|
-
if PCPServerSDK::Models.const_defined?(type)
|
|
128
|
-
klass = PCPServerSDK::Models.const_get(type)
|
|
129
|
-
klass.respond_to?(:openapi_any_of) || klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value)
|
|
130
|
-
else
|
|
131
|
-
value
|
|
132
|
-
end
|
|
133
|
-
end
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
def ==(o)
|
|
137
|
-
return true if self.equal?(o)
|
|
138
|
-
self.class == o.class &&
|
|
139
|
-
token == o.token &&
|
|
140
|
-
id == o.id &&
|
|
141
|
-
creation_date == o.creation_date &&
|
|
142
|
-
expiration_date == o.expiration_date
|
|
143
|
-
end
|
|
144
|
-
|
|
145
|
-
def eql?(o)
|
|
146
|
-
self == o
|
|
147
|
-
end
|
|
148
|
-
|
|
149
|
-
def hash
|
|
150
|
-
[token, id, creation_date, expiration_date].hash
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def to_s
|
|
154
|
-
to_hash.to_s
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
def to_body
|
|
158
|
-
to_hash
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
def to_hash
|
|
162
|
-
hash = {}
|
|
163
|
-
self.class.attribute_map.each_pair do |attr, param|
|
|
164
|
-
value = self.send(attr)
|
|
165
|
-
if value.nil?
|
|
166
|
-
is_nullable = self.class.openapi_nullable.include?(attr)
|
|
167
|
-
next if !is_nullable || (is_nullable && !instance_variable_defined?("@#{attr}"))
|
|
168
|
-
end
|
|
169
|
-
hash[param] = _to_hash(value)
|
|
170
|
-
end
|
|
171
|
-
hash
|
|
172
|
-
end
|
|
173
|
-
|
|
174
|
-
def _to_hash(value)
|
|
175
|
-
if value.is_a?(Array)
|
|
176
|
-
value.compact.map { |v| _to_hash(v) }
|
|
177
|
-
elsif value.is_a?(Hash)
|
|
178
|
-
{}.tap do |hash|
|
|
179
|
-
value.each { |k, v| hash[k] = _to_hash(v) }
|
|
180
|
-
end
|
|
181
|
-
elsif value.respond_to? :to_hash
|
|
182
|
-
value.to_hash
|
|
183
|
-
else
|
|
184
|
-
value
|
|
185
|
-
end
|
|
186
|
-
end
|
|
5
|
+
class AuthenticationToken < ModelBase
|
|
6
|
+
attribute :token, :token, :String
|
|
7
|
+
attribute :id, :id, :String
|
|
8
|
+
attribute :creation_date, :creationDate, :Time
|
|
9
|
+
attribute :expiration_date, :expirationDate, :Time
|
|
187
10
|
end
|
|
188
11
|
end
|
|
189
12
|
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require_relative 'model_base'
|
|
2
|
+
|
|
3
|
+
module PCPServerSDK
|
|
4
|
+
module Models
|
|
5
|
+
class CreatePayByLinkRequest < ModelBase
|
|
6
|
+
attribute :payment_link_specific_input, :paymentLinkSpecificInput, :PaymentLinkSpecificInput
|
|
7
|
+
attribute :order_type, :orderType, :OrderType
|
|
8
|
+
attribute :items, :items, 'Array<OrderItem>'
|
|
9
|
+
attribute :order_references, :orderReferences, :References
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
require_relative 'model_base'
|
|
2
|
+
|
|
3
|
+
module PCPServerSDK
|
|
4
|
+
module Models
|
|
5
|
+
class CreatePayByLinkResponse < ModelBase
|
|
6
|
+
attribute :expiration_date, :expirationDate, :Time
|
|
7
|
+
attribute :payment_link_order, :paymentLinkOrder, :PaymentLinkOrder
|
|
8
|
+
attribute :status, :status, :PayLinkStatusValue
|
|
9
|
+
attribute :redirection_url, :redirectionUrl, :String
|
|
10
|
+
attribute :payment_link_id, :paymentLinkId, :String
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
end
|
|
@@ -4,7 +4,7 @@ module PCPServerSDK
|
|
|
4
4
|
module Models
|
|
5
5
|
class CreatePaymentIntent < ModelBase
|
|
6
6
|
attribute :amount_of_money, :amountOfMoney, :AmountOfMoney
|
|
7
|
-
attribute :references, :references, :
|
|
7
|
+
attribute :references, :references, :PaymentReferencesForPaymentIntent
|
|
8
8
|
attribute :shopping_cart, :shoppingCart, :ShoppingCartData
|
|
9
9
|
end
|
|
10
10
|
end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module PCPServerSDK
|
|
2
|
+
module Models
|
|
3
|
+
class PayLinkStatusValue
|
|
4
|
+
ACTIVE = 'ACTIVE'.freeze
|
|
5
|
+
PAID = 'PAID'.freeze
|
|
6
|
+
EXPIRED = 'EXPIRED'.freeze
|
|
7
|
+
REDIRECTED = 'REDIRECTED'.freeze
|
|
8
|
+
|
|
9
|
+
def self.all_vars
|
|
10
|
+
@all_vars ||= [ACTIVE, PAID, EXPIRED, REDIRECTED].freeze
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.build_from_hash(value)
|
|
14
|
+
return value if all_vars.include?(value)
|
|
15
|
+
|
|
16
|
+
raise "Invalid ENUM value #{value} for class #PayLinkStatusValue"
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
@@ -22,6 +22,10 @@ module PCPServerSDK
|
|
|
22
22
|
# or terminal will be used. It is always the reference for external transactions.
|
|
23
23
|
# (e.g. card present payments, cash payments or payments processed by other payment providers).
|
|
24
24
|
attribute :merchant_reference, :merchantReference, :String
|
|
25
|
+
# Trace number assigned by the payment terminal.
|
|
26
|
+
attribute :trace_number, :traceNumber, :String
|
|
27
|
+
# Receipt number assigned by the payment terminal.
|
|
28
|
+
attribute :receipt_number, :receiptNumber, :String
|
|
25
29
|
# The date and time when the payment was created.
|
|
26
30
|
#
|
|
27
31
|
# Format will be in one of the following formats:
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require_relative 'model_base'
|
|
2
|
+
|
|
3
|
+
module PCPServerSDK
|
|
4
|
+
module Models
|
|
5
|
+
class PaymentLinkSpecificInput < ModelBase
|
|
6
|
+
attribute :expiration_date, :expirationDate, :Time
|
|
7
|
+
attribute :authorization_mode, :authorizationMode, :AuthorizationMode
|
|
8
|
+
attribute :payment_methods, :paymentMethods, 'Array<String>'
|
|
9
|
+
attribute :bnpl_id, :bnplId, :String
|
|
10
|
+
attribute :return_url, :returnUrl, :String
|
|
11
|
+
attribute :logo_url, :logoUrl, :String
|
|
12
|
+
attribute :auto_redirection, :autoRedirection, :Boolean
|
|
13
|
+
attribute :terms_url, :termsUrl, :String
|
|
14
|
+
attribute :retry_number, :retryNumber, :Integer
|
|
15
|
+
attribute :merchant_name, :merchantName, :String
|
|
16
|
+
attribute :merchant_origin, :merchantOrigin, :String
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require_relative 'model_base'
|
|
2
|
+
|
|
3
|
+
module PCPServerSDK
|
|
4
|
+
module Models
|
|
5
|
+
class PaymentProduct840CustomerAccountForIntent < ModelBase
|
|
6
|
+
attribute :company_name, :companyName, :String
|
|
7
|
+
attribute :first_name, :firstName, :String
|
|
8
|
+
attribute :surname, :surname, :String
|
|
9
|
+
attribute :email_address, :emailAddress, :String
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
require_relative '
|
|
1
|
+
require_relative 'model_base'
|
|
2
2
|
|
|
3
3
|
module PCPServerSDK
|
|
4
4
|
module Models
|
|
5
|
-
class PaymentProduct840SpecificOutput <
|
|
5
|
+
class PaymentProduct840SpecificOutput < ModelBase
|
|
6
|
+
attribute :billing_address, :billingAddress, :Address
|
|
7
|
+
attribute :customer_account, :customerAccount, :PaymentProduct840CustomerAccount
|
|
8
|
+
attribute :pay_pal_transaction_id, :payPalTransactionId, :String
|
|
6
9
|
attribute :shipping_address, :shippingAddress, :Address
|
|
7
|
-
|
|
8
|
-
def self.openapi_all_of
|
|
9
|
-
[:PaymentProduct840SpecificOutputData]
|
|
10
|
-
end
|
|
11
10
|
end
|
|
12
11
|
end
|
|
13
12
|
end
|
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
require_relative '
|
|
1
|
+
require_relative 'model_base'
|
|
2
2
|
|
|
3
3
|
module PCPServerSDK
|
|
4
4
|
module Models
|
|
5
|
-
class PaymentProduct840SpecificOutputForIntent <
|
|
5
|
+
class PaymentProduct840SpecificOutputForIntent < ModelBase
|
|
6
|
+
attribute :billing_address, :billingAddress, :Address
|
|
7
|
+
attribute :customer_account, :customerAccount, :PaymentProduct840CustomerAccountForIntent
|
|
8
|
+
attribute :pay_pal_transaction_id, :payPalTransactionId, :String
|
|
6
9
|
attribute :shipping_address, :shippingAddress, :ShippingAddress
|
|
7
|
-
|
|
8
|
-
def self.openapi_all_of
|
|
9
|
-
[:PaymentProduct840SpecificOutputData]
|
|
10
|
-
end
|
|
11
10
|
end
|
|
12
11
|
end
|
|
13
12
|
end
|
|
@@ -15,7 +15,8 @@ module PCPServerSDK
|
|
|
15
15
|
:include_payment_product_id, :include_checkout_status,
|
|
16
16
|
:include_extended_checkout_status, :include_payment_channel,
|
|
17
17
|
:payment_reference, :payment_id, :first_name, :surname,
|
|
18
|
-
:email, :phone_number, :date_of_birth, :company_information, :terminal_id, :reporting_token
|
|
18
|
+
:email, :phone_number, :date_of_birth, :company_information, :terminal_id, :reporting_token,
|
|
19
|
+
:card_authorization_id, :receipt_number, :trace_number
|
|
19
20
|
|
|
20
21
|
def initialize
|
|
21
22
|
@include_payment_product_id = []
|
|
@@ -60,6 +61,9 @@ module PCPServerSDK
|
|
|
60
61
|
query['companyInformation'] = @company_information if @company_information
|
|
61
62
|
query['terminalId'] = @terminal_id if @terminal_id
|
|
62
63
|
query['reportingToken'] = @reporting_token if @reporting_token
|
|
64
|
+
query['cardAuthorizationId'] = @card_authorization_id if @card_authorization_id
|
|
65
|
+
query['receiptNumber'] = @receipt_number if @receipt_number
|
|
66
|
+
query['traceNumber'] = @trace_number if @trace_number
|
|
63
67
|
|
|
64
68
|
query
|
|
65
69
|
end
|
data/lib/PCP-server-Ruby-SDK.rb
CHANGED
|
@@ -7,6 +7,7 @@ require_relative 'PCP-server-Ruby-SDK/endpoints/order_management_checkout_action
|
|
|
7
7
|
require_relative 'PCP-server-Ruby-SDK/endpoints/payment_execution_api_client'
|
|
8
8
|
require_relative 'PCP-server-Ruby-SDK/endpoints/payment_information_api_client'
|
|
9
9
|
require_relative 'PCP-server-Ruby-SDK/endpoints/payment_intent_api_client'
|
|
10
|
+
require_relative 'PCP-server-Ruby-SDK/endpoints/pay_by_link_api_client'
|
|
10
11
|
|
|
11
12
|
# Errors
|
|
12
13
|
require_relative 'PCP-server-Ruby-SDK/errors/api_error_response_exception'
|
|
@@ -118,11 +119,12 @@ require_relative 'PCP-server-Ruby-SDK/models/payment_instructions'
|
|
|
118
119
|
require_relative 'PCP-server-Ruby-SDK/models/create_payment_intent'
|
|
119
120
|
require_relative 'PCP-server-Ruby-SDK/models/create_payment_intent_request'
|
|
120
121
|
require_relative 'PCP-server-Ruby-SDK/models/create_payment_intent_response'
|
|
122
|
+
require_relative 'PCP-server-Ruby-SDK/models/create_pay_by_link_request'
|
|
123
|
+
require_relative 'PCP-server-Ruby-SDK/models/create_pay_by_link_response'
|
|
121
124
|
require_relative 'PCP-server-Ruby-SDK/models/payment_intent_response_data'
|
|
122
125
|
require_relative 'PCP-server-Ruby-SDK/models/payment_intent_output'
|
|
123
126
|
require_relative 'PCP-server-Ruby-SDK/models/payment_intent_response'
|
|
124
127
|
require_relative 'PCP-server-Ruby-SDK/models/payment_method_specific_input_for_intent'
|
|
125
|
-
require_relative 'PCP-server-Ruby-SDK/models/payment_product840_specific_output_data'
|
|
126
128
|
require_relative 'PCP-server-Ruby-SDK/models/payment_product840_specific_output_for_intent'
|
|
127
129
|
require_relative 'PCP-server-Ruby-SDK/models/redirect_payment_method_specific_input_for_intent'
|
|
128
130
|
require_relative 'PCP-server-Ruby-SDK/models/redirect_payment_method_specific_output_for_create_intent'
|
|
@@ -137,10 +139,15 @@ require_relative 'PCP-server-Ruby-SDK/models/payment_product3392_specific_input'
|
|
|
137
139
|
require_relative 'PCP-server-Ruby-SDK/models/payment_product5002_specific_input'
|
|
138
140
|
require_relative 'PCP-server-Ruby-SDK/models/payment_product771_specific_output'
|
|
139
141
|
require_relative 'PCP-server-Ruby-SDK/models/payment_product840_customer_account'
|
|
142
|
+
require_relative 'PCP-server-Ruby-SDK/models/payment_product840_customer_account_for_intent'
|
|
140
143
|
require_relative 'PCP-server-Ruby-SDK/models/payment_product840_specific_output'
|
|
141
144
|
require_relative 'PCP-server-Ruby-SDK/models/payment_references'
|
|
145
|
+
require_relative 'PCP-server-Ruby-SDK/models/payment_references_for_payment_intent'
|
|
142
146
|
require_relative 'PCP-server-Ruby-SDK/models/payment_references_for_refund'
|
|
143
147
|
require_relative 'PCP-server-Ruby-SDK/models/payment_response'
|
|
148
|
+
require_relative 'PCP-server-Ruby-SDK/models/payment_link_order'
|
|
149
|
+
require_relative 'PCP-server-Ruby-SDK/models/payment_link_specific_input'
|
|
150
|
+
require_relative 'PCP-server-Ruby-SDK/models/pay_link_status_value'
|
|
144
151
|
require_relative 'PCP-server-Ruby-SDK/models/payment_status_output'
|
|
145
152
|
require_relative 'PCP-server-Ruby-SDK/models/payment_type'
|
|
146
153
|
require_relative 'PCP-server-Ruby-SDK/models/payout_output'
|
data/package-lock.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pcp-serversdk-ruby",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "pcp-serversdk-ruby",
|
|
9
|
-
"version": "1.
|
|
9
|
+
"version": "1.14.0",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@commitlint/cli": "19.4.0",
|
|
12
12
|
"@commitlint/config-conventional": "19.2.2",
|
data/package.json
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require 'net/http'
|
|
3
|
+
require 'json'
|
|
4
|
+
require_relative '../../lib/PCP-server-Ruby-SDK.rb'
|
|
5
|
+
|
|
6
|
+
RSpec.describe PCPServerSDK::Endpoints::PayByLinkApiClient do
|
|
7
|
+
let(:config) { mock_communicator_config }
|
|
8
|
+
let(:client) { described_class.new(config) }
|
|
9
|
+
let(:payload) { double('PCPServerSDK::Models::CreatePayByLinkRequest') }
|
|
10
|
+
let(:response) do
|
|
11
|
+
double(
|
|
12
|
+
'Response',
|
|
13
|
+
body: '{"status":"ACTIVE","paymentLinkId":"707ef15b-7a0a-48f2-b7d8-c95103418a9c"}',
|
|
14
|
+
code: 201
|
|
15
|
+
)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
before do
|
|
19
|
+
allow(client).to receive(:get_response).and_return(response)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
describe '#create_pay_by_link_request' do
|
|
23
|
+
it 'posts to the pay-by-link endpoint and deserializes its response' do
|
|
24
|
+
result = client.create_pay_by_link_request('1', '2', '3', payload)
|
|
25
|
+
|
|
26
|
+
expect(result).to be_a(PCPServerSDK::Models::CreatePayByLinkResponse)
|
|
27
|
+
expect(result.status).to eq('ACTIVE')
|
|
28
|
+
expect(result.payment_link_id).to eq('707ef15b-7a0a-48f2-b7d8-c95103418a9c')
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
it 'requires all path parameters and the payload' do
|
|
32
|
+
expect { client.create_pay_by_link_request(nil, '2', '3', payload) }.to raise_error(TypeError, 'Merchant ID is required')
|
|
33
|
+
expect { client.create_pay_by_link_request('1', nil, '3', payload) }.to raise_error(TypeError, 'Commerce Case ID is required')
|
|
34
|
+
expect { client.create_pay_by_link_request('1', '2', nil, payload) }.to raise_error(TypeError, 'Checkout ID is required')
|
|
35
|
+
expect { client.create_pay_by_link_request('1', '2', '3', nil) }.to raise_error(TypeError, 'Payload is required')
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -17,8 +17,13 @@ RSpec.describe PCPServerSDK::Endpoints::PaymentInformationApiClient do
|
|
|
17
17
|
let(:payload) { double('PCPServerSDK::Models::PaymentInformationRequest') }
|
|
18
18
|
|
|
19
19
|
context 'when request is successful' do
|
|
20
|
-
let(:response) { double('Response', body: '{}', code: '200') }
|
|
21
|
-
let(:expected_response)
|
|
20
|
+
let(:response) { double('Response', body: '{"traceNumber":"trace-123","receiptNumber":"receipt-123"}', code: '200') }
|
|
21
|
+
let(:expected_response) do
|
|
22
|
+
PCPServerSDK::Models::PaymentInformationResponse.new(
|
|
23
|
+
trace_number: 'trace-123',
|
|
24
|
+
receipt_number: 'receipt-123'
|
|
25
|
+
)
|
|
26
|
+
end
|
|
22
27
|
|
|
23
28
|
before do
|
|
24
29
|
allow(client).to receive(:get_response).and_return(response)
|
|
@@ -27,6 +32,8 @@ RSpec.describe PCPServerSDK::Endpoints::PaymentInformationApiClient do
|
|
|
27
32
|
it 'returns a successful response' do
|
|
28
33
|
result = client.create_payment_information('1', '2', '3', payload)
|
|
29
34
|
expect(result).to eq(expected_response)
|
|
35
|
+
expect(result.trace_number).to eq('trace-123')
|
|
36
|
+
expect(result.receipt_number).to eq('receipt-123')
|
|
30
37
|
end
|
|
31
38
|
end
|
|
32
39
|
|
|
@@ -8,7 +8,9 @@ RSpec.describe PCPServerSDK::Endpoints::PaymentIntentApiClient do
|
|
|
8
8
|
|
|
9
9
|
describe '#create_payment_intent' do
|
|
10
10
|
it 'posts the payload and deserializes the response' do
|
|
11
|
-
payload = PCPServerSDK::Models::CreatePaymentIntentRequest.new
|
|
11
|
+
payload = PCPServerSDK::Models::CreatePaymentIntentRequest.new(
|
|
12
|
+
references: PCPServerSDK::Models::PaymentReferencesForPaymentIntent.new(merchant_reference: 'order-123')
|
|
13
|
+
)
|
|
12
14
|
response = double('Response', body: '{"paymentIntentOutput":{"paymentIntentId":"intent-1"}}', code: '201')
|
|
13
15
|
allow(client).to receive(:get_response).and_return(response)
|
|
14
16
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
require 'spec_helper'
|
|
2
|
+
require_relative '../../lib/PCP-server-Ruby-SDK'
|
|
3
|
+
|
|
4
|
+
RSpec.describe 'Pay-by-link models' do
|
|
5
|
+
it 'serializes required request properties and deserializes the response structure' do
|
|
6
|
+
request = PCPServerSDK::Models::CreatePayByLinkRequest.new(
|
|
7
|
+
payment_link_specific_input: PCPServerSDK::Models::PaymentLinkSpecificInput.new(
|
|
8
|
+
authorization_mode: 'SALE',
|
|
9
|
+
payment_methods: ['840'],
|
|
10
|
+
return_url: 'https://merchant.example/complete'
|
|
11
|
+
),
|
|
12
|
+
order_type: 'FULL',
|
|
13
|
+
order_references: PCPServerSDK::Models::References.new(merchant_reference: 'order-123')
|
|
14
|
+
)
|
|
15
|
+
|
|
16
|
+
expect(request.to_hash).to include(
|
|
17
|
+
paymentLinkSpecificInput: {
|
|
18
|
+
authorizationMode: 'SALE',
|
|
19
|
+
paymentMethods: ['840'],
|
|
20
|
+
returnUrl: 'https://merchant.example/complete'
|
|
21
|
+
},
|
|
22
|
+
orderType: 'FULL',
|
|
23
|
+
orderReferences: { merchantReference: 'order-123' }
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
response = PCPServerSDK::Models::CreatePayByLinkResponse.build_from_hash(
|
|
27
|
+
'expirationDate' => '2026-09-22T12:00:00Z',
|
|
28
|
+
'paymentLinkOrder' => {
|
|
29
|
+
'merchantReference' => 'order-123',
|
|
30
|
+
'amount' => { 'amount' => 1200, 'currencyCode' => 'EUR' }
|
|
31
|
+
},
|
|
32
|
+
'status' => 'ACTIVE',
|
|
33
|
+
'redirectionUrl' => 'https://commerce.example/pay/link',
|
|
34
|
+
'paymentLinkId' => '707ef15b-7a0a-48f2-b7d8-c95103418a9c'
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
expect(response.expiration_date).to be_a(Time)
|
|
38
|
+
expect(response.payment_link_order).to be_a(PCPServerSDK::Models::PaymentLinkOrder)
|
|
39
|
+
expect(response.payment_link_order.amount).to be_a(PCPServerSDK::Models::AmountOfMoney)
|
|
40
|
+
expect(response.payment_link_order.amount.amount).to eq(1200)
|
|
41
|
+
expect(response.payment_link_order.amount.currency_code).to eq('EUR')
|
|
42
|
+
expect(response.status).to eq('ACTIVE')
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
it 'enforces the required request fields from the OpenAPI schema' do
|
|
46
|
+
expect do
|
|
47
|
+
PCPServerSDK::Models::CreatePayByLinkRequest.new(order_type: 'FULL')
|
|
48
|
+
end.to raise_error(ArgumentError, 'payment_link_specific_input cannot be nil')
|
|
49
|
+
end
|
|
50
|
+
end
|
|
@@ -5,6 +5,7 @@ RSpec.describe 'Payment intent models' do
|
|
|
5
5
|
it 'deserializes and serializes nested payment intent data' do
|
|
6
6
|
request = PCPServerSDK::Models::CreatePaymentIntentRequest.build_from_hash(
|
|
7
7
|
'amountOfMoney' => { 'amount' => 1200, 'currencyCode' => 'EUR' },
|
|
8
|
+
'references' => { 'merchantReference' => 'subscription-123' },
|
|
8
9
|
'shoppingCart' => {
|
|
9
10
|
'items' => [{ 'invoiceData' => { 'description' => 'Subscription' } }]
|
|
10
11
|
},
|
|
@@ -18,8 +19,33 @@ RSpec.describe 'Payment intent models' do
|
|
|
18
19
|
)
|
|
19
20
|
|
|
20
21
|
expect(request.amount_of_money).to be_a(PCPServerSDK::Models::AmountOfMoney)
|
|
22
|
+
expect(request.references).to be_a(PCPServerSDK::Models::PaymentReferencesForPaymentIntent)
|
|
21
23
|
expect(request.shopping_cart.items.first).to be_a(PCPServerSDK::Models::CartItemData)
|
|
22
24
|
expect(request.payment_method_specific_input.redirect_payment_method_specific_input.requires_approval).to be(false)
|
|
23
25
|
expect(request.to_hash.dig(:shoppingCart, :items, 0, :invoiceData, :description)).to eq('Subscription')
|
|
24
26
|
end
|
|
27
|
+
|
|
28
|
+
it 'uses the payment-intent PayPal account structure' do
|
|
29
|
+
response = PCPServerSDK::Models::PaymentIntentResponse.build_from_hash(
|
|
30
|
+
'redirectPaymentMethodSpecificOutput' => {
|
|
31
|
+
'paymentProduct840SpecificOutput' => {
|
|
32
|
+
'customerAccount' => { 'emailAddress' => 'customer@example.com' }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
customer_account = response.redirect_payment_method_specific_output.payment_product840_specific_output.customer_account
|
|
38
|
+
|
|
39
|
+
expect(customer_account).to be_a(PCPServerSDK::Models::PaymentProduct840CustomerAccountForIntent)
|
|
40
|
+
expect(customer_account.email_address).to eq('customer@example.com')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
it 'uses the regular PayPal account structure outside payment intents' do
|
|
44
|
+
output = PCPServerSDK::Models::PaymentProduct840SpecificOutput.build_from_hash(
|
|
45
|
+
'customerAccount' => { 'payerId' => 'payer-123' }
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
expect(output.customer_account).to be_a(PCPServerSDK::Models::PaymentProduct840CustomerAccount)
|
|
49
|
+
expect(output.customer_account.payer_id).to eq('payer-123')
|
|
50
|
+
end
|
|
25
51
|
end
|
|
@@ -181,4 +181,19 @@ RSpec.describe PCPServerSDK::Queries::GetCheckoutsQuery do
|
|
|
181
181
|
@query.company_information = 'Company XYZ'
|
|
182
182
|
expect(@query.to_query_map).to eq({ 'companyInformation' => 'Company XYZ' })
|
|
183
183
|
end
|
|
184
|
+
|
|
185
|
+
it 'should return query map with card_authorization_id' do
|
|
186
|
+
@query.card_authorization_id = 'authorization-123'
|
|
187
|
+
expect(@query.to_query_map).to eq({ 'cardAuthorizationId' => 'authorization-123' })
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
it 'should return query map with receipt_number' do
|
|
191
|
+
@query.receipt_number = 'receipt-123'
|
|
192
|
+
expect(@query.to_query_map).to eq({ 'receiptNumber' => 'receipt-123' })
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
it 'should return query map with trace_number' do
|
|
196
|
+
@query.trace_number = 'trace-123'
|
|
197
|
+
expect(@query.to_query_map).to eq({ 'traceNumber' => 'trace-123' })
|
|
198
|
+
end
|
|
184
199
|
end
|