Class: PaypalServerSdk::PaymentsController

Inherits:
BaseController show all
Defined in:
lib/paypal_server_sdk/controllers/payments_controller.rb

Overview

PaymentsController

Constant Summary

Constants inherited from BaseController

BaseController::GLOBAL_ERRORS

Instance Attribute Summary

Attributes inherited from BaseController

#config, #http_call_back

Instance Method Summary collapse

Methods inherited from BaseController

#initialize, #new_api_call_builder, #new_parameter, #new_request_builder, #new_response_handler, user_agent, user_agent_parameters

Constructor Details

This class inherits a constructor from PaypalServerSdk::BaseController

Instance Method Details

#authorizations_capture(options = {}) ⇒ ApiResponse

Captures an authorized payment, by ID. ID for the authorized payment to capture. keys for 45 days. upon successful completion of the request. Value is:<ul><li>return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links.</li><li>return=representation. The server returns a complete resource representation, including the current state of the resource.</li></ul>

Parameters:

  • authorization_id (String)

    Required parameter: The PayPal-generated

  • pay_pal_request_id (String)

    Optional parameter: The server stores

  • prefer (String)

    Optional parameter: The preferred server response

  • body (CaptureRequest)

    Optional parameter: Example:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 61

def authorizations_capture(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/payments/authorizations/{authorization_id}/capture',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['authorization_id'], key: 'authorization_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(options['pay_pal_request_id'], key: 'PayPal-Request-Id'))
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CapturedPayment.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'The request failed because it is not well-formed or is'\
                              ' syntactically incorrect or violates schema.',
                             ErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('409',
                             'The server has detected a conflict while processing this'\
                              ' request.',
                             ErrorException)
                .local_error('422',
                             'The request failed because it is semantically incorrect or'\
                              ' failed business validation.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end

#authorizations_get(authorization_id) ⇒ ApiResponse

Shows details for an authorized payment, by ID. authorized payment for which to show details.

Parameters:

  • authorization_id (String)

    Required parameter: The ID of the

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 13

def authorizations_get(authorization_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/payments/authorizations/{authorization_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(authorization_id, key: 'authorization_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentAuthorization.method(:from_hash))
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end

#authorizations_reauthorize(options = {}) ⇒ ApiResponse

Reauthorizes an authorized PayPal account payment, by ID. To ensure that funds are still available, reauthorize a payment after its initial three-day honor period expires. Within the 29-day authorization period, you can issue multiple re-authorizations after the honor period expires.<br/><br/>If 30 days have transpired since the date of the original authorization, you must create an authorized payment instead of reauthorizing the original authorized payment.<br/><br/>A reauthorized payment itself has a new honor period of three days.<br/><br/>You can reauthorize an authorized payment from 4 to 29 days after the 3-day honor period. The allowed amount depends on context and geography, for example in US it is up to 115% of the original authorized amount, not to exceed an increase of $75 USD.<br/><br/>Supports only the ‘amount` request parameter.<blockquote><strong>Note:</strong> This request is currently not supported for Partner use cases.</blockquote> ID for the authorized payment to reauthorize. keys for 45 days. upon successful completion of the request. Value is:<ul><li>return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links.</li><li>return=representation. The server returns a complete resource representation, including the current state of the resource.</li></ul>

Parameters:

  • authorization_id (String)

    Required parameter: The PayPal-generated

  • pay_pal_request_id (String)

    Optional parameter: The server stores

  • prefer (String)

    Optional parameter: The preferred server response

  • body (ReauthorizeRequest)

    Optional parameter: Example:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 139

def authorizations_reauthorize(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/payments/authorizations/{authorization_id}/reauthorize',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['authorization_id'], key: 'authorization_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(options['pay_pal_request_id'], key: 'PayPal-Request-Id'))
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentAuthorization.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'The request failed because it is not well-formed or is'\
                              ' syntactically incorrect or violates schema.',
                             ErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('422',
                             'The request failed because it either is semantically incorrect'\
                              ' or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end

#authorizations_void(options = {}) ⇒ ApiResponse

Voids, or cancels, an authorized payment, by ID. You cannot void an authorized payment that has been fully captured. ID for the authorized payment to void. API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see [PayPal-Auth-Assertion](/docs/api/reference/api-requests/#paypal-auth-asse rtion).<blockquote><strong>Note:</strong>For three party transactions in which a partner is managing the API calls on behalf of a merchant, the partner must identify the merchant using either a PayPal-Auth-Assertion header or an access token with target_subject.</blockquote> upon successful completion of the request. Value is:<ul><li>return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links.</li><li>return=representation. The server returns a complete resource representation, including the current state of the resource.</li></ul>

Parameters:

  • authorization_id (String)

    Required parameter: The PayPal-generated

  • pay_pal_auth_assertion (String)

    Optional parameter: An

  • prefer (String)

    Optional parameter: The preferred server response

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 206

def authorizations_void(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/payments/authorizations/{authorization_id}/void',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['authorization_id'], key: 'authorization_id')
                                .should_encode(true))
               .header_param(new_parameter(options['pay_pal_auth_assertion'], key: 'PayPal-Auth-Assertion'))
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .is_nullable_response(true)
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(PaymentAuthorization.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'The request failed because it is not well-formed or is'\
                              ' syntactically incorrect or violates schema.',
                             ErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('409',
                             'The request failed because a previous call for the given'\
                              ' resource is in progress.',
                             ErrorException)
                .local_error('422',
                             'The request failed because it either is semantically incorrect'\
                              ' or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end

#captures_get(capture_id) ⇒ ApiResponse

Shows details for a captured payment, by ID. the captured payment for which to show details.

Parameters:

  • capture_id (String)

    Required parameter: The PayPal-generated ID for

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 258

def captures_get(capture_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/payments/captures/{capture_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(capture_id, key: 'capture_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(CapturedPayment.method(:from_hash))
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end

#captures_refund(options = {}) ⇒ ApiResponse

Refunds a captured payment, by ID. For a full refund, include an empty payload in the JSON request body. For a partial refund, include an amount object in the JSON request body. the captured payment to refund. keys for 45 days. upon successful completion of the request. Value is:<ul><li>return=minimal. The server returns a minimal response to optimize communication between the API caller and the server. A minimal response includes the id, status and HATEOAS links.</li><li>return=representation. The server returns a complete resource representation, including the current state of the resource.</li></ul> API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see [PayPal-Auth-Assertion](/docs/api/reference/api-requests/#paypal-auth-asse rtion).<blockquote><strong>Note:</strong>For three party transactions in which a partner is managing the API calls on behalf of a merchant, the partner must identify the merchant using either a PayPal-Auth-Assertion header or an access token with target_subject.</blockquote>

Parameters:

  • capture_id (String)

    Required parameter: The PayPal-generated ID for

  • pay_pal_request_id (String)

    Optional parameter: The server stores

  • prefer (String)

    Optional parameter: The preferred server response

  • pay_pal_auth_assertion (String)

    Optional parameter: An

  • body (RefundRequest)

    Optional parameter: Example:

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 316

def captures_refund(options = {})
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::POST,
                                 '/v2/payments/captures/{capture_id}/refund',
                                 Server::DEFAULT)
               .template_param(new_parameter(options['capture_id'], key: 'capture_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'Content-Type'))
               .header_param(new_parameter(options['pay_pal_request_id'], key: 'PayPal-Request-Id'))
               .header_param(new_parameter(options['prefer'], key: 'Prefer'))
               .header_param(new_parameter(options['pay_pal_auth_assertion'], key: 'PayPal-Auth-Assertion'))
               .body_param(new_parameter(options['body']))
               .header_param(new_parameter('application/json', key: 'accept'))
               .body_serializer(proc do |param| param.to_json unless param.nil? end)
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Refund.method(:from_hash))
                .is_api_response(true)
                .local_error('400',
                             'The request failed because it is not well-formed or is'\
                              ' syntactically incorrect or violates schema.',
                             ErrorException)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('409',
                             'The request failed because a previous call for the given'\
                              ' resource is in progress.',
                             ErrorException)
                .local_error('422',
                             'The request failed because it either is semantically incorrect'\
                              ' or failed business validation.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end

#refunds_get(refund_id) ⇒ ApiResponse

Shows details for a refund, by ID. the refund for which to show details.

Parameters:

  • refund_id (String)

    Required parameter: The PayPal-generated ID for

Returns:

  • (ApiResponse)

    the complete http response with raw body and status code.



371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 371

def refunds_get(refund_id)
  new_api_call_builder
    .request(new_request_builder(HttpMethodEnum::GET,
                                 '/v2/payments/refunds/{refund_id}',
                                 Server::DEFAULT)
               .template_param(new_parameter(refund_id, key: 'refund_id')
                                .should_encode(true))
               .header_param(new_parameter('application/json', key: 'accept'))
               .auth(Single.new('Oauth2')))
    .response(new_response_handler
                .deserializer(APIHelper.method(:custom_type_deserializer))
                .deserialize_into(Refund.method(:from_hash))
                .is_api_response(true)
                .local_error('401',
                             'Authentication failed due to missing authorization header, or'\
                              ' invalid authentication credentials.',
                             ErrorException)
                .local_error('403',
                             'The request failed because the caller has insufficient'\
                              ' permissions.',
                             ErrorException)
                .local_error('404',
                             'The request failed because the resource does not exist.',
                             ErrorException)
                .local_error('500',
                             'The request failed because an internal server error occurred.',
                             APIException)
                .local_error('default',
                             'The error response.',
                             ErrorException))
    .execute
end