Class: PaypalServerSdk::OrdersController
- Inherits:
-
BaseController
- Object
- BaseController
- PaypalServerSdk::OrdersController
- Defined in:
- lib/paypal_server_sdk/controllers/orders_controller.rb
Overview
OrdersController
Constant Summary
Constants inherited from BaseController
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
-
#authorize_order(options = {}) ⇒ ApiResponse
Authorizes payment for an order.
-
#capture_order(options = {}) ⇒ ApiResponse
Captures payment for an order.
-
#confirm_order(options = {}) ⇒ ApiResponse
Payer confirms their intent to pay for the the Order with the given payment source.
-
#create_order(options = {}) ⇒ ApiResponse
Creates an order.
-
#create_order_tracking(options = {}) ⇒ ApiResponse
Adds tracking information for an Order.
-
#get_order(options = {}) ⇒ ApiResponse
Shows details for an order, by ID.
-
#patch_order(options = {}) ⇒ ApiResponse
Updates an order with a ‘CREATED` or `APPROVED` status.
-
#update_order_tracking(options = {}) ⇒ ApiResponse
Updates or cancels the tracking information for a PayPal order, 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
#authorize_order(options = {}) ⇒ ApiResponse
Authorizes payment for an order. To successfully authorize payment for an order, the buyer must first approve the order or a valid payment_source must be provided in the request. A buyer can approve the order upon being redirected to the rel:approve URL that was returned in the HATEOAS links in the create order response. Note: For error handling and troubleshooting, see Orders v2 errors. authorize. 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 6 hours. The API callers can request the times to up to 72 hours by speaking to their Account Manager. It is mandatory for all single-step create order calls (E.g. Create Order Request with payment source information like Card, PayPal.vault_id, PayPal.billing_agreement_id, etc). 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. description here API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. description here
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/orders_controller.rb', line 318 def ( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/checkout/orders/{id}/authorize', Server::DEFAULT) .template_param(new_parameter(['id'], key: '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_client_metadata_id'], key: 'PayPal-Client-Metadata-Id')) .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(OrderAuthorizeResponse.method(:from_hash)) .is_api_response(true) .local_error('400', 'Request is not well-formed, 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 authorized payment failed due to insufficient permissions'\ '.', ErrorException) .local_error('404', 'The specified resource does not exist.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('500', 'An internal server error has occurred.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#capture_order(options = {}) ⇒ ApiResponse
Captures payment for an order. To successfully capture payment for an order, the buyer must first approve the order or a valid payment_source must be provided in the request. A buyer can approve the order upon being redirected to the rel:approve URL that was returned in the HATEOAS links in the create order response. Note: For error handling and troubleshooting, see Orders v2 errors. capture a payment. 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 6 hours. The API callers can request the times to up to 72 hours by speaking to their Account Manager. It is mandatory for all single-step create order calls (E.g. Create Order Request with payment source information like Card, PayPal.vault_id, PayPal.billing_agreement_id, etc). 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. description here API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. description here
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 399 def capture_order( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/checkout/orders/{id}/capture', Server::DEFAULT) .template_param(new_parameter(['id'], key: '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_client_metadata_id'], key: 'PayPal-Client-Metadata-Id')) .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(Order.method(:from_hash)) .is_api_response(true) .local_error('400', 'Request is not well-formed, 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 authorized payment failed due to insufficient permissions'\ '.', ErrorException) .local_error('404', 'The specified resource does not exist.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('500', 'An internal server error has occurred.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#confirm_order(options = {}) ⇒ ApiResponse
Payer confirms their intent to pay for the the Order with the given payment source. payer confirms their intent to pay. description here API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. 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. description here
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 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 247 def confirm_order( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/checkout/orders/{id}/confirm-payment-source', Server::DEFAULT) .template_param(new_parameter(['id'], key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter(['paypal_client_metadata_id'], key: 'PayPal-Client-Metadata-Id')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .header_param(new_parameter(['prefer'], key: 'Prefer')) .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(Order.method(:from_hash)) .is_api_response(true) .local_error('400', 'Request is not well-formed, syntactically incorrect, or'\ ' violates schema.', ErrorException) .local_error('403', 'Authorization failed due to insufficient permissions.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('500', 'An internal server error has occurred.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#create_order(options = {}) ⇒ ApiResponse
Creates an order. Merchants and partners can add Level 2 and 3 data to payments to reduce risk and payment processing costs. For more information about processing payments, see checkout or multiparty checkout. Note: For error handling and troubleshooting, see Orders v2 errors. here 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 6 hours. The API callers can request the times to up to 72 hours by speaking to their Account Manager. It is mandatory for all single-step create order calls (E.g. Create Order Request with payment source information like Card, PayPal.vault_id, PayPal.billing_agreement_id, etc). type description here description here 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.
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 39 def create_order( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/checkout/orders', Server::DEFAULT) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(['body'])) .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(['paypal_partner_attribution_id'], key: 'PayPal-Partner-Attribution-Id')) .header_param(new_parameter(['paypal_client_metadata_id'], key: 'PayPal-Client-Metadata-Id')) .header_param(new_parameter(['prefer'], key: 'Prefer')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .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(Order.method(:from_hash)) .is_api_response(true) .local_error('400', 'Request is not well-formed, syntactically incorrect, or'\ ' violates schema.', ErrorException) .local_error('401', 'Authentication failed due to missing authorization header, or'\ ' invalid authentication credentials.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#create_order_tracking(options = {}) ⇒ ApiResponse
Adds tracking information for an Order. tracking information is associated with. description here API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion.
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 457 def create_order_tracking( = {}) @api_call .request(new_request_builder(HttpMethodEnum::POST, '/v2/checkout/orders/{id}/track', Server::DEFAULT) .template_param(new_parameter(['id'], key: 'id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .body_param(new_parameter(['body'])) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .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(Order.method(:from_hash)) .is_api_response(true) .local_error('400', 'Request is not well-formed, syntactically incorrect, or'\ ' violates schema.', ErrorException) .local_error('403', 'Authorization failed due to insufficient permissions.', ErrorException) .local_error('404', 'The specified resource does not exist.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('500', 'An internal server error has occurred.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#get_order(options = {}) ⇒ ApiResponse
Shows details for an order, by ID. Note: For error handling and troubleshooting, see Orders v2 errors. 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. fields that should be returned for the order. Valid filter field is ‘payment_source`.
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 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 92 def get_order( = {}) @api_call .request(new_request_builder(HttpMethodEnum::GET, '/v2/checkout/orders/{id}', Server::DEFAULT) .template_param(new_parameter(['id'], key: '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')) .query_param(new_parameter(['fields'], key: 'fields')) .header_param(new_parameter('application/json', key: 'accept')) .auth(Single.new('Oauth2'))) .response(new_response_handler .deserializer(APIHelper.method(:custom_type_deserializer)) .deserialize_into(Order.method(:from_hash)) .is_api_response(true) .local_error('401', 'Authentication failed due to missing authorization header, or'\ ' invalid authentication credentials.', ErrorException) .local_error('404', 'The specified resource does not exist.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#patch_order(options = {}) ⇒ ApiResponse
Updates an order with a ‘CREATED` or `APPROVED` status. You cannot update an order with the `COMPLETED` status.<br/><br/>To make an update, you must provide a `reference_id`. If you omit this value with an order that contains only one purchase unit, PayPal sets the value to `default` which enables you to use the path: \"/purchase_units/@reference_id=='default'/{attribute-or-object}\"</ code>. Merchants and partners can add Level 2 and 3 data to payments to reduce risk and payment processing costs. For more information about processing payments, see <a href="https://developer.paypal.com/docs/checkout/advanced/processing/">che ckout</a> or <a href="https://developer.paypal.com/docs/multiparty/checkout/advanced/proce ssing/">multiparty checkout</a>.<blockquote><strong>Note:</strong> For error handling and troubleshooting, see <a href="https://developer.paypal.com/api/rest/reference/orders/v2/errors/#pa tch-order">Orders v2 errors</a>.</blockquote>Patchable attributes or objects:<br/><br/><table><thead><th>Attribute</th><th>Op</th><th>Notes</th ></thead><tbody><tr><td><code>intent</td><td>replace</td><td></td>< /tr><tr><td>payer</td><td>replace, add</td><td>Using replace op for payer will replace the whole payer object with the value sent in request.</td></tr><tr><td>purchase_units</td><td>replace, add</td><td></td></tr><tr><td>purchase_units[].custom_id</td> <td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].description </td><td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].payee.email </td><td>replace</td><td></td></tr><tr><td>purchase_units[].shipping .name</td><td>replace, add</td><td></td></tr><tr><td>purchase_units[].shipping.email_addres s</td><td>replace, add</td><td></td></tr><tr><td>purchase_units[].shipping.phone_number </td><td>replace, add</td><td></td></tr><tr><td>purchase_units[].shipping.options</cod e></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.address</cod e></td><td>replace, add</td><td></td></tr><tr><td><code>purchase_units[].shipping.type< /td><td>replace, add</td><td></td></tr><tr><td>purchase_units[].soft_descriptor</code ></td><td>replace, remove</td><td></td></tr><tr><td><code>purchase_units[].amount</td> <td>replace</td><td></td></tr><tr><td>purchase_units[].items< /td><td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].invoice_id< /td><td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].payment_instructio n</td><td>replace</td><td></td></tr><tr><td>purchase_units[]. payment_instruction.disbursement_mode</td><td>replace</td><td>By default, disbursement_mode is INSTANT.</td></tr><tr><td>purchase_units[].payment_inst ruction.payee_receivable_fx_rate_id</td><td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].payment_instructio n.platform_fees</td><td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].supplementary_data .airline</td><td>replace, add, remove</td><td></td></tr><tr><td>purchase_units[].supplementary_data .card</td><td>replace, add, remove</td><td></td></tr><tr><td>application_context.client_configur ation</td><td>replace, add</td><td></td></tr></tbody></table> 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. here
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 217 218 219 220 221 222 223 224 225 226 227 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 192 def patch_order( = {}) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/v2/checkout/orders/{id}', Server::DEFAULT) .template_param(new_parameter(['id'], key: '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_auth_assertion'], key: 'PayPal-Auth-Assertion')) .body_param(new_parameter(['body'])) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('Oauth2'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('400', 'Request is not well-formed, syntactically incorrect, or'\ ' violates schema.', ErrorException) .local_error('401', 'Authentication failed due to missing authorization header, or'\ ' invalid authentication credentials.', ErrorException) .local_error('404', 'The specified resource does not exist.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |
#update_order_tracking(options = {}) ⇒ ApiResponse
Updates or cancels the tracking information for a PayPal order, by ID. Updatable attributes or objects: Attribute Op Notes items replace Using replace op for items will replace the entire items object with the value sent in request. notify_payer replace, add status replace Only patching status to CANCELLED is currently supported. tracking information is associated with. API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. here
511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 |
# File 'lib/paypal_server_sdk/controllers/orders_controller.rb', line 511 def update_order_tracking( = {}) @api_call .request(new_request_builder(HttpMethodEnum::PATCH, '/v2/checkout/orders/{id}/trackers/{tracker_id}', Server::DEFAULT) .template_param(new_parameter(['id'], key: 'id') .should_encode(true)) .template_param(new_parameter(['tracker_id'], key: 'tracker_id') .should_encode(true)) .header_param(new_parameter('application/json', key: 'Content-Type')) .header_param(new_parameter(['paypal_auth_assertion'], key: 'PayPal-Auth-Assertion')) .body_param(new_parameter(['body'])) .body_serializer(proc do |param| param.to_json unless param.nil? end) .auth(Single.new('Oauth2'))) .response(new_response_handler .is_response_void(true) .is_api_response(true) .local_error('400', 'Request is not well-formed, syntactically incorrect, or'\ ' violates schema.', ErrorException) .local_error('403', 'Authorization failed due to insufficient permissions.', ErrorException) .local_error('404', 'The specified resource does not exist.', ErrorException) .local_error('422', 'The requested action could not be performed, semantically'\ ' incorrect, or failed business validation.', ErrorException) .local_error('500', 'An internal server error has occurred.', ErrorException) .local_error('default', 'The error response.', ErrorException)) .execute end |