Class: PaypalServerSdk::PaymentsController
- Inherits:
-
BaseController
- Object
- BaseController
- PaypalServerSdk::PaymentsController
- Defined in:
- lib/paypal_server_sdk/controllers/payments_controller.rb
Overview
PaymentsController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#capture_authorized_payment(options = {}) ⇒ ApiResponse
Captures an authorized payment, by ID.
-
#get_authorized_payment(options = {}) ⇒ ApiResponse
Shows details for an authorized payment, by ID.
-
#get_captured_payment(options = {}) ⇒ ApiResponse
Shows details for a captured payment, by ID.
-
#get_refund(options = {}) ⇒ ApiResponse
Shows details for a refund, by ID.
-
#reauthorize_payment(options = {}) ⇒ ApiResponse
Reauthorizes an authorized PayPal account payment, by ID.
-
#refund_captured_payment(options = {}) ⇒ ApiResponse
Refunds a captured payment, by ID.
-
#void_payment(options = {}) ⇒ ApiResponse
Voids, or cancels, an authorized payment, by ID.
Methods inherited from BaseController
#initialize, #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
#capture_authorized_payment(options = {}) ⇒ ApiResponse
Captures an authorized payment, by ID. ID for the authorized payment to capture. uses a request header to invoke negative testing in the sandbox. This header configures the sandbox into a negative testing state for transactions that include the merchant. keys for 45 days. upon successful completion of the request. Value is: 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. return=representation. The server returns a complete resource representation, including the current state of the resource. 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). Note: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. here
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 86 def ( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/payments/authorizations/{authorization_id}/capture', Server::DEFAULT) .template_param(new_parameter(['authorization_id'], key: 'authorization_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter(['paypal_mock_response'], key: 'PayPal-Mock-Response')) .header_param(new_parameter(['paypal_request_id'], key: 'PayPal-Request-Id')) .header_param(new_parameter(['prefer'], key: 'Prefer')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .body_param(new_parameter(['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 |
#get_authorized_payment(options = {}) ⇒ ApiResponse
Shows details for an authorized payment, by ID. authorized payment for which to show details. uses a request header to invoke negative testing in the sandbox. This header configures the sandbox into a negative testing state for transactions that include the merchant. 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). Note: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.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 25 def ( = {}) @api_call .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(['paypal_mock_response'], key: 'PayPal-Mock-Response')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .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 |
#get_captured_payment(options = {}) ⇒ ApiResponse
Shows details for a captured payment, by ID. the captured payment for which to show details. uses a request header to invoke negative testing in the sandbox. This header configures the sandbox into a negative testing state for transactions that include the merchant.
297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 297 def get_captured_payment( = {}) @api_call .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(['paypal_mock_response'], key: 'PayPal-Mock-Response')) .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 |
#get_refund(options = {}) ⇒ ApiResponse
Shows details for a refund, by ID. the refund for which to show details. uses a request header to invoke negative testing in the sandbox. This header configures the sandbox into a negative testing state for transactions that include the merchant. 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). Note: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.
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 427 def get_refund( = {}) @api_call .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(['paypal_mock_response'], key: 'PayPal-Mock-Response')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .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 |
#reauthorize_payment(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. 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. A reauthorized payment itself has a new honor period of three days. 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. Supports only the ‘amount` request parameter. ID for the authorized payment to reauthorize. keys for 45 days. upon successful completion of the request. Value is: 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. return=representation. The server returns a complete resource representation, including the current state of the resource. 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). Note: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. description here
171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 171 def ( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/payments/authorizations/{authorization_id}/reauthorize', Server::DEFAULT) .template_param(new_parameter(['authorization_id'], key: 'authorization_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter(['paypal_request_id'], key: 'PayPal-Request-Id')) .header_param(new_parameter(['prefer'], key: 'Prefer')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .body_param(new_parameter(['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 |
#refund_captured_payment(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. uses a request header to invoke negative testing in the sandbox. This header configures the sandbox into a negative testing state for transactions that include the merchant. keys for 45 days. upon successful completion of the request. Value is: 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. return=representation. The server returns a complete resource representation, including the current state of the resource. 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). Note: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. here
359 360 361 362 363 364 365 366 367 368 369 370 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 403 404 405 406 407 408 409 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 359 def refund_captured_payment( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/payments/captures/{capture_id}/refund', Server::DEFAULT) .template_param(new_parameter(['capture_id'], key: 'capture_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter(['paypal_mock_response'], key: 'PayPal-Mock-Response')) .header_param(new_parameter(['paypal_request_id'], key: 'PayPal-Request-Id')) .header_param(new_parameter(['prefer'], key: 'Prefer')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .body_param(new_parameter(['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 |
#void_payment(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. uses a request header to invoke negative testing in the sandbox. This header configures the sandbox into a negative testing state for transactions that include the merchant. 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). Note: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. keys for 45 days. upon successful completion of the request. Value is: 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. return=representation. The server returns a complete resource representation, including the current state of the resource.
243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 |
# File 'lib/paypal_server_sdk/controllers/payments_controller.rb', line 243 def void_payment( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/payments/authorizations/{authorization_id}/void', Server::DEFAULT) .template_param(new_parameter(['authorization_id'], key: 'authorization_id') .should_encode(true)) .header_param(new_parameter(['paypal_mock_response'], key: 'PayPal-Mock-Response')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .header_param(new_parameter(['paypal_request_id'], key: 'PayPal-Request-Id')) .header_param(new_parameter(['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('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 |