# Orders Use the `/orders` resource to create, update, retrieve, authorize, capture and track orders. ```php $ordersController = $client->getOrdersController(); ``` ## Class Name `OrdersController` ## Methods * [Orders Create](../../doc/controllers/orders.md#orders-create) * [Orders Get](../../doc/controllers/orders.md#orders-get) * [Orders Patch](../../doc/controllers/orders.md#orders-patch) * [Orders Confirm](../../doc/controllers/orders.md#orders-confirm) * [Orders Authorize](../../doc/controllers/orders.md#orders-authorize) * [Orders Capture](../../doc/controllers/orders.md#orders-capture) * [Orders Track Create](../../doc/controllers/orders.md#orders-track-create) * [Orders Trackers Patch](../../doc/controllers/orders.md#orders-trackers-patch) # Orders Create 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.
```php function ordersCreate(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `body` | [`OrderRequest`](../../doc/models/order-request.md) | Body, Required | - | | `paypalRequestId` | `?string` | Header, Optional | The server stores 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).
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `108` | | `paypalPartnerAttributionId` | `?string` | Header, Optional | **Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36` | | `paypalClientMetadataId` | `?string` | Header, Optional | **Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36` | | `prefer` | `?string` | Header, Optional | The preferred server response upon successful completion of the request. Value is:
**Default**: `'return=minimal'`
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `25`, *Pattern*: `^[a-zA-Z=,-]*$` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. The `getResult()` method on this instance returns the response data which is of type [`Order`](../../doc/models/order.md). ## Example Usage ```php $collect = [ 'body' => OrderRequestBuilder::init( CheckoutPaymentIntent::CAPTURE, [ PurchaseUnitRequestBuilder::init( AmountWithBreakdownBuilder::init( 'currency_code6', 'value0' )->build() )->build() ] )->build(), 'prefer' => 'return=minimal' ]; $apiResponse = $ordersController->ordersCreate($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 401 | Authentication failed due to missing authorization header, or invalid authentication credentials. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Get Shows details for an order, by ID.
Note: For error handling and troubleshooting, see Orders v2 errors.
```php function ordersGet(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order for which to show details.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | | `fields` | `?string` | Query, Optional | A comma-separated list of fields that should be returned for the order. Valid filter field is `payment_source`.
**Constraints**: *Pattern*: `^[a-z_]*$` | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. The `getResult()` method on this instance returns the response data which is of type [`Order`](../../doc/models/order.md). ## Example Usage ```php $collect = [ 'id' => 'id0' ]; $apiResponse = $ordersController->ordersGet($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 401 | Authentication failed due to missing authorization header, or invalid authentication credentials. | [`ErrorException`](../../doc/models/error-exception.md) | | 404 | The specified resource does not exist. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Patch Updates an order with a `CREATED` or `APPROVED` status. You cannot update an order with the `COMPLETED` status.

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}\". 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.
Patchable attributes or objects:

AttributeOpNotes
intentreplace
payerreplace, addUsing replace op for payer will replace the whole payer object with the value sent in request.
purchase_unitsreplace, add
purchase_units[].custom_idreplace, add, remove
purchase_units[].descriptionreplace, add, remove
purchase_units[].payee.emailreplace
purchase_units[].shipping.namereplace, add
purchase_units[].shipping.email_addressreplace, add
purchase_units[].shipping.phone_numberreplace, add
purchase_units[].shipping.optionsreplace, add
purchase_units[].shipping.addressreplace, add
purchase_units[].shipping.typereplace, add
purchase_units[].soft_descriptorreplace, remove
purchase_units[].amountreplace
purchase_units[].itemsreplace, add, remove
purchase_units[].invoice_idreplace, add, remove
purchase_units[].payment_instructionreplace
purchase_units[].payment_instruction.disbursement_modereplaceBy default, disbursement_mode is INSTANT.
purchase_units[].payment_instruction.payee_receivable_fx_rate_idreplace, add, remove
purchase_units[].payment_instruction.platform_feesreplace, add, remove
purchase_units[].supplementary_data.airlinereplace, add, remove
purchase_units[].supplementary_data.cardreplace, add, remove
application_context.client_configurationreplace, add
```php function ordersPatch(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order to update.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | | `body` | [`?(Patch[])`](../../doc/models/patch.md) | Body, Optional | - | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. ## Example Usage ```php $collect = [ 'id' => 'id0', 'body' => [ PatchBuilder::init( PatchOp::ADD )->build() ] ]; $apiResponse = $ordersController->ordersPatch($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 401 | Authentication failed due to missing authorization header, or invalid authentication credentials. | [`ErrorException`](../../doc/models/error-exception.md) | | 404 | The specified resource does not exist. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Confirm Payer confirms their intent to pay for the the Order with the given payment source. ```php function ordersConfirm(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order for which the payer confirms their intent to pay.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `paypalClientMetadataId` | `?string` | Header, Optional | **Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | | `prefer` | `?string` | Header, Optional | The preferred server response upon successful completion of the request. Value is:
**Default**: `'return=minimal'`
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `25`, *Pattern*: `^[a-zA-Z=]*$` | | `body` | [`?ConfirmOrderRequest`](../../doc/models/confirm-order-request.md) | Body, Optional | - | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. The `getResult()` method on this instance returns the response data which is of type [`Order`](../../doc/models/order.md). ## Example Usage ```php $collect = [ 'id' => 'id0', 'prefer' => 'return=minimal' ]; $apiResponse = $ordersController->ordersConfirm($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 403 | Authorization failed due to insufficient permissions. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | 500 | An internal server error has occurred. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Authorize 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.
```php function ordersAuthorize(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order for which to authorize.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `paypalRequestId` | `?string` | Header, Optional | The server stores 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).
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `108` | | `prefer` | `?string` | Header, Optional | The preferred server response upon successful completion of the request. Value is:
**Default**: `'return=minimal'`
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `25`, *Pattern*: `^[a-zA-Z=,-]*$` | | `paypalClientMetadataId` | `?string` | Header, Optional | **Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | | `body` | [`?OrderAuthorizeRequest`](../../doc/models/order-authorize-request.md) | Body, Optional | - | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. The `getResult()` method on this instance returns the response data which is of type [`OrderAuthorizeResponse`](../../doc/models/order-authorize-response.md). ## Example Usage ```php $collect = [ 'id' => 'id0', 'prefer' => 'return=minimal' ]; $apiResponse = $ordersController->ordersAuthorize($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 401 | Authentication failed due to missing authorization header, or invalid authentication credentials. | [`ErrorException`](../../doc/models/error-exception.md) | | 403 | The authorized payment failed due to insufficient permissions. | [`ErrorException`](../../doc/models/error-exception.md) | | 404 | The specified resource does not exist. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | 500 | An internal server error has occurred. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Capture 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.
```php function ordersCapture(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order for which to capture a payment.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `paypalRequestId` | `?string` | Header, Optional | The server stores 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).
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `108` | | `prefer` | `?string` | Header, Optional | The preferred server response upon successful completion of the request. Value is:
**Default**: `'return=minimal'`
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `25`, *Pattern*: `^[a-zA-Z=,-]*$` | | `paypalClientMetadataId` | `?string` | Header, Optional | **Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | | `body` | [`?OrderCaptureRequest`](../../doc/models/order-capture-request.md) | Body, Optional | - | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. The `getResult()` method on this instance returns the response data which is of type [`Order`](../../doc/models/order.md). ## Example Usage ```php $collect = [ 'id' => 'id0', 'prefer' => 'return=minimal' ]; $apiResponse = $ordersController->ordersCapture($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 401 | Authentication failed due to missing authorization header, or invalid authentication credentials. | [`ErrorException`](../../doc/models/error-exception.md) | | 403 | The authorized payment failed due to insufficient permissions. | [`ErrorException`](../../doc/models/error-exception.md) | | 404 | The specified resource does not exist. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | 500 | An internal server error has occurred. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Track Create Adds tracking information for an Order. ```php function ordersTrackCreate(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order that the tracking information is associated with.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `body` | [`OrderTrackerRequest`](../../doc/models/order-tracker-request.md) | Body, Required | - | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. The `getResult()` method on this instance returns the response data which is of type [`Order`](../../doc/models/order.md). ## Example Usage ```php $collect = [ 'id' => 'id0', 'body' => OrderTrackerRequestBuilder::init( 'capture_id8' ) ->notifyPayer(false) ->build() ]; $apiResponse = $ordersController->ordersTrackCreate($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 403 | Authorization failed due to insufficient permissions. | [`ErrorException`](../../doc/models/error-exception.md) | | 404 | The specified resource does not exist. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | 500 | An internal server error has occurred. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) | # Orders Trackers Patch Updates or cancels the tracking information for a PayPal order, by ID. Updatable attributes or objects:

AttributeOpNotes
itemsreplaceUsing replace op for items will replace the entire items object with the value sent in request.
notify_payerreplace, add
statusreplaceOnly patching status to CANCELLED is currently supported.
```php function ordersTrackersPatch(array $options): ApiResponse ``` ## Parameters | Parameter | Type | Tags | Description | | --- | --- | --- | --- | | `id` | `string` | Template, Required | The ID of the order that the tracking information is associated with.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `trackerId` | `string` | Template, Required | The order tracking ID.
**Constraints**: *Minimum Length*: `1`, *Maximum Length*: `36`, *Pattern*: `^[A-Z0-9]+$` | | `paypalAuthAssertion` | `?string` | Header, Optional | An API-caller-provided JSON Web Token (JWT) assertion that identifies the merchant. For details, see PayPal-Auth-Assertion. | | `body` | [`?(Patch[])`](../../doc/models/patch.md) | Body, Optional | - | ## Response Type This method returns a `PaypalServerSdkLib\Utils\ApiResponse` instance. ## Example Usage ```php $collect = [ 'id' => 'id0', 'trackerId' => 'tracker_id2', 'body' => [ PatchBuilder::init( PatchOp::ADD )->build() ] ]; $apiResponse = $ordersController->ordersTrackersPatch($collect); ``` ## Errors | HTTP Status Code | Error Description | Exception Class | | --- | --- | --- | | 400 | Request is not well-formed, syntactically incorrect, or violates schema. | [`ErrorException`](../../doc/models/error-exception.md) | | 403 | Authorization failed due to insufficient permissions. | [`ErrorException`](../../doc/models/error-exception.md) | | 404 | The specified resource does not exist. | [`ErrorException`](../../doc/models/error-exception.md) | | 422 | The requested action could not be performed, semantically incorrect, or failed business validation. | [`ErrorException`](../../doc/models/error-exception.md) | | 500 | An internal server error has occurred. | [`ErrorException`](../../doc/models/error-exception.md) | | Default | The error response. | [`ErrorException`](../../doc/models/error-exception.md) |