> For the complete documentation index, see [llms.txt](https://phpjuice.gitbook.io/paypal-checkout-sdk/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://phpjuice.gitbook.io/paypal-checkout-sdk/api/order.md).

# Order

See <https://developer.paypal.com/docs/api/orders/v2/#definition-order>.

## Methods

### Order::\_\_construct()

Creates an order object using constructor.

#### Signature

```php
public function __construct(string $intent = CAPTURE);
```

#### Example

```php
$order = new Order('CAPTURE');
```

### Order::addPurchaseUnit()

Adds a new purchase unit item into purchase\_units array.

#### Signature

```php
public function addPurchaseUnit(PurchaseUnit $purchase_unit): self;
```

#### Example

```php
$order = new Order('CAPTURE');
$order->addPurchaseUnit($purchase_unit);
```

### Order::getPurchaseUnits()

Gets an array for purchase units from an order.

#### Signature

```php
public function getPurchaseUnits(): array;
```

#### Example

```php
$purchase_units = $order->getPurchaseUnits($purchase_unit);
```

### Order::setApplicationContext()

Sets the application context of an order.

#### Signature

```php
public function setApplicationContext(ApplicationContext $application_context): self;
```

#### Example

```php
$order = new Order('CAPTURE');
$order->setApplicationContext($application_context);
```

### Order::getApplicationContext()

Gets an order application context.

#### Signature

```php
public function getApplicationContext(): ?ApplicationContext;
```

#### Example

```php
$application_context = $order->getApplicationContext() // ApplicationContext::class ;
```

### Order::setIntent()

Sets an order intent.

#### Signature

```php
public function setIntent(string $intent): self;
```

#### Example

```php
$order = new Order('CAPTURE');
$order->setIntent('AUTHORIZE');
```

### Order::getIntent()

Gets an order intent.

#### Signature

```php
public function getIntent(): string;
```

#### Example

```php
$order = new Order('CAPTURE');
$intent = $order->getIntent() // CAPTURE;
```

### Order::getId()

Gets an order id.

#### Signature

```php
public function getId(): string;
```

#### Example

```php
$order = new Order('CAPTURE');
$id = $order->getId() // 8F783829JA718493L;
```

### Order::getStatus()

Gets an order status.

#### Signature

```php
public function getStatus(): string;
```

#### Example

```php
$order = new Order('CAPTURE');
$status = $order->getStatus() // COMPLETED;
```

### Order::getPayee()

Gets an order payee.

#### Signature

```php
public function getPayee(): ?Payee;
```

#### Example

```php
$order = new Order('CAPTURE');
$payee = $order->getPayee() // Payee::class;
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://phpjuice.gitbook.io/paypal-checkout-sdk/api/order.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
