paypal-server-sdk 1.0.0 → 1.1.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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +42 -36
  3. data/lib/paypal_server_sdk/controllers/base_controller.rb +1 -1
  4. data/lib/paypal_server_sdk/controllers/orders_controller.rb +211 -171
  5. data/lib/paypal_server_sdk/controllers/payments_controller.rb +95 -92
  6. data/lib/paypal_server_sdk/controllers/vault_controller.rb +81 -81
  7. data/lib/paypal_server_sdk/exceptions/error_exception.rb +5 -3
  8. data/lib/paypal_server_sdk/exceptions/o_auth_provider_exception.rb +5 -3
  9. data/lib/paypal_server_sdk/models/apple_pay_attributes.rb +2 -1
  10. data/lib/paypal_server_sdk/models/apple_pay_experience_context.rb +68 -0
  11. data/lib/paypal_server_sdk/models/apple_pay_request.rb +18 -4
  12. data/lib/paypal_server_sdk/models/callback_configuration.rb +1 -2
  13. data/lib/paypal_server_sdk/models/card_brand.rb +1 -1
  14. data/lib/paypal_server_sdk/models/card_customer_information.rb +14 -4
  15. data/lib/paypal_server_sdk/models/customer_information.rb +16 -5
  16. data/lib/paypal_server_sdk/models/customer_response.rb +1 -2
  17. data/lib/paypal_server_sdk/models/google_pay_experience_context.rb +68 -0
  18. data/lib/paypal_server_sdk/models/google_pay_request.rb +17 -4
  19. data/lib/paypal_server_sdk/models/item.rb +14 -4
  20. data/lib/paypal_server_sdk/models/line_item.rb +22 -11
  21. data/lib/paypal_server_sdk/models/order_billing_plan.rb +93 -0
  22. data/lib/paypal_server_sdk/models/order_status.rb +5 -5
  23. data/lib/paypal_server_sdk/models/payment_token_response.rb +1 -2
  24. data/lib/paypal_server_sdk/models/paypal_wallet_contact_preference.rb +34 -0
  25. data/lib/paypal_server_sdk/models/paypal_wallet_customer.rb +14 -4
  26. data/lib/paypal_server_sdk/models/paypal_wallet_customer_request.rb +14 -4
  27. data/lib/paypal_server_sdk/models/paypal_wallet_experience_context.rb +20 -6
  28. data/lib/paypal_server_sdk/models/shipping_options_purchase_unit.rb +24 -5
  29. data/lib/paypal_server_sdk/models/vault_customer.rb +15 -5
  30. data/lib/paypal_server_sdk/models/vault_response.rb +2 -1
  31. data/lib/paypal_server_sdk/models/vault_response_customer.rb +1 -1
  32. data/lib/paypal_server_sdk/models/venmo_wallet_customer_information.rb +24 -4
  33. data/lib/paypal_server_sdk.rb +149 -145
  34. metadata +6 -2
@@ -6,53 +6,6 @@
6
6
  module PaypalServerSdk
7
7
  # PaymentsController
8
8
  class PaymentsController < BaseController
9
- # Shows details for an authorized payment, by ID.
10
- # @param [String] authorization_id Required parameter: The ID of the
11
- # authorized payment for which to show details.
12
- # @param [String] paypal_mock_response Optional parameter: PayPal's REST API
13
- # uses a request header to invoke negative testing in the sandbox. This
14
- # header configures the sandbox into a negative testing state for
15
- # transactions that include the merchant.
16
- # @param [String] paypal_auth_assertion Optional parameter: An
17
- # API-caller-provided JSON Web Token (JWT) assertion that identifies the
18
- # merchant. For details, see
19
- # [PayPal-Auth-Assertion](/docs/api/reference/api-requests/#paypal-auth-asse
20
- # rtion). Note:For three party transactions in which a partner is managing
21
- # the API calls on behalf of a merchant, the partner must identify the
22
- # merchant using either a PayPal-Auth-Assertion header or an access token
23
- # with target_subject.
24
- # @return [ApiResponse] the complete http response with raw body and status code.
25
- def get_authorized_payment(options = {})
26
- new_api_call_builder
27
- .request(new_request_builder(HttpMethodEnum::GET,
28
- '/v2/payments/authorizations/{authorization_id}',
29
- Server::DEFAULT)
30
- .template_param(new_parameter(options['authorization_id'], key: 'authorization_id')
31
- .should_encode(true))
32
- .header_param(new_parameter(options['paypal_mock_response'], key: 'PayPal-Mock-Response'))
33
- .header_param(new_parameter(options['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion'))
34
- .header_param(new_parameter('application/json', key: 'accept'))
35
- .auth(Single.new('Oauth2')))
36
- .response(new_response_handler
37
- .deserializer(APIHelper.method(:custom_type_deserializer))
38
- .deserialize_into(PaymentAuthorization.method(:from_hash))
39
- .is_api_response(true)
40
- .local_error('401',
41
- 'Authentication failed due to missing authorization header, or'\
42
- ' invalid authentication credentials.',
43
- ErrorException)
44
- .local_error('404',
45
- 'The request failed because the resource does not exist.',
46
- ErrorException)
47
- .local_error('500',
48
- 'The request failed because an internal server error occurred.',
49
- APIException)
50
- .local_error('default',
51
- 'The error response.',
52
- ErrorException))
53
- .execute
54
- end
55
-
56
9
  # Captures an authorized payment, by ID.
57
10
  # @param [String] authorization_id Required parameter: The PayPal-generated
58
11
  # ID for the authorized payment to capture.
@@ -76,7 +29,8 @@ module PaypalServerSdk
76
29
  # the API calls on behalf of a merchant, the partner must identify the
77
30
  # merchant using either a PayPal-Auth-Assertion header or an access token
78
31
  # with target_subject.
79
- # @param [CaptureRequest] body Optional parameter: Example:
32
+ # @param [CaptureRequest] body Optional parameter: TODO: type description
33
+ # here
80
34
  # @return [ApiResponse] the complete http response with raw body and status code.
81
35
  def capture_authorized_payment(options = {})
82
36
  new_api_call_builder
@@ -130,6 +84,48 @@ module PaypalServerSdk
130
84
  .execute
131
85
  end
132
86
 
87
+ # Shows details for a captured payment, by ID.
88
+ # @param [String] capture_id Required parameter: The PayPal-generated ID for
89
+ # the captured payment for which to show details.
90
+ # @param [String] paypal_mock_response Optional parameter: PayPal's REST API
91
+ # uses a request header to invoke negative testing in the sandbox. This
92
+ # header configures the sandbox into a negative testing state for
93
+ # transactions that include the merchant.
94
+ # @return [ApiResponse] the complete http response with raw body and status code.
95
+ def get_captured_payment(options = {})
96
+ new_api_call_builder
97
+ .request(new_request_builder(HttpMethodEnum::GET,
98
+ '/v2/payments/captures/{capture_id}',
99
+ Server::DEFAULT)
100
+ .template_param(new_parameter(options['capture_id'], key: 'capture_id')
101
+ .should_encode(true))
102
+ .header_param(new_parameter(options['paypal_mock_response'], key: 'PayPal-Mock-Response'))
103
+ .header_param(new_parameter('application/json', key: 'accept'))
104
+ .auth(Single.new('Oauth2')))
105
+ .response(new_response_handler
106
+ .deserializer(APIHelper.method(:custom_type_deserializer))
107
+ .deserialize_into(CapturedPayment.method(:from_hash))
108
+ .is_api_response(true)
109
+ .local_error('401',
110
+ 'Authentication failed due to missing authorization header, or'\
111
+ ' invalid authentication credentials.',
112
+ ErrorException)
113
+ .local_error('403',
114
+ 'The request failed because the caller has insufficient'\
115
+ ' permissions.',
116
+ ErrorException)
117
+ .local_error('404',
118
+ 'The request failed because the resource does not exist.',
119
+ ErrorException)
120
+ .local_error('500',
121
+ 'The request failed because an internal server error occurred.',
122
+ APIException)
123
+ .local_error('default',
124
+ 'The error response.',
125
+ ErrorException))
126
+ .execute
127
+ end
128
+
133
129
  # Reauthorizes an authorized PayPal account payment, by ID. To ensure that
134
130
  # funds are still available, reauthorize a payment after its initial
135
131
  # three-day honor period expires. Within the 29-day authorization period,
@@ -161,7 +157,8 @@ module PaypalServerSdk
161
157
  # the API calls on behalf of a merchant, the partner must identify the
162
158
  # merchant using either a PayPal-Auth-Assertion header or an access token
163
159
  # with target_subject.
164
- # @param [ReauthorizeRequest] body Optional parameter: Example:
160
+ # @param [ReauthorizeRequest] body Optional parameter: TODO: type
161
+ # description here
165
162
  # @return [ApiResponse] the complete http response with raw body and status code.
166
163
  def reauthorize_payment(options = {})
167
164
  new_api_call_builder
@@ -277,48 +274,6 @@ module PaypalServerSdk
277
274
  .execute
278
275
  end
279
276
 
280
- # Shows details for a captured payment, by ID.
281
- # @param [String] capture_id Required parameter: The PayPal-generated ID for
282
- # the captured payment for which to show details.
283
- # @param [String] paypal_mock_response Optional parameter: PayPal's REST API
284
- # uses a request header to invoke negative testing in the sandbox. This
285
- # header configures the sandbox into a negative testing state for
286
- # transactions that include the merchant.
287
- # @return [ApiResponse] the complete http response with raw body and status code.
288
- def get_captured_payment(options = {})
289
- new_api_call_builder
290
- .request(new_request_builder(HttpMethodEnum::GET,
291
- '/v2/payments/captures/{capture_id}',
292
- Server::DEFAULT)
293
- .template_param(new_parameter(options['capture_id'], key: 'capture_id')
294
- .should_encode(true))
295
- .header_param(new_parameter(options['paypal_mock_response'], key: 'PayPal-Mock-Response'))
296
- .header_param(new_parameter('application/json', key: 'accept'))
297
- .auth(Single.new('Oauth2')))
298
- .response(new_response_handler
299
- .deserializer(APIHelper.method(:custom_type_deserializer))
300
- .deserialize_into(CapturedPayment.method(:from_hash))
301
- .is_api_response(true)
302
- .local_error('401',
303
- 'Authentication failed due to missing authorization header, or'\
304
- ' invalid authentication credentials.',
305
- ErrorException)
306
- .local_error('403',
307
- 'The request failed because the caller has insufficient'\
308
- ' permissions.',
309
- ErrorException)
310
- .local_error('404',
311
- 'The request failed because the resource does not exist.',
312
- ErrorException)
313
- .local_error('500',
314
- 'The request failed because an internal server error occurred.',
315
- APIException)
316
- .local_error('default',
317
- 'The error response.',
318
- ErrorException))
319
- .execute
320
- end
321
-
322
277
  # Refunds a captured payment, by ID. For a full refund, include an empty
323
278
  # payload in the JSON request body. For a partial refund, include an amount
324
279
  # object in the JSON request body.
@@ -344,7 +299,8 @@ module PaypalServerSdk
344
299
  # the API calls on behalf of a merchant, the partner must identify the
345
300
  # merchant using either a PayPal-Auth-Assertion header or an access token
346
301
  # with target_subject.
347
- # @param [RefundRequest] body Optional parameter: Example:
302
+ # @param [RefundRequest] body Optional parameter: TODO: type description
303
+ # here
348
304
  # @return [ApiResponse] the complete http response with raw body and status code.
349
305
  def refund_captured_payment(options = {})
350
306
  new_api_call_builder
@@ -398,6 +354,53 @@ module PaypalServerSdk
398
354
  .execute
399
355
  end
400
356
 
357
+ # Shows details for an authorized payment, by ID.
358
+ # @param [String] authorization_id Required parameter: The ID of the
359
+ # authorized payment for which to show details.
360
+ # @param [String] paypal_mock_response Optional parameter: PayPal's REST API
361
+ # uses a request header to invoke negative testing in the sandbox. This
362
+ # header configures the sandbox into a negative testing state for
363
+ # transactions that include the merchant.
364
+ # @param [String] paypal_auth_assertion Optional parameter: An
365
+ # API-caller-provided JSON Web Token (JWT) assertion that identifies the
366
+ # merchant. For details, see
367
+ # [PayPal-Auth-Assertion](/docs/api/reference/api-requests/#paypal-auth-asse
368
+ # rtion). Note:For three party transactions in which a partner is managing
369
+ # the API calls on behalf of a merchant, the partner must identify the
370
+ # merchant using either a PayPal-Auth-Assertion header or an access token
371
+ # with target_subject.
372
+ # @return [ApiResponse] the complete http response with raw body and status code.
373
+ def get_authorized_payment(options = {})
374
+ new_api_call_builder
375
+ .request(new_request_builder(HttpMethodEnum::GET,
376
+ '/v2/payments/authorizations/{authorization_id}',
377
+ Server::DEFAULT)
378
+ .template_param(new_parameter(options['authorization_id'], key: 'authorization_id')
379
+ .should_encode(true))
380
+ .header_param(new_parameter(options['paypal_mock_response'], key: 'PayPal-Mock-Response'))
381
+ .header_param(new_parameter(options['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion'))
382
+ .header_param(new_parameter('application/json', key: 'accept'))
383
+ .auth(Single.new('Oauth2')))
384
+ .response(new_response_handler
385
+ .deserializer(APIHelper.method(:custom_type_deserializer))
386
+ .deserialize_into(PaymentAuthorization.method(:from_hash))
387
+ .is_api_response(true)
388
+ .local_error('401',
389
+ 'Authentication failed due to missing authorization header, or'\
390
+ ' invalid authentication credentials.',
391
+ ErrorException)
392
+ .local_error('404',
393
+ 'The request failed because the resource does not exist.',
394
+ ErrorException)
395
+ .local_error('500',
396
+ 'The request failed because an internal server error occurred.',
397
+ APIException)
398
+ .local_error('default',
399
+ 'The error response.',
400
+ ErrorException))
401
+ .execute
402
+ end
403
+
401
404
  # Shows details for a refund, by ID.
402
405
  # @param [String] refund_id Required parameter: The PayPal-generated ID for
403
406
  # the refund for which to show details.
@@ -6,27 +6,19 @@
6
6
  module PaypalServerSdk
7
7
  # VaultController
8
8
  class VaultController < BaseController
9
- # Creates a Payment Token from the given payment source and adds it to the
10
- # Vault of the associated customer.
11
- # @param [PaymentTokenRequest] body Required parameter: Payment Token
12
- # creation with a financial instrument and an optional customer_id.
13
- # @param [String] paypal_request_id Optional parameter: The server stores
14
- # keys for 3 hours.
9
+ # Delete the payment token associated with the payment token id.
10
+ # @param [String] id Required parameter: ID of the payment token.
15
11
  # @return [ApiResponse] the complete http response with raw body and status code.
16
- def create_payment_token(options = {})
12
+ def delete_payment_token(id)
17
13
  new_api_call_builder
18
- .request(new_request_builder(HttpMethodEnum::POST,
19
- '/v3/vault/payment-tokens',
14
+ .request(new_request_builder(HttpMethodEnum::DELETE,
15
+ '/v3/vault/payment-tokens/{id}',
20
16
  Server::DEFAULT)
21
- .header_param(new_parameter('application/json', key: 'Content-Type'))
22
- .body_param(new_parameter(options['body']))
23
- .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
24
- .header_param(new_parameter('application/json', key: 'accept'))
25
- .body_serializer(proc do |param| param.to_json unless param.nil? end)
17
+ .template_param(new_parameter(id, key: 'id')
18
+ .should_encode(true))
26
19
  .auth(Single.new('Oauth2')))
27
20
  .response(new_response_handler
28
- .deserializer(APIHelper.method(:custom_type_deserializer))
29
- .deserialize_into(PaymentTokenResponse.method(:from_hash))
21
+ .is_response_void(true)
30
22
  .is_api_response(true)
31
23
  .local_error('400',
32
24
  'Request is not well-formed, syntactically incorrect, or'\
@@ -35,45 +27,34 @@ module PaypalServerSdk
35
27
  .local_error('403',
36
28
  'Authorization failed due to insufficient permissions.',
37
29
  ErrorException)
38
- .local_error('404',
39
- 'Request contains reference to resources that do not exist.',
40
- ErrorException)
41
- .local_error('422',
42
- 'The requested action could not be performed, semantically'\
43
- ' incorrect, or failed business validation.',
44
- ErrorException)
45
30
  .local_error('500',
46
31
  'An internal server error has occurred.',
47
32
  ErrorException))
48
33
  .execute
49
34
  end
50
35
 
51
- # Returns all payment tokens for a customer.
52
- # @param [String] customer_id Required parameter: A unique identifier
53
- # representing a specific customer in merchant's/partner's system or
54
- # records.
55
- # @param [Integer] page_size Optional parameter: A non-negative, non-zero
56
- # integer indicating the maximum number of results to return at one time.
57
- # @param [Integer] page Optional parameter: A non-negative, non-zero integer
58
- # representing the page of the results.
59
- # @param [TrueClass | FalseClass] total_required Optional parameter: A
60
- # boolean indicating total number of items (total_items) and pages
61
- # (total_pages) are expected to be returned in the response.
36
+ # Creates a Setup Token from the given payment source and adds it to the
37
+ # Vault of the associated customer.
38
+ # @param [SetupTokenRequest] body Required parameter: Setup Token creation
39
+ # with a instrument type optional financial instrument details and
40
+ # customer_id.
41
+ # @param [String] paypal_request_id Optional parameter: The server stores
42
+ # keys for 3 hours.
62
43
  # @return [ApiResponse] the complete http response with raw body and status code.
63
- def list_customer_payment_tokens(options = {})
44
+ def create_setup_token(options = {})
64
45
  new_api_call_builder
65
- .request(new_request_builder(HttpMethodEnum::GET,
66
- '/v3/vault/payment-tokens',
46
+ .request(new_request_builder(HttpMethodEnum::POST,
47
+ '/v3/vault/setup-tokens',
67
48
  Server::DEFAULT)
68
- .query_param(new_parameter(options['customer_id'], key: 'customer_id'))
69
- .query_param(new_parameter(options['page_size'], key: 'page_size'))
70
- .query_param(new_parameter(options['page'], key: 'page'))
71
- .query_param(new_parameter(options['total_required'], key: 'total_required'))
49
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
50
+ .body_param(new_parameter(options['body']))
51
+ .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
72
52
  .header_param(new_parameter('application/json', key: 'accept'))
53
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
73
54
  .auth(Single.new('Oauth2')))
74
55
  .response(new_response_handler
75
56
  .deserializer(APIHelper.method(:custom_type_deserializer))
76
- .deserialize_into(CustomerVaultPaymentTokensResponse.method(:from_hash))
57
+ .deserialize_into(SetupTokenResponse.method(:from_hash))
77
58
  .is_api_response(true)
78
59
  .local_error('400',
79
60
  'Request is not well-formed, syntactically incorrect, or'\
@@ -82,20 +63,24 @@ module PaypalServerSdk
82
63
  .local_error('403',
83
64
  'Authorization failed due to insufficient permissions.',
84
65
  ErrorException)
66
+ .local_error('422',
67
+ 'The requested action could not be performed, semantically'\
68
+ ' incorrect, or failed business validation.',
69
+ ErrorException)
85
70
  .local_error('500',
86
71
  'An internal server error has occurred.',
87
72
  ErrorException))
88
73
  .execute
89
74
  end
90
75
 
91
- # Returns a readable representation of vaulted payment source associated
92
- # with the payment token id.
93
- # @param [String] id Required parameter: ID of the payment token.
76
+ # Returns a readable representation of temporarily vaulted payment source
77
+ # associated with the setup token id.
78
+ # @param [String] id Required parameter: ID of the setup token.
94
79
  # @return [ApiResponse] the complete http response with raw body and status code.
95
- def get_payment_token(id)
80
+ def get_setup_token(id)
96
81
  new_api_call_builder
97
82
  .request(new_request_builder(HttpMethodEnum::GET,
98
- '/v3/vault/payment-tokens/{id}',
83
+ '/v3/vault/setup-tokens/{id}',
99
84
  Server::DEFAULT)
100
85
  .template_param(new_parameter(id, key: 'id')
101
86
  .should_encode(true))
@@ -103,7 +88,7 @@ module PaypalServerSdk
103
88
  .auth(Single.new('Oauth2')))
104
89
  .response(new_response_handler
105
90
  .deserializer(APIHelper.method(:custom_type_deserializer))
106
- .deserialize_into(PaymentTokenResponse.method(:from_hash))
91
+ .deserialize_into(SetupTokenResponse.method(:from_hash))
107
92
  .is_api_response(true)
108
93
  .local_error('403',
109
94
  'Authorization failed due to insufficient permissions.',
@@ -121,19 +106,27 @@ module PaypalServerSdk
121
106
  .execute
122
107
  end
123
108
 
124
- # Delete the payment token associated with the payment token id.
125
- # @param [String] id Required parameter: ID of the payment token.
109
+ # Creates a Payment Token from the given payment source and adds it to the
110
+ # Vault of the associated customer.
111
+ # @param [PaymentTokenRequest] body Required parameter: Payment Token
112
+ # creation with a financial instrument and an optional customer_id.
113
+ # @param [String] paypal_request_id Optional parameter: The server stores
114
+ # keys for 3 hours.
126
115
  # @return [ApiResponse] the complete http response with raw body and status code.
127
- def delete_payment_token(id)
116
+ def create_payment_token(options = {})
128
117
  new_api_call_builder
129
- .request(new_request_builder(HttpMethodEnum::DELETE,
130
- '/v3/vault/payment-tokens/{id}',
118
+ .request(new_request_builder(HttpMethodEnum::POST,
119
+ '/v3/vault/payment-tokens',
131
120
  Server::DEFAULT)
132
- .template_param(new_parameter(id, key: 'id')
133
- .should_encode(true))
121
+ .header_param(new_parameter('application/json', key: 'Content-Type'))
122
+ .body_param(new_parameter(options['body']))
123
+ .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
124
+ .header_param(new_parameter('application/json', key: 'accept'))
125
+ .body_serializer(proc do |param| param.to_json unless param.nil? end)
134
126
  .auth(Single.new('Oauth2')))
135
127
  .response(new_response_handler
136
- .is_response_void(true)
128
+ .deserializer(APIHelper.method(:custom_type_deserializer))
129
+ .deserialize_into(PaymentTokenResponse.method(:from_hash))
137
130
  .is_api_response(true)
138
131
  .local_error('400',
139
132
  'Request is not well-formed, syntactically incorrect, or'\
@@ -142,34 +135,45 @@ module PaypalServerSdk
142
135
  .local_error('403',
143
136
  'Authorization failed due to insufficient permissions.',
144
137
  ErrorException)
138
+ .local_error('404',
139
+ 'Request contains reference to resources that do not exist.',
140
+ ErrorException)
141
+ .local_error('422',
142
+ 'The requested action could not be performed, semantically'\
143
+ ' incorrect, or failed business validation.',
144
+ ErrorException)
145
145
  .local_error('500',
146
146
  'An internal server error has occurred.',
147
147
  ErrorException))
148
148
  .execute
149
149
  end
150
150
 
151
- # Creates a Setup Token from the given payment source and adds it to the
152
- # Vault of the associated customer.
153
- # @param [SetupTokenRequest] body Required parameter: Setup Token creation
154
- # with a instrument type optional financial instrument details and
155
- # customer_id.
156
- # @param [String] paypal_request_id Optional parameter: The server stores
157
- # keys for 3 hours.
151
+ # Returns all payment tokens for a customer.
152
+ # @param [String] customer_id Required parameter: A unique identifier
153
+ # representing a specific customer in merchant's/partner's system or
154
+ # records.
155
+ # @param [Integer] page_size Optional parameter: A non-negative, non-zero
156
+ # integer indicating the maximum number of results to return at one time.
157
+ # @param [Integer] page Optional parameter: A non-negative, non-zero integer
158
+ # representing the page of the results.
159
+ # @param [TrueClass | FalseClass] total_required Optional parameter: A
160
+ # boolean indicating total number of items (total_items) and pages
161
+ # (total_pages) are expected to be returned in the response.
158
162
  # @return [ApiResponse] the complete http response with raw body and status code.
159
- def create_setup_token(options = {})
163
+ def list_customer_payment_tokens(options = {})
160
164
  new_api_call_builder
161
- .request(new_request_builder(HttpMethodEnum::POST,
162
- '/v3/vault/setup-tokens',
165
+ .request(new_request_builder(HttpMethodEnum::GET,
166
+ '/v3/vault/payment-tokens',
163
167
  Server::DEFAULT)
164
- .header_param(new_parameter('application/json', key: 'Content-Type'))
165
- .body_param(new_parameter(options['body']))
166
- .header_param(new_parameter(options['paypal_request_id'], key: 'PayPal-Request-Id'))
168
+ .query_param(new_parameter(options['customer_id'], key: 'customer_id'))
169
+ .query_param(new_parameter(options['page_size'], key: 'page_size'))
170
+ .query_param(new_parameter(options['page'], key: 'page'))
171
+ .query_param(new_parameter(options['total_required'], key: 'total_required'))
167
172
  .header_param(new_parameter('application/json', key: 'accept'))
168
- .body_serializer(proc do |param| param.to_json unless param.nil? end)
169
173
  .auth(Single.new('Oauth2')))
170
174
  .response(new_response_handler
171
175
  .deserializer(APIHelper.method(:custom_type_deserializer))
172
- .deserialize_into(SetupTokenResponse.method(:from_hash))
176
+ .deserialize_into(CustomerVaultPaymentTokensResponse.method(:from_hash))
173
177
  .is_api_response(true)
174
178
  .local_error('400',
175
179
  'Request is not well-formed, syntactically incorrect, or'\
@@ -178,24 +182,20 @@ module PaypalServerSdk
178
182
  .local_error('403',
179
183
  'Authorization failed due to insufficient permissions.',
180
184
  ErrorException)
181
- .local_error('422',
182
- 'The requested action could not be performed, semantically'\
183
- ' incorrect, or failed business validation.',
184
- ErrorException)
185
185
  .local_error('500',
186
186
  'An internal server error has occurred.',
187
187
  ErrorException))
188
188
  .execute
189
189
  end
190
190
 
191
- # Returns a readable representation of temporarily vaulted payment source
192
- # associated with the setup token id.
193
- # @param [String] id Required parameter: ID of the setup token.
191
+ # Returns a readable representation of vaulted payment source associated
192
+ # with the payment token id.
193
+ # @param [String] id Required parameter: ID of the payment token.
194
194
  # @return [ApiResponse] the complete http response with raw body and status code.
195
- def get_setup_token(id)
195
+ def get_payment_token(id)
196
196
  new_api_call_builder
197
197
  .request(new_request_builder(HttpMethodEnum::GET,
198
- '/v3/vault/setup-tokens/{id}',
198
+ '/v3/vault/payment-tokens/{id}',
199
199
  Server::DEFAULT)
200
200
  .template_param(new_parameter(id, key: 'id')
201
201
  .should_encode(true))
@@ -203,7 +203,7 @@ module PaypalServerSdk
203
203
  .auth(Single.new('Oauth2')))
204
204
  .response(new_response_handler
205
205
  .deserializer(APIHelper.method(:custom_type_deserializer))
206
- .deserialize_into(SetupTokenResponse.method(:from_hash))
206
+ .deserialize_into(PaymentTokenResponse.method(:from_hash))
207
207
  .is_api_response(true)
208
208
  .local_error('403',
209
209
  'Authorization failed due to insufficient permissions.',
@@ -31,8 +31,8 @@ module PaypalServerSdk
31
31
  attr_accessor :links
32
32
 
33
33
  # The constructor.
34
- # @param [String] The reason for raising an exception.
35
- # @param [HttpResponse] The HttpReponse of the API call.
34
+ # @param [String] reason The reason for raising an exception.
35
+ # @param [HttpResponse] response The HttpReponse of the API call.
36
36
  def initialize(reason, response)
37
37
  super(reason, response)
38
38
  hash = APIHelper.json_deserialize(@response.raw_body)
@@ -40,9 +40,11 @@ module PaypalServerSdk
40
40
  end
41
41
 
42
42
  # Populates this object by extracting properties from a hash.
43
- # @param [Hash] The deserialized response sent by the server in the
43
+ # @param [Hash] hash The deserialized response sent by the server in the
44
44
  # response body.
45
45
  def unbox(hash)
46
+ return nil unless hash
47
+
46
48
  @name = hash.key?('name') ? hash['name'] : nil
47
49
  @message = hash.key?('message') ? hash['message'] : nil
48
50
  @debug_id = hash.key?('debug_id') ? hash['debug_id'] : nil
@@ -27,8 +27,8 @@ module PaypalServerSdk
27
27
  attr_accessor :error_uri
28
28
 
29
29
  # The constructor.
30
- # @param [String] The reason for raising an exception.
31
- # @param [HttpResponse] The HttpReponse of the API call.
30
+ # @param [String] reason The reason for raising an exception.
31
+ # @param [HttpResponse] response The HttpReponse of the API call.
32
32
  def initialize(reason, response)
33
33
  super(reason, response)
34
34
  hash = APIHelper.json_deserialize(@response.raw_body)
@@ -36,9 +36,11 @@ module PaypalServerSdk
36
36
  end
37
37
 
38
38
  # Populates this object by extracting properties from a hash.
39
- # @param [Hash] The deserialized response sent by the server in the
39
+ # @param [Hash] hash The deserialized response sent by the server in the
40
40
  # response body.
41
41
  def unbox(hash)
42
+ return nil unless hash
43
+
42
44
  @error = hash.key?('error') ? hash['error'] : nil
43
45
  @error_description =
44
46
  hash.key?('error_description') ? hash['error_description'] : SKIP
@@ -9,7 +9,8 @@ module PaypalServerSdk
9
9
  SKIP = Object.new
10
10
  private_constant :SKIP
11
11
 
12
- # The details about a customer in PayPal's system of record.
12
+ # This object represents a merchant’s customer, allowing them to store
13
+ # contact details, and track all payments associated with the same customer.
13
14
  # @return [CustomerInformation]
14
15
  attr_accessor :customer
15
16
 
@@ -0,0 +1,68 @@
1
+ # paypal_server_sdk
2
+ #
3
+ # This file was automatically generated by APIMATIC v2.0
4
+ # ( https://apimatic.io ).
5
+
6
+ module PaypalServerSdk
7
+ # Customizes the payer experience during the approval process for the payment.
8
+ class ApplePayExperienceContext < BaseModel
9
+ SKIP = Object.new
10
+ private_constant :SKIP
11
+
12
+ # Describes the URL.
13
+ # @return [String]
14
+ attr_accessor :return_url
15
+
16
+ # Describes the URL.
17
+ # @return [String]
18
+ attr_accessor :cancel_url
19
+
20
+ # A mapping from model property names to API property names.
21
+ def self.names
22
+ @_hash = {} if @_hash.nil?
23
+ @_hash['return_url'] = 'return_url'
24
+ @_hash['cancel_url'] = 'cancel_url'
25
+ @_hash
26
+ end
27
+
28
+ # An array for optional fields
29
+ def self.optionals
30
+ []
31
+ end
32
+
33
+ # An array for nullable fields
34
+ def self.nullables
35
+ []
36
+ end
37
+
38
+ def initialize(return_url:, cancel_url:)
39
+ @return_url = return_url
40
+ @cancel_url = cancel_url
41
+ end
42
+
43
+ # Creates an instance of the object from a hash.
44
+ def self.from_hash(hash)
45
+ return nil unless hash
46
+
47
+ # Extract variables from the hash.
48
+ return_url = hash.key?('return_url') ? hash['return_url'] : nil
49
+ cancel_url = hash.key?('cancel_url') ? hash['cancel_url'] : nil
50
+
51
+ # Create object from extracted values.
52
+ ApplePayExperienceContext.new(return_url: return_url,
53
+ cancel_url: cancel_url)
54
+ end
55
+
56
+ # Provides a human-readable string representation of the object.
57
+ def to_s
58
+ class_name = self.class.name.split('::').last
59
+ "<#{class_name} return_url: #{@return_url}, cancel_url: #{@cancel_url}>"
60
+ end
61
+
62
+ # Provides a debugging-friendly string with detailed object information.
63
+ def inspect
64
+ class_name = self.class.name.split('::').last
65
+ "<#{class_name} return_url: #{@return_url.inspect}, cancel_url: #{@cancel_url.inspect}>"
66
+ end
67
+ end
68
+ end